Home | Tutorials | Wiki | Issues
Ask Your Question
1

how to get the states of other objects in model plugin

asked 2017-11-11 21:41:52 -0600

gazebo_learner gravatar image

I am learning how to write a model plugin to control an object and interact with other objects in Gazebo. In the model plugin tutorial, I see we can get update from "void OnUpdate(const common::UpdateInfo & /_info/)". However, the updateInfo does not seem to contain the poses and motion characteristics of other objects. Could anyone point me to any sample code to do that?

Also, how do I know if my object has a collision with other objects? Are there any events to listen to?

btw: I'm using the direct Gazebo plugins, not the ROS interface yet.

Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-11-12 19:56:51 -0600

It sounds like a world plugin would be more fit for the job. With that, you can access all models in the world.

To detect collisions, a contact sensor should be useful.

edit flag offensive delete link more

Comments

Thank you for the answer. I will grab the model states in the world plugin and also add a contact sensor to each object. That said, I'm surprised that there was not an existing way for each object to get the states of the world (static surface and other objects) easily. I thought this was the basic input to the motion planning and control components. Or are most people using ROS to subscribe/publish messages anyways?

gazebo_learner gravatar imagegazebo_learner ( 2017-11-12 23:38:18 -0600 )edit

There are many ways for models to find information about the world, you can even do it from a model plugin, just get the world pointer with `model->GetWorld()` and you can do anything you can with a world plugin. It's just not recommended because this will be repeated for each model that has the plugin, while if you put the logic in a world plugin it only gets loaded once.

chapulina gravatar imagechapulina ( 2017-11-13 16:47:45 -0600 )edit

I see. I'll use model->GetWorld() to get other model states. I agree with your point - we apply the logic at right places only. Thank you so much!

gazebo_learner gravatar imagegazebo_learner ( 2017-11-13 22:37:13 -0600 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2017-11-11 21:41:52 -0600

Seen: 23 times

Last updated: Nov 12