Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem adding gazebo_ros_control plugin in sdf model and running in gazebo

Hello. I have a problem in my sdf model.I am trying add this code to my robot model sdf:

<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/my_robot2</robotNamespace>

    </plugin>

I am running this on ubuntu 12.04 with ROS Hydro and Gazebo1.9. I do this on terminal: §optirun gazebo I use optirun because I have two graphics boards (Bumblebee). After having the gazebo running, and I try to insert my model in gazebo through the insert option of gazebo. But I receive this error when inserting the model and the gazebo close.

[FATAL] [1394020657.190138065]: You must call ros::init() before creating the first NodeHandle
[FATAL] [1394020657.190343598]: BREAKPOINT HIT
    file = /tmp/buildd/ros-hydro-roscpp-1.9.54-0precise-20140130-2139/src/libros/node_handle.cpp
    line=151

Here is my model.sdf:

<?xml version="1.0"?>
<sdf version="1.4">
  <model name="my_robot2">
    <static>false</static>

    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/my_robot2</robotNamespace> 
    </plugin>


    <link name="chassis">
      <pose>0 0 0.16 0 0 0</pose>
      <inertial> 
        <mass>5.0</mass>
      </inertial>
      <collision name="collision">
        <geometry>
          <box>
            <size>0.445 0.277 0.17</size>
          </box>
        </geometry>
      </collision>
      <collision name="castor_collision">
        <pose>-0.200 0 -0.12 0 0 0</pose>
        <geometry>
          <sphere>
            <radius>0.04</radius>
          </sphere>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>0</mu>
              <mu2>0</mu2>
              <slip1>1.0</slip1>
              <slip2>1.0</slip2>
            </ode>
          </friction>
        </surface>
      </collision>
      <visual name="visual">
        <pose>0 0 0.04 0 0 0</pose>
        <geometry>
          <mesh>
            <uri>model://pioneer2dx/meshes/chassis.dae</uri>
          </mesh>
        </geometry>
      </visual>
      <visual name="castor_visual">
        <pose>-0.200 0 -0.12 0 0 0</pose>
        <geometry>
          <sphere>
            <radius>0.04</radius>
          </sphere>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/FlatBlack</name>
          </script>
        </material>
      </visual>
    </link>
    <link name="right_wheel">
      <pose>0.1 -.17 0.11 0 1.5707 1.5707</pose>
      <inertial>
        <mass>0.1</mass>
      </inertial>
      <collision name="collision">
        <geometry>
          <cylinder>
            <radius>0.11</radius>
            <length>0.05</length>
          </cylinder>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>100000.0</mu>
              <mu2>100000.0</mu2>
              <slip1>0.0</slip1>
              <slip2>0.0</slip2>
            </ode>
          </friction>
        </surface>
      </collision>
      <visual name="visual">
        <geometry>
          <cylinder>
            <radius>0.11</radius>
            <length>0.05</length>
          </cylinder>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/FlatBlack</name>
          </script>
        </material>
      </visual>
    </link>
    <link name="left_wheel">
      <pose>0.1 .17 0.11 0 1.5707 1.5707</pose>
      <inertial>
        <mass>0.5</mass>
      </inertial>
      <collision name="collision">
        <geometry>
          <cylinder>
            <radius>0.11</radius>
            <length>0.05</length>
          </cylinder>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>100000.0</mu>
              <mu2>100000.0</mu2>
              <slip1>0.0</slip1>
              <slip2>0.0</slip2>
            </ode>
          </friction>
        </surface>
      </collision>
      <visual name="visual">
        <geometry>
          <cylinder>
            <radius>0.11</radius>
            <length>0.05</length>
          </cylinder>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/FlatBlack</name>
          </script>
        </material>
      </visual>
    </link>
    <joint type="revolute" name="left_wheel_hinge">
      <pose>0 0 -0.03 0 0 0</pose>
      <child>left_wheel</child>
      <parent>chassis</parent>
      <axis>
        <xyz>0 1 0</xyz>
      </axis>
    </joint>
    <joint type="revolute" name="right_wheel_hinge">
      <pose>0 0 0.03 0 0 0</pose>
      <child>right_wheel</child>
      <parent>chassis</parent>
      <axis>
        <xyz>0 1 0</xyz>
      </axis>
    </joint>

<!--
    <plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller">
      <robotNamespace>/myrobot2</robotNamespace>
      <alwaysOn>true</alwaysOn>
      <updateRate>100</updateRate>
      <leftJoint>left_wheel_hinge</leftJoint>
      <rightJoint>right_wheel_hinge</rightJoint>
      <torque>5</torque>
      <wheelSeparation>0.39</wheelSeparation>
      <wheelDiameter>0.15</wheelDiameter>
      <commandTopic>p3dx/cmd_vel</commandTopic>
      <odometryTopic>p3dx/odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>base_link</robotBaseFrame>
    </plugin>-->

    <plugin filename="libDiffDrivePlugin.so" name="diff_drive">
      <left_joint>left_wheel_hinge</left_joint>
      <right_joint>right_wheel_hinge</right_joint>
      <torque>5</torque>
    </plugin>
    <include>
      <uri>model://noisy_laser</uri>
      <pose>0.2 0 0.3 0 0 0</pose>
    </include>
    <joint name="hokuyo_joint" type="revolute">
      <child>hokuyo::laser_link</child>
      <parent>chassis</parent>
      <axis>
        <xyz>0 0 1</xyz>
        <limit>
          <upper>0</upper>
          <lower>0</lower>
        </limit>
      </axis>
    </joint>
  </model>
</sdf>

If I erase that code of gazebo_ros_control plugin, the gazebo can insert the model without nay problem. Can anyone find the problem?? I search on web but only tutorials that explain sdf, are of the gazebosim, but they don't explain how insert plugin to sdf files. For me the tutorials of modeling a robot in sdf are too incomplete. I think that I am putting the code in wrong way.

I have another question, if rviz suport SDF models or only URDF models? If I can load my model in rviz with sdf model?

Thanks for your time.