ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Detect collision Stage

asked 2013-06-21 05:15:17 -0600

Mago Nick gravatar image

updated 2014-01-28 17:17:00 -0600

ngrennan gravatar image

hi, I'm trying to simulate two differential drive robots walking in a corridor (the map is provided as png and yaml files, and I cannot change it) using stage. Since one of the robots uses a reinforcement-learning-based controller I need to model the state of the simulation. The state is composed of various information such as if the robot has reached its goal or if a collision (no matter what kind of collision) has occurred. The problem I'm having is to detect if the robot running my controller has collided with something. Since the image representing the robot changes in stage, I assume that stage is aware of such collision and I would like to retrieve such information. Can you help me doing this? Thanks Andrea

edit retag flag offensive close merge delete


I am in an exactly similar situation. RL controller with stageros for simulation.

devesh gravatar image devesh  ( 2013-11-20 18:11:00 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-11-21 01:03:30 -0600

devesh gravatar image

As gustavo suggested, I modified src/stageros.cpp. The boolean 'stall' is set iff there is a collision at the instant. Stalled() function returns this value and can be called to check.

Other details regarding the solution

But after modifying, 'rosmake stage' does not work for some reason (just like this thread

So, after modifying the permissions of the stage stack folder I ran 'make'. After downloading the md5sum tarball into the build folder, it compiled most of the code. But then, it gave out the error "undefined reference to Fl::wait(double)".

Turns out, it is a problem with gcc and ordering of flags. So, as suggested in, I edited CMakeLists.txt towards the bottom into (I just added the 3rd line)

rosbuild_add_compile_flags(bin/stageros ${STAGE_CFLAGS_OTHERS})
target_link_libraries(bin/stageros ${STAGE_LIBRARIES})
target_link_libraries(bin/stageros fltk fltk_gl fltk_images)
rosbuild_add_link_flags(bin/stageros ${STAGE_LDFLAGS_OTHERS})
edit flag offensive delete link more


hi devesh, can you please elaborate on how you achieved this? I can't seem to get anything to compile on ROS jade

jsergeant gravatar image jsergeant  ( 2015-09-09 23:58:35 -0600 )edit

Hi jsergeant, unfortunately I'm out of touch with ROS and don't use it anymore. I remember it was a tedious chase to fix errors for compilation but don't even remember what all I did to get it to work.

devesh gravatar image devesh  ( 2015-09-10 05:00:05 -0600 )edit

answered 2019-10-30 02:29:23 -0600

wuch gravatar image

As suggested by @gustavo.velascoh and @devesh, one can modify src/stageros.cpp. You can find these two lines in src/stageros.cpp which gives you a hint:

//@todo Publish stall on a separate topic when one becomes available
//this->odomMsgs[r].stall = this->positionmodels[r]->Stall();

Note that Stall() should be Stalled().

In my case:

        // do something
edit flag offensive delete link more

answered 2013-06-28 05:24:03 -0600

I think you should modify stageros to match your requirements. I suggest you to see stagelib documentation and look for a attribute of position model which could represent the collision state and modify stageros.cpp to publish it.

edit flag offensive delete link more


Actually, in past ros version there was a te Planning_environment class that allowed this. But in fuerte I can't find anything similar. I believe that editing the source of a library is not an ideal solution, unfortunately. thanks anyway, I will keep searching for a solution

Mago Nick gravatar image Mago Nick  ( 2013-07-02 00:52:07 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-06-21 05:15:17 -0600

Seen: 1,199 times

Last updated: Oct 30 '19