0
$\begingroup$

Rosanswers logo

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" />

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!


Originally posted by uschwes on ROS Answers with karma: 51 on 2011-06-22

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by hsu with karma: 5780 on 2011-06-22

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

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).


Originally posted by dornhege with karma: 31395 on 2011-06-22

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.