0
$\begingroup$

Rosanswers logo

I am a ROS beginner so this might all be a rather basic mistake. But I have a simulation of a drone in Gazebo. I am using controller_manager to spawn controllers for the propellers and a camera. However, robot model in Rviz gives me a lot of no transform link errors because /joint_state topic is not being published.

Here is my control.yaml file

joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50

joint_motor_controller:
  type: velocity_controllers/JointGroupVelocityController
  joints:
    - front_left_prop_joint
    - front_right_prop_joint
    - back_left_prop_joint
    - back_right_prop_joint

camera_joint_position_controller:
  type: position_controllers/JointPositionController
  joint: camera_joint

drone_base.xacro

<?xml version="1.0" encoding="utf-8"?>
<robot name="drone_description"
  xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:property name="PI" value="3.14159265359"/>

  <xacro:include filename="$(find drone_description)/urdf/drone_macros.xacro" />
  <xacro:include filename="$(find drone_description)/urdf/drone_gazebo.xacro" />
  <xacro:include filename="$(find drone_description)/urdf/sensors.xacro" />

  <!-- DUMMY lINK -->
  <link name="dummy_link" />

  <!-- LINKS -->
  <link name="base_link">
    <inertial>
      <origin xyz="5.7334E-07 0.026879 0.015324" rpy="0 0 0" />
      <mass value="0.38016" />
      <inertia ixx="0.00029212" ixy="-1.331E-09" ixz="-3.9126E-08" iyy="0.00040699" iyz="1.6869E-06" izz="0.00015798" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://drone_description/meshes/base_link.STL" />
      </geometry>
      <material name="">
        <color rgba="0.69804 0.69804 0.69804 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://drone_description/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>

  <link name="camera">
    <inertial>
      <origin xyz="-0.0036143 0.00349 0.00925" rpy="0 0 0" />
      <mass value="0.090718" />
      <inertia ixx="2.4903E-06" ixy="3.2829E-09" ixz="8.2525E-22" iyy="3.279E-06" iyz="-1.531E-21" izz="2.3388E-06" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://drone_description/meshes/camera.STL" />
      </geometry>
      <material name="">
        <color rgba="0.69804 0.69804 0.69804 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://drone_description/meshes/camera.STL" />
      </geometry>
    </collision>
  </link>

  <!-- DUMMY JOINT -->
  <joint name="dummy" type="fixed">
    <parent link="dummy_link" />
    <child link="base_link" />
  </joint>

  <!-- JOINT -->
  <joint name="camera_joint" type="revolute">
    <origin xyz="0.00925 0.059965 0.0165" rpy="${PI/2} 0 -${PI/2}" />
    <parent link="base_link" />
    <child link="camera" />
    <axis xyz="0 0 1" />
    <limit lower="0" upper="${PI/3}" effort="100" velocity="1" />
  </joint>

  <transmission name="camera_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="camera_joint">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="camera_motor">
      <mechanicalReduction>1</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <xacro:prop_link name="front_left_prop" />
  <xacro:prop_link name="front_right_prop" />
  <xacro:prop_link name="back_left_prop" />
  <xacro:prop_link name="back_right_prop" />

  <xacro:prop_joint name="front_left_prop" originxyz="-0.092959 0.073449 0.0385" axis="0 0 1"/>
  <xacro:prop_joint name="front_right_prop" originxyz="0.092959 0.073449 0.0385" axis="0 0 -1"/>
  <xacro:prop_joint name="back_left_prop" originxyz="-0.093338 -0.10988 0.0385" axis="0 0 -1"/>
  <xacro:prop_joint name="back_right_prop" originxyz="0.093338 -0.10988 0.0385" axis="0 0 1"/>
  
  <xacro:prop_transmission name="front_left_prop" />
  <xacro:prop_transmission name="front_right_prop" />
  <xacro:prop_transmission name="back_left_prop" />
  <xacro:prop_transmission name="back_right_prop" />

  <xacro:propeller_plugin name="front_left_prop" dir="-1" />
  <xacro:propeller_plugin name="front_right_prop" dir="1" />
  <xacro:propeller_plugin name="back_left_prop" dir="1" />
  <xacro:propeller_plugin name="back_right_prop" dir="-1" />
</robot>

drone_macros.xacro

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:macro name="prop_link" params="name">
    <link name="${name}">
      <inertial>
        <origin xyz="0 0 0.0089339" rpy="0 0 0" />
        <mass value="0.06804" />
        <inertia ixx="5.4455E-05" ixy="2.3822E-05" ixz="0" iyy="1.2182E-05" iyz="0" izz="6.5653E-05" />
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://drone_description/meshes/propeller.STL" />
        </geometry>
        <material name="">
          <color rgba="0.69804 0.69804 0.69804 1" />
        </material>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://drone_description/meshes/propeller.STL" />
        </geometry>
      </collision>
    </link>
  </xacro:macro>

  <xacro:macro name="prop_joint" params="name originxyz axis">
    <joint name="${name}_joint" type="continuous">
      <origin xyz="${originxyz}" rpy="0 0 0" />
      <parent link="base_link" />
      <child link="${name}" />
      <axis xyz="${axis}" />
    </joint>
  </xacro:macro>

  <xacro:macro name="prop_transmission" params="name">
    <transmission name="${name}_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <joint name="${name}_joint">
        <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
      </joint>
      <actuator name="${name}_motor">
        <mechanicalReduction>1</mechanicalReduction>
        <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
      </actuator>
    </transmission>
  </xacro:macro>    
</robot>

drone_gazebo.xacro

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <!-- ROS CONTROL -->
  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/</robotNamespace>
    </plugin>
  </gazebo>

  <!-- LIFT DRAG -->
  <xacro:macro name="propeller_plugin" params="name dir">
    <gazebo>
      <plugin name="${name}_lift" filename="libLiftDragPlugin.so">
        <a0>0.0872665</a0>
        <cla>0.07365687650517104</cla>
        <cda>0.0</cda>
        <cma>0.0</cma>
        <alpha_stall>1.22173</alpha_stall>
        <cla_stall>-0.2</cla_stall>
        <cda_stall>1.0</cda_stall>
        <cma_stall>0.0</cma_stall>
        <cp>0 0.14 0</cp>
        <area>0.1</area>
        <air_density>1.2041</air_density>
        <forward>1 0 0</forward>
        <upward>0 0 ${dir}</upward>
        <link_name>${name}</link_name>
        <control_joint>${name}_joint</control_joint>
      </plugin>
    </gazebo>
  </xacro:macro>
</robot>

gazebo.launch

<launch>
  <include file="$(find gazebo_ros)/launch/empty_world.launch" />

  <!-- Load URDF to parameter server -->
  <param name="robot_description" command="$(find xacro)/xacro $(find drone_description)/urdf/drone_base.xacro" />

  <!-- Spawn model in Gazebo -->
  <node name="spawn_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -model drone_description -param robot_description" output="screen" />

  <rosparam file="$(find drone_description)/config/control.yaml" command="load" />

  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/" args="joint_motor_controller camera_joint_position_controller" />

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen" />

</launch>

The full package is in a repository here: https://github.com/djangbahevans/ROS-Drone


Originally posted by djangbahevans on ROS Answers with karma: 23 on 2021-02-24

Post score: 1


Original comments

Comment by turtleMaster20 on 2021-02-24:
Can you also post the error messages? Specifically which links are missing.

Comment by djangbahevans on 2021-02-24:
For the dummy_link and base_link, Rviz determines the transforms properly, but for all other links, it says "No transform from [{child_link}] to [base_link]".

Comment by turtleMaster20 on 2021-02-24:
I am guessing the links are not 'jointed' to the dummy link. Try this:

<joint name="dummy" type="fixed"> <parent link="base_link" /> <child link="{child_link}" /> </joint>

Note: In this example it is assumed that the [base_link] and [{child_link}] the same origin, if they have a displacement (or if the relation is not fixed) then change accordingly.

Comment by djangbahevans on 2021-02-24:
There already are joints joining all the other links to the base_link, and they display and work fine in Gazebo. The problem is Rviz visualization isn't working because nothing is publishing on the /joint_states topic.

Comment by turtleMaster20 on 2021-02-24:
Any reason you are not feeding joint_state_controller argument into the the controller_spawner? Can you check once with this argument?

Comment by djangbahevans on 2021-02-24:
That was the mistake. Thanks @turtleMaster20

Comment by turtleMaster20 on 2021-02-25:
Can you tick mark the answer I have posted? Cheers!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

joint_state_controller argument is not included when the controller_spawner is started.


Originally posted by turtleMaster20 with karma: 41 on 2021-02-25

This answer was 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.