Visualize Gazebo Simulation in rviz
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!