Home | Tutorials | Wiki | Issues
Ask Your Question
1

Visual's material update from ModelPlugin in ROS Gazebo

asked 2013-02-14 05:04:46 -0500

Artem gravatar image

Hello,

I'm new to ROS/Gazebo so excuse me for lame words, terms and my English... and Hi everybody here, it's my first post!

I need to update link's visual material in ModelPlugin depending on some conditions (for example, when switch is up I need to assign Gazebo/GreenGlow to the visual, when it is down then Gazebo/Grey). Can this be achieved from the code ? I tried to update SDF parameters (link->GetSDF()) - I changed <script> to necessary value but this works only once (on gazebo gui startup). After gui is shown gazebo does not update visual using current SDF values without explicit request. So I tried to call link->UpdateParameters(sdf) with an updated sdf but got only this message in the console:

Service call failed: transport error completing service call: unable to receive data from sender, check sender's logs for details Segmentation fault (core dumped) [gazebo-2] process has died [pid 1019, exit code 139, cmd /opt/ros/fuerte/stacks/simulator_gazebo/gazebo/scripts/gazebo /home/ubuntu/work/robonaut2_taskboard_controller/stacks/nasa_r2_simulator/r2_gazebo/gazebo/r2_empty.world __name:=gazebo __log:=/home/ubuntu/.ros/log/48332fd8-7695-11e2-9689-080027b96a58/gazebo-2.log]. log file: /home/ubuntu/.ros/log/48332fd8-7695-11e2-9689-080027b96a58/gazebo-2.log*

I would greatly appreciate any help on this question. Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2013-02-16 13:18:02 -0500

updated 2013-02-16 14:44:00 -0500

Hi, the gazebo api is very powerful and well designed.

I try to solve the problem using a VisualPlugin. The ModelPlugins exist to access the physics features of a Model. Nowadays the tutorials says that exists four kind of plugins: World, Model, Sensor and System. But the VisualPlugin exists too, I don't know if there is no documentation about it.

Well I copy the code of "ModelPush" plugin example and modify to do a visual plugin that changes the color of a box. myplugin.h and myplugin.cpp and finally the world file teste.world.

I don't know if there is another solution, this one is a little complicated, but maybe it serves you.

After you compile the code and run the gazebo with the world file, you should see a static box that changes the color between red and black.

If you need to change the color of things dynamically probably you need some custom messages to communicate a "physical event" to the visual plugin.

I hope that answer helps you.


Well there is an example in folder examples/plugins/model_visuals of gazebo source. Take a look: Example passing a message

This way is the correct way, I think. Once you known the visual name that you need to modify, you just need to create a visual message and sends it to gazebo. The advantage is that you can keep entire code in the ModelPlugin and modify the visuals through messages.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-02-14 05:04:46 -0500

Seen: 2,499 times

Last updated: Feb 16 '13