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

gps hector gazebo

asked 2012-09-28 01:25:34 -0600

pmarinplaza gravatar image

I have a lot of troubles to add one module of gps in the robot description.

I find the code in hector_gazebo_plugins/src/gazebo_ros_gps.cpp

I want to use it and add by the next code lines in my robot description:

<joint name="gps_joint" type="fixed">
  <origin xyz="0 0 0"/>
  <parent link="base_link"/>
  <child link="gps_link"/>
</joint>

<link name="gps_link">
  <inertial>
    <mass value="0.001" />
    <origin xyz="0 0 0" rpy="0 0 0" />
    <inertia ixx="0.000000017" ixy="0" ixz="0" iyy="0.000000017" iyz="0" izz="0.000000017" />
  </inertial>
  <visual>
    <origin xyz="0 0 0" rpy="0 0 0" />
    <geometry>
      <box size="0.01 0.01 0.01" />          
    </geometry>
  </visual>
  <collision>
    <origin xyz="0 0 0" rpy="0 0 0" />
    <geometry>
      <box size="0.01 0.01 0.01" />
    </geometry>
  </collision>
</link>


<gazebo>      
  <controller:hector_gazebo_ros_gps name="quadrotor_gps_sim" plugin="libhector_gazebo_ros_test.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>4.0</updateRate>
    <bodyName>gps_link</bodyName>
    <topicName>fix</topicName>
    <velocityTopicName>fix_vel</velocityTopicName>
    <drift>5.0 5.0 5.0</drift>
    <gaussianNoise>0.1 0.1 0.1</gaussianNoise>
    <velocityDrift>0 0 0</velocityDrift>
    <velocityGaussianNoise>0.1 0.1 0.1</velocityGaussianNoise>
<!--interface:position name="gps_position"/-->
  </controller:hector_gazebo_ros_gps>
</gazebo>

When I launch the robot, all works fine except this plugin. I am debugging this source and I notice the error in this line:

if (!_sdf->HasElement("bodyName"))
  {
    link = _model->GetLink();
    link_name_ = link->GetName();
  }
  else {
    link_name_ = _sdf->GetElement("bodyName")->GetValueString();
    link = boost::shared_dynamic_cast<physics::Link>(world->GetEntity(link_name_));
  }
  if (!link)
  {
    ROS_FATAL("GazeboRosTest plugin error: bodyName: %s does not exist\n", link_name_.c_str());
    return;
  }

The return of HasElement is 1 and go inside the else, then, link is empty and return the error, why the link is empty? I write 1 more lines to get

ROS_INFO("bodyName: %s" link_name_.c_str());

And the result is gps_link. In my robot description tf there is indeed gps_link I don't have any clues to continue.

Any ideas? Where Can I find some example to use in the simulator with quadrotor or ugv hector?

Thank you very much.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2012-09-28 01:58:07 -0600

pmarinplaza gravatar image

Ok, I found the problem. When I write the description, I use one ghost base_footprint in the bottom of the robot to use it for transformations (all tf refering that point) and when I use base_link as canonical body the plugins go wrong.

the change is:

<gazebo>      
  <controller:hector_gazebo_ros_gps name="quadrotor_gps_sim" plugin="libhector_gazebo_ros_test.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>4.0</updateRate>
    <bodyName>base_footprint</bodyName>
    <topicName>fix</topicName>
    <velocityTopicName>fix_vel</velocityTopicName>
    <drift>5.0 5.0 5.0</drift>
    <gaussianNoise>0.1 0.1 0.1</gaussianNoise>
    <velocityDrift>0 0 0</velocityDrift>
    <velocityGaussianNoise>0.1 0.1 0.1</velocityGaussianNoise>
    <!--interface:position name="gps_position"/-->
  </controller:hector_gazebo_ros_gps>
</gazebo>

Now, I get the topic fix and fix_velocity very well

edit flag offensive delete link more
0

answered 2017-04-21 09:42:26 -0600

Vincent R gravatar image

There is a hack to be able to have the simulated gps in another frame than base_link.

You can use a revolute joint instead of a fixed joint.

  <link name="navsat_link">
    <inertial>
      <inertia ixx="0.00001" ixy="0.0" ixz="0.0" iyy="0.00001" iyz="0.0" izz="0.00001" />
      <mass value="0.015" />  <!-- [kg] -->
      <origin xyz="0 0 0" rpy="0 0 0" />
    </inertial>
  </link>

  <joint name="navsat_joint" type="revolute">
    <origin xyz="${-wheelbase/2} 0 0.3" rpy="0 0 0" />
    <parent link="base_link" />
    <child link="navsat_link" />
    <limit upper="0" lower="0" effort="0" velocity="0" />
  </joint>

Then you have to use the joint_state_publisher node to publish a fixed (zero) position.

This is inspired by the PR in this repo : https://github.com/ethz-asl/rotors_si...

edit flag offensive delete link more
0

answered 2012-11-02 03:33:52 -0600

The body name gps_link is unknown to gazebo due to the link lumping that happens in the urdf2gazebo parser. There is currently no simple solution to attach the sensor plugins to other bodies than the canonical one that are rigidly attached to it.

Your solution to replace the bodyName gps_link with base_footprint is a workaround, but the output of the sensor is not the same as it it would be attached to the gps_link if these two frames do not coincide.

See this question for a more detailed answer.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-09-28 01:25:34 -0600

Seen: 2,970 times

Last updated: Apr 21 '17