ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to compile and run code written with MoveIt API?

asked 2017-02-18 05:21:13 -0500

gsarret gravatar image

updated 2017-02-18 05:25:34 -0500

There are several tutorials on MoveIt website on C++ API like this one. I've downloaded them, built using catkin build and now can run those examples using roslaunch. But how exactly do I compile and run my own code? If I copy one of the example cpp-files to ${CATKIN_WS}/moveit_mycode/, say move_group_interface_tutorial.cpp, edit a couple of lines, then what do I do next?

My take is that I shouldn't use gcc straightforwardly, but rather catkin build, which means I need a CMakelists.txt or something similar. Also, should I write a .launch file? I realize this is a very basic question, but I couldn't figure it out. I couldn't find any info on the topic, too, neither on MoveIt website nor anywhere else. I'd appreciate any help!

I'm on ROS Kinetic, Ubuntu 16.04.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2017-02-18 06:44:01 -0500

gvdhoorn gravatar image

updated 2017-02-18 06:48:46 -0500

I realize this is a very basic question, but I couldn't figure it out. I couldn't find any info on the topic, too, neither on MoveIt website nor anywhere else. I'd appreciate any help!

Well .. these aren't really MoveIt specific questions, so I'm not surprised you can't find anything there: creating packages and writing nodes are considered basic skills when developing with ROS, so they are not covered by package-specific tutorials like those for MoveIt.

I would recommend you take a look at the wiki/tutorials and you pick up a book (or two). A Gentle Introduction to ROS is free (although the author would probably appreciate it very much if you'd support him by buying a hardcopy from Amazon), and as far as I've understood from others, a good introduction to some of the basic workflows in ROS.


My take is that I shouldn't use gcc straightforwardly

Well, you could, but it doesn't really scale very well, so avoiding it is a good idea.

but rather catkin build, which means I need a CMakelists.txt or something similar.

Indeed. But understand that CMakeLists.txt are not something we in ROS invented. It's all just CMake (so be sure to look up CMake documentation as well as Catkin's (and read/follow some tutorials)).

Also, should I write a .launch file?

Only if you feel that would help make your life easier. Basically, a launch file is script that starts a bunch of nodes for you with a single command. Instead of having N open terminals and writing rosrun .. N times, roslaunch takes care of starting everything for you.

So if you have just a single node, then rosrun $pkg $binary_name .. might be enough. As soon as you have multiple nodes that (need to) work together, launch files would start to make sense. But it's perfectly possible to use a launch file for a single node as well.

Also:

If I copy one of the example cpp-files to ${CATKIN_WS}/moveit_mycode/ [..]

If you have an actual Catkin workspace, then source files should not be placed at the root of it, but rather in the source space (${CATKIN_WS}/src by default). And also in a package, but that'll become clear when you read up on these things.

edit flag offensive delete link more

Comments

2

PS: yes, you could place nodes anywhere, and packages and building with Catkin are not required either, but if you're just starting out I would not try to fight the system in those ways yet. Focus on understanding what is going on in 'normal' workflows, then start thinking about changing them.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-18 06:47:54 -0500 )edit

Thank you so much for a detailed answer! Everything makes a bit more sense now to me. As you've probably noticed, I'm a newbie. I'll dig into reading ROS tutorials and docs. I've read some already, just didn't realize I have to create my own package. I was aware of CMake, of course! (: Thanks again!

gsarret gravatar image gsarret  ( 2017-02-18 07:03:14 -0500 )edit

No problem. Glad I could help.

For Catkin specifically btw, you might also want to take a look at A Gentle Introduction to Catkin by @jbohren.

It's rather defailed (so not needed per se), but good if you really want to know what is going on.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-18 07:21:32 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-18 05:21:13 -0500

Seen: 515 times

Last updated: Feb 18 '17