Home | Tutorials | Wiki | Issues
Ask Your Question
0

Find ground height in Gazebo WorldPlugin

asked 2017-06-14 04:01:05 -0600

NoWiS gravatar image

Hi,

In a Gazebo WorldPlugin, I would like to know the ground position below a point. Sadly it seems that it can't have access to rendering::Scene which offers such methods.

Is there another methods to do so accessible from a WorldPlugin ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-06-22 10:06:08 -0600

NoWiS gravatar image

Basically, you can access the HeightmapShape, and use it to compute the height :

// Get the HeightmapShape
physics::ModelPtr model = parent->GetModel( "heightmap" );
physics::HeightmapShape* hm = dynamic_cast<physics::HeightmapShape*>( model->GetLink("link")->GetCollision("collision")->GetShape().get() );        

// The HeightmapShape does not work with the same coordinate system, so get some data:
math::Vector3 size = hm->GetSize(); 
math::Vector2i vc = hm->GetVertexCount();
double ss = static_cast<double>( hm->GetSubSampling() );

// And finally get your z from your x and y:
double z = hm->GetHeight( (x + size.x/2)/size.x*vc.x - 1, (y + size.y/2)/size.y*vc.y - 1);

Be careful, this example

  • makes no safety checks
  • suppose the heightmap orgin is 0,0,0
edit flag offensive delete link more
0

answered 2017-09-07 14:23:18 -0600

dmeltz gravatar image

with some small but quite critical corrections i manage to make NoWiS code to work, i put mine over here

edit flag offensive delete link more

Comments

Thanks for the update :)

NoWiS gravatar imageNoWiS ( 2017-09-14 04:05:57 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-06-14 04:01:05 -0600

Seen: 195 times

Last updated: Sep 07