run move_base node and get costmap from text file - ros

The move_base node call the function makePlan:
bool makePlan(
const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal,
std::vector<geometry_msgs::PoseStamped>& plan
)
I wrote a c++ program to randomly generate start, goal, and map, which is a 2d array of 0s(free) and 100s(obstacle), and store this data into text file.
How can I configure makePlan to take start and goal from this text file, and how to allow move_base to use the 2d array stored in the text file?
Appreciate any help.

You can create your own GlobalPlanner by implementing a GlobalPlanner Plugin see: http://wiki.ros.org/navigation/Tutorials/Writing%20A%20Global%20Path%20Planner%20As%20Plugin%20in%20ROS
Then frist step would be to copy the original source code of the GlobalPlanner to your own GlobalPlanner and make it work.
Now you can change the make_plan method in your own global planner and adjust it as you like.

Related

Migrate Vim/Vimscript for asynchronously running external editors to Lua/Neovim

In my Vim's configuration file init.vim I am using code, that sets a default viewer for practically any kind of file suffix. Here I will demonstrate only an example for .md files:
let g:netrw_browsex_viewer="-"
function! NFH_md(f)
call asyncrun#run("", "cwd", "typora " . a:f)
endfunction
First paragraph makes sure to choose the function based on suffix of the file ("URI under cursor"). Second paragraph shows a function whose name i.e. NFH_md implies that this is the function opened when .md file is in the "URI under the cursor". Inside this function there is an call that opens an external program typora asynchronously so that I am still able to continue using Vim.
If you want to know more use :help netrw_browsex_viewer.
I tried porting the mentioned Vim script to Neovim & Lua but I only managed to port first line:
vim.g.netrw_browsex_viewer="-"
For I don't know, how to properly port the second paragraph. This is why for now I just use Vimscript source code like this:
vim.api.nvim_exec(
[[
function! NFH_md(f)
call asyncrun#run("", "cwd", "marktext " . a:f)
endfunction
]],
false
)
But I would love to translate all the code to Lua - Could anyone help a bit to translate this remaining Vimscript code to Lua?

create a Scale9Sprite in quick-cocos

Bt using function following may create a Scale9Sprite
display.newScale9Sprite(filename, x, y, size, capInsets)
The image is packed in a pvr.ccz file which is encrypted. I don't think using the function above is a good way to do the job.
So I wonder whether there is a function may create Scale9Sprite from SpriteFrame? Or I have to save the image in a single file?
You can use
CCScale9Sprite:createWithSpriteFrame(spriteFrame, capInsets)
and
CCScale9Sprite:createWithSpriteFrameName(spriteFrameName, capInsets)
to create your sprite.

Parsing LLVM IR code (with debug symbols) to map it back to the original source

I'm thinking about building a tool to help me visualise the generated LLVM-IR code for each instruction/function on my original source file.
Something like this but for LLVM-IR.
The steps to build such tool so far seem to be:
Start by with LLVM-IR AST builder.
Parse generated IR code.
On caret position get AST element.
Read the element scope, line, column and
file and signal it on the original source file.
Is this the correct way to approach it? Am I trivialising it too much?
I think your approach is quite correct. The UI part will probably be quite long to implement so I'll focus on the llvm part.
Let's say you start from a input file containing your LLVM-IR.
Step 1 process module:
Read file content to a string. Then Build a module from it, and process it to get the debug info:
llvm::MemoryBuffer* buf = llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(fileContent)).release();
llvm::SMDiagnostic diag;
llvm::Module* module = llvm::parseIR(buf->getMemBufferRef(), diag, *context).release();
llvm::DebugInfoFinder* dif = new llvm::DebugInfoFinder();
dif->processModule(*module);
Step 2 iterate on instructions:
Once done with that, you can simply iterate on function and blocks and instructions:
// pseudo code for loops (real code is a bit long)
foreach(llvm::Function f in module.functions)
{
foreach(llvm::BasicBlock b in f.BasicBlockList)
{
foreach(llvm::Instruction inst in b.InstList)
{
llvm::DebugLoc dl = inst.getDebugLoc();
unsigned line = dl->getLine();
// accordingly populate some dictionary between your instructions and source code
}
}
}
Step 3 update your UI
This is another story...

Saving image in plot window after placing points in plot

Using Octave, I am able to show a image and then plot some red circles over it, as follow:
tux = imread('tux.png');
imshow(tux);
hold on;
plot(100,100,'r','markersize', 10);
plot(150,200,'r','markersize', 10);
The above code display this window:
My question is: How can I save this image as it is being showed inside the window?
Thank you very much!
Pretty simple. Use:
print -djpg image.jpg
print is a command in Octave that allows you to capture what's currently seen in the current figure window. -d specifies what output device you want to write to. There are multiple "devices" you can use to save to file... EPS, PS, TEX, etc. A device can also be an image writer, and so here I chose JPEG. You can choose other valid image formats that are supported by Octave. Take a look at the link I provided above for more details.
After, you just specify what file name you want to save the plot to. In this case, I chose image.jpg.
You can also take a look at saveas. Make sure you get a handle to the current figure first before doing so:
h = gcf;
saveas(h, "image.jpg");
Also... a more point-and-click approach would be to Go to File -> Save As in the figure that your image is displayed in :)
You can use print to save your plot to a file:
print (FILENAME, OPTIONS) // for the current figure
print (H, FILENAME, OPTIONS) // for the figure handle H
and also take a look to saveas
saveas (H, FILENAME)

Delphi HtmlHelpAPI- How to direct a CHM file to open to different sections

I am able to open a CHM file by passing a ShortInteger and casting it as a Word for the dwData parameter. I.E.
Unit Help; //this is where the Id's are set with their description
Interface
Const
Address_File = 35; //delphi identifies Address_File as a shortint
etc..
Call get help pass my ID
GetHelp(Address_File); //call get help pass my ID to open to the Address_File topic
GetHelp procedure
procedure GetHelp(HelpID : Word);
begin
Application.HelpFile := ProgramPath + 'help.chm';
HtmlHelpW(0, PWideChar(Application.HelpFile),HH_HELP_CONTEXT , HelpID);
end;
HtmlHelpW function
function HtmlHelpW(hwndCaller : HWND; pszFile: PWideChar; uCommand : Integer;
dwData : DWORD) : HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpW';
As I pass different ShortIntegers I am able to initialize the help file at different sections.
However I can't figure out how the values are mapped. There are some sections in the chm file that I want to be able to map to but the short Integer or context ID associated with them is not documented in the program or is not mapped.
Free Pascal comes with a chmls.exe util that has a command that tries to recover the alias (context) data:
chmls, a CHM utility. (c) 2010 Free Pascal core.
Usage: chmls [switches] [command] [command specific parameters]
Switches :
-h, --help : this screen
-p, --no-page : do not page list output
-n,--name-only : only show "name" column in list output
Where command is one of the following or if omitted, equal to LIST.
list <filename> [section number]
Shows contents of the archive's directory
extract <chm filename> <filename to extract> [saveasname]
Extracts file "filename to get" from archive "filename",
and, if specified, saves it to [saveasname]
extractall <chm filename> [directory]
Extracts all files from archive "filename" to directory
"directory"
unblockchm <filespec1> [filespec2] ..
Mass unblocks (XPsp2+) the relevant CHMs. Multiple files
and wildcards allowed
extractalias <chmfilename> [basefilename] [symbolprefix]
Extracts context info from file "chmfilename"
to a "basefilename".h and "basefilename".ali,
using symbols "symbolprefix"contextnr
extracttoc <chmfilename> [filename]
Extracts the toc (mainly to check binary TOC)
extractindex <chmfilename> [filename]
Extracts the index (mainly to check binary index)
This might be a start, since at least you'll know which pages are exported using an ID, and maybe the URL names will give some information.
The util is in recent releases (make sure you get 2.6.0) and also available in Free Pascal source, which should be convertable to Delphi with relatively minor effort.
Basically the chmls tool was created out of various test codebases. The testprograms decompiled and printed contents of different CHM sections and were used while creating the helpfile compiler, chmcmd, which is also part of FPC.
In Delphi, calling a help file is rather easy. In any VCL Forms application, you can set the HelpContext property of almost any control to a unique Context ID, which corresponds to a particular topic in the Help File. The Help File was compiled with these mappings, but when you decompile it, these mappings are no longer there. You must have access to the original help file project in order to know these ID's.
Set HelpContext of controls to the corresponding Context ID in the Help File
Set HelpType of controls to htContext to use the HelpContext ID
Assign Application.HelpFile to the appropriate location of the CHM file
When pressing F1 anywhere in your application, the help file will open based on the Help Context ID on the control, or its parent control
If you don't have the original project, and you don't want to re-create it, then you would have a long task of iterating through the Context ID's of your help file. Try to call the help file starting from 0 through 1,000 or possibly 50,000, depending on the size of it.
A practice I implement is a set of constants in a designated unit called HelpConstants.pas which is shared across our common application base. Each constant name uniquely and briefly describes the topic which it represents. Upon starting the application, I dynamically assign these Context ID's to their corresponding controls (usually forms) and VCL takes care of the rest.
I got the utility Marco suggested from
https://github.com/alrieckert/freepascal_arm/blob/master/packages/chm/bin/i386-win32/chmls.exe
(download by selecting View Raw).
I was able to extract all the context tags from the .chm help file and add the one I was interested in to my C++ Builder program by calling Application->HelpJump().
HTH

Resources