Gazebo | Ignition | Community
Ask Your Question

Control Model Tutorial: Sensor isn't attached

asked 2013-03-25 19:35:19 -0600

Ben B gravatar image

updated 2013-03-26 12:37:05 -0600

I'm going through the Control Model tutorial. Part of the plugin displays the minimum distance sensed by a ray sensor. Unfortunately, it's perpetually displaying min_range = 9.500. I think the sensor isn't travelling with the box, because when I change the initial pose of the box, the 9.500 value changes to something else and stays put.

My understanding was that having the sensor inside of <joint></joint> tags was supposed to keep it attached. Am I wrong? How do I attach it?

I'm wondering if something in Gazebo is configured wrong because running this tutorial up to and including the gztopic echo /gazebo/default/box/link/my_contact doesn't produce anything other than

$ gztopic echo /gazebo/default/box/link/my_contact
Msg Waiting for master
Msg Connected to gazebo master @
Msg Publicized address:
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2013-03-27 15:00:46 -0600

GAugusto gravatar image

updated 2013-03-27 19:10:36 -0600

hi. try to check if each ray is measuring correctly.

edit the plugin to:

      this->model->SetLinearVel(math::Vector3(0, 0, 0)); //so it does not move

and add this below it

      // console output
      static int rgcount =0;
      rgcount ++;
         rgcount = 0; 
         float r0 = this->raysensor->GetRange(0); //index 0
         float r90 = this->raysensor->GetRange(90); //index 90
         float r180 = this->raysensor->GetRange(179); //index 179
         printf("0deg:   %3.3f \n90deg:  %3.3f \n180deg: %3.3f \n\n", r0, r90, r180);


then manualy put/move cubes at these angles changing distances, see if the values match or if they give the same number as before. also move the box with the sensor manualy around to see if the sensor moves with the box.

edit: index 180 -> 179

edit flag offensive delete link more


I think index 180 should be index 179. Anyway, no change. I'm getting 30, 9.5, and 30.

Ben B gravatar imageBen B ( 2013-03-27 16:09:19 -0600 )edit

yes, indeed it should be 179 (i used to use 181samples). well the ranges seam correct. did moving the box manualy changed the range values? if not then the sensor is not moving with the model, wich is wierd because the model description seams correct.

GAugusto gravatar imageGAugusto ( 2013-03-27 19:04:18 -0600 )edit

Unfortunately, the values stayed the same.

Ben B gravatar imageBen B ( 2013-03-27 19:18:56 -0600 )edit

that is very strange,the sensor is really unattached from the model. i just finished redoing the tutorial and it worked, tho im using gazebo1.4 the sdf is still 1.3 :/ can you see the rays (blue field) moving with the box?

GAugusto gravatar imageGAugusto ( 2013-03-27 19:53:32 -0600 )edit

I don't see the blue rays at all.

Ben B gravatar imageBen B ( 2013-03-27 19:58:35 -0600 )edit

then probably there was a bug/accident during the installation. unfortunately i cant help you more. :( last resource scenario reinstall gazebo, BUT make a backup of your .bashrc file (gedit ~/.bashrc) just to be safe before you reinstall.

GAugusto gravatar imageGAugusto ( 2013-03-27 20:13:33 -0600 )edit

Thanks for trying, GAugusto. Unfortunately, I've tried reinstalling. First I had it installed from a repo, then I tried from source. I've also reproduced this error on fresh install on another computer.

Ben B gravatar imageBen B ( 2013-03-28 12:13:09 -0600 )edit

answered 2013-03-25 23:40:34 -0600

Boris gravatar image

According to SDF 1.3:

A plugin is a dynamically loaded chunk of code. It can exist as a child of world, model, and sensor.

You can see also that there are no <plugin> tags inside <joint> section. So you have to move it to <model> section as it done in tutorial.

edit flag offensive delete link more


Hi there, my code is just like in the tutorial. The plugin is within the model tags. And the ray sensor is within the joint tags.

Ben B gravatar imageBen B ( 2013-03-26 09:43:24 -0600 )edit

you mean within the <link> tags, right? that's hot it is in the example

AndreiHaidu gravatar imageAndreiHaidu ( 2013-03-26 10:21:25 -0600 )edit

My bad. You're right. I should've said: It's within the <link> tags.

Ben B gravatar imageBen B ( 2013-03-26 11:23:53 -0600 )edit

answered 2013-03-26 03:33:55 -0600

AndreiHaidu gravatar image


I am not sure because I did not have time to test it, but I noticed in the code the following line may be wrong, this could be the reason you always get a constant for the range value.

double min_range = this->raysensor->GetRangeMax();

notice how 'min_range' variable gets the max range value from the function 'GetRangeMax()'

And is the plugin doing what is supposed to do? 'You should see the box move slowly towards the wall.' ?

Cheers, Andrei

edit flag offensive delete link more


Hi Andrei, I think I interpreted it like you did at first. But I think the get range max function is actually the max range of the sensor is actually the furthest it can sense. So it makes sense that it defaults to this when it has no other reading.

Ben B gravatar imageBen B ( 2013-03-26 09:47:16 -0600 )edit

Also, the box does move.

Ben B gravatar imageBen B ( 2013-03-26 09:55:02 -0600 )edit

And does it stop when it is close to the wall? If it does, that means the range changes, as it only stops when the range is below 1.0 : if(min_range <= 1.0) \n vel = 0.0;

AndreiHaidu gravatar imageAndreiHaidu ( 2013-03-26 10:26:44 -0600 )edit

It only stops when hits the wall. The min_range reports 9.5 from when it starts and continues to report 9.5 even when it's running into the wall.

Ben B gravatar imageBen B ( 2013-03-26 11:24:52 -0600 )edit

Okey, I also tried the exapmple, and for me it worked, I am using gazebo 1.5 from source, what is your version?

AndreiHaidu gravatar imageAndreiHaidu ( 2013-03-26 12:06:48 -0600 )edit

I'm using 1.5.0 installed from the repo. The only change I've made to the tutorial is that mine is all installed in a different directory. Though I'm not getting any errors about missing anything. I'll try the directory mentioned in the tutorial.

Ben B gravatar imageBen B ( 2013-03-26 12:14:09 -0600 )edit

Still no dice.

Ben B gravatar imageBen B ( 2013-03-26 12:21:31 -0600 )edit

Andrei, can you see the rays from the sensor? Also, do you get this error: "Error [Events.hh:141] Events::ConnectWorldUpdateStart is deprecated in v 1.5.0. Please use Events::ConnectWorldUpdateBegin" ? I've tried making the change the error suggests. The error goes away, but it still doesn't work.

Ben B gravatar imageBen B ( 2013-03-26 12:24:38 -0600 )edit

Yes I can see the rays, I also got the error and it worked with it, so I did not change it to Events::ConnectWorldUpdateBegin.

AndreiHaidu gravatar imageAndreiHaidu ( 2013-03-26 12:31:44 -0600 )edit

Dang. I can't seem to get any of the sensors to report anything. I've updated the question to reflect that the contact sensor doesn't work either.

Ben B gravatar imageBen B ( 2013-03-26 16:29:41 -0600 )edit

Question Tools


Asked: 2013-03-25 19:35:19 -0600

Seen: 629 times

Last updated: Mar 27 '13