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

Visualize Gazebo Simulation in rviz

asked 2011-06-22 01:55:09 -0500

uschwes gravatar image

updated 2011-06-22 01:57:33 -0500

Hi,

though there are some related questions to this topic, I stumbled into some specific problems. I simply want to have my robot model dynamically displayed in rviz and use gazebo just for the simulation:

Currently my launch file looks like this:

<launch>

<param name="/use_sim_time" value="True" />


<!-- Run Gazebo simulator with the specified world -->
<node name="gazebo" pkg="gazebo" type="gazebo"
      args="$(find gazebo_worlds)/worlds/empty.world -r" output="screen" respawn="false" />


<!-- convert from xacro to urdf and push it to parameter server-->
<param name="robot_description" command="$(find xacro)/xacro.py '$(find package_name)/model/model_name.urdf.xacro'" />


<!-- push robot_description to factory and spawn robot in gazebo -->
<node name="spawn_car" pkg="gazebo" type="spawn_model" args="-urdf -param robot_description -z 1.051 -model car" respawn="false" output="screen" />


<!-- start robot state publisher -->
<node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" output="screen" >
    <param name="publish_frequency" type="double" value="1.0" />
    <param name="tf_prefix" type="string" value="" />
</node>

<node name="joint_state_publisher" pkg="joint_state_publisher"
type="joint_state_publisher" />

</launch>

Am I right, that the joint_state_publisher reads in the urdf description of the robot and therefore, when I manipulate my model in gazebo, these changes will not appear in the tf transform from robot_state_publisher and hence not in rviz?

Do I have to set up the tf transforms in my controller function then? If so, I would have another question: I define the controller in my robot model via

<!-- Ackermann plugin -->
<gazebo>
  <controller:ackermann_plugin name="ackermann_controller"
  plugin="libackermann_plugin.so">
<alwaysOn>true</alwaysOn>
...parameters
<interface:position name="position_iface_0" />
<robotNamespace>/</robotNamespace>
<topicName>VehicleControl</topicName>
  </controller:ackermann_plugin>
</gazebo>

and access it later on in the controller with

pos_iface_ = dynamic_cast<libgazebo::PositionIface*> (GetIface("position"));

and

pos_iface_->data->pose.yaw

and so on.

So which joint am i getting the information from? How can I access multiple/all joints to set up the tf transforms?

Might be rather fundamental questions, but I'm somehow stuck here. Help appreciated, thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2011-06-22 03:45:06 -0500

hsu gravatar image

On the PR2 the GazeboRosControllerManager instantiates a ControllerManager, which publishes joint_states. joint_states is subscribed by robot_state_publisher to produce the tf tree for the robot.

You can do the same by publishing joint_states in your plugin and starting a robot_state_publisher separately to broadcast tf tree for you; or you can broadcast a tf tree of your robot directly in your plugin.

edit flag offensive delete link more
1

answered 2011-06-22 03:06:22 -0500

dornhege gravatar image

You probably want to have a setup that mimics a real robot. That means that the joint states that are input in the robot_state_publisher come from gazebo as that knows where the joints are. You will get /tf then as is a real robot from robot_state_publisher.

You only use the joint_state_publisher or other programs to send commands to gazebo or a controller in between that will then apply these actions in gazebo (which in turn will send out joint states that go into the robot_state_publisher producing /tf).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-06-22 01:55:09 -0500

Seen: 4,384 times

Last updated: Jun 22 '11