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

Detect collision Stage

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

Mago Nick gravatar image

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

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

Comments

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

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

3 Answers

Sort by ยป oldest newest most voted
2

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

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 http://answers.ros.org/question/87666/no-executable-in-bin-with-rosmake-on-groovy/)

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 http://player-stage-gazebo.10965.n7.nabble.com/Stage-install-error-td6455.html, 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

Comments

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 -0500 )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 -0500 )edit
1

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

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:

if(this->positionmodels[r]->Stalled()){
        // do something
}
edit flag offensive delete link more
0

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

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

Comments

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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 1,306 times

Last updated: Oct 30 '19