0
$\begingroup$

Rosanswers logo

Hi,I am new in ROS....and forget my broken english.

Now I am build a robot via Urdf,but when I done all the process,open rviz, and the joint who isn't fixed was run in error:

No transform from [left_wheel] to [base_link]
No transform from [right_wheel] to [base_link]
No transform from [stable_wheel] to [base_link]

The node that I have:

robot_state_publisher (robot_state_publisher/state_publisher)
rviz (rviz/rviz)
state_publisher (r2d2/state_publisher)

and the topic that I have:

/clicked_point
/initialpose
/joint_states
/move_base_simple/goal
/rosout
/rosout_agg
/tf
/tf_static

The robot I build is 3 wheel,1 wheel use for stable and 2 wheel is use for differential drive.

Here are the Urdf.Xacro and launch file.

<?xml version="1.0"?>
<robot name="test" xmlns:xacro="http://www.ros.org/wiki/xacro">
 <!--Constants for robot dimensions
 <xacro:property name=(value_name) value=(value)/>-->


 <!--Import all customization elements
 <xacro:include filename="$PATH_OF_FILE">-->
 <xacro:include filename="property.urdf.xacro"/>
 <xacro:include filename="model.gazebo.xacro"/>
<!--###############################Main Body########################-->

 <link name="base_link">
 <!--Visual tag is create a visual look out for model-->
  <visual>
   <geometry>
    <cylinder length="${bodylen}" radius="${bodyrad}"/>
   </geometry>
   <material name="white"/>
  </visual>
  
<!--collision tag is create a actual look out for model in gazebo-->
  <collision>
   <geometry>
    <cylinder length="${bodylen}" radius="${bodyrad}"/>
   </geometry>
  </collision>

<!--inertial tag is create a inertial of model-->

 </link>

<!--################################Stable Wheel####################-->
 <link name="stable_wheel">
  <visual>
   <geometry>
    <sphere radius="${sphereR}"/>
   </geometry>
   <material name="blue"/>
  </visual>

  <collision>
   <geometry>
    <sphere radius="${sphereR}"/>
   </geometry>
  </collision>

 </link>
 <joint name="base_to_stable" type="continuous">
  <parent link="base_link"/>
  <child link="stable_wheel"/>
  <axis xyz ="1 1 1"/>
  <origin xyz="-.15 0 -.15"/>
 </joint>

<!--############################Left Wheel##########################-->
 <link name="left_wheel">
  <visual>
   <geometry>
    <cylinder length="${wheelL}" radius="${wheelR}"/>
   </geometry>
   <origin rpy="${straight}"/>
   <material name="black"/>
  </visual>

  <collision>
   <geometry>
    <cylinder length="${wheelL}" radius="${wheelR}"/>
   </geometry>
   <origin ryp="${straight}"/>
  </collision>

 </link>

 <joint name="base_to_left_wheel" type="continuous">
  <parent link="base_link"/>
  <child link="left_wheel"/>
  <axis xyz="0 1 0"/>
  <origin xyz="0.1 -0.25 -0.15"/>
 </joint>

 <!--#############################Right Wheel#######################-->

 <link name="right_wheel">
  <visual>
   <geometry>
    <cylinder length="${wheelL}" radius="${wheelR}"/>
   </geometry>
   <origin rpy="${straight}"/>
   <material name="black"/>
  </visual>

  <collision>
   <geometry>
    <cylinder length="${wheelL}" radius="${wheelR}"/>
   </geometry>
   <origin rpy="${straight}"/>
  </collision>

 </link>
  <joint name="base_to_right_wheel" type="continuous">
   <parent link="base_link"/>
   <child link="right_wheel"/>
   <axis xyz="0 1 0"/>
   <origin xyz="0.1 0.25 -0.15"/>
  </joint>
</robot>

and here are the launch file:

<launch>
    <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find r2d2)/urdf/model.urdf.xacro'"/>
    <param name="robot_description" command="$(arg urdf_file)" />
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="state_publisher" pkg="r2d2" type="state_publisher" />
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.rviz" required="true" />
    </launch>

here are the state_publisher:

    #include <string>
    #include <ros/ros.h>
    #include <sensor_msgs/JointState.h>
    #include <tf/transform_broadcaster.h>
    
    int main(int argc, char** argv) {
        ros::init(argc, argv, "state_publisher");
        ros::NodeHandle n;
        ros::Publisher joint_pub = n.advertise<sensor_msgs::JointState>("joint_states", 1);
       tf::TransformBroadcaster broadcaster;
       ros::Rate loop_rate(30);
   
       const double degree = M_PI/180;
   
       // robot state
       double tilt = 0, tinc = degree, swivel=0, angle=0, height=0, hinc=0.005;
   
       // message declarations
       geometryI made a listener that uses the function lookuptransform to_msgs::TransformStamped odom_trans;
       sensor_msgs::JointState joint_state;
       odom_trans.header.frame_id = "odom";
       odom_trans.child_frame_id = "axis";
   
       while (ros::ok()) {
           //update joint_state
           joint_state.header.stamp = ros::Time::now();
           joint_state.name.resize(3);
           joint_state.position.resize(3);
           joint_state.name[0] ="swivel";
           joint_state.position[0] = swivel;
           joint_state.name[1] ="tilt";
           joint_state.position[1] = tilt;
           joint_state.name[2] ="periscope";
           joint_state.position[2] = height;
   
   
           // update transform
           // (moving in a circle with radius=2)
           odom_trans.header.stamp = ros::Time::now();
           odom_trans.transform.translation.x = cos(angle)*2;
           odom_trans.transform.translation.y = sin(angle)*2;
           odom_trans.transform.translation.z = .7;
           odom_trans.transform.rotation = tf::createQuaternionMsgFromYaw(angle+M_PI/2);
   
           //send the joint state and transform
           joint_pub.publish(joint_state);
           broadcaster.sendTransform(odom_trans);
   
           // Create new robot state
           tilt += tinc;
           if (tilt<-.5 || tilt>0) tinc *= -1;
           height += hinc;
           if (height>.2 || height<0) hinc *= -1;
           swivel += degree;
           angle += degree/4;
   
           // This will adjust as needed per iteration
           loop_rate.sleep();
       }
   
   
       return 0;
   }

this code is copy from This tutorial.


Originally posted by Xyden on ROS Answers with karma: 3 on 2016-05-18

Post score: 0


Original comments

Comment by mgruhler on 2016-05-18:
If you have a question about a URDF... Why not post the URDF in question? as well as the launch file/commands you use to run it...

Comment by Xyden on 2016-05-18:
you mean post mine urdf file?ok i will attach later

Comment by mgruhler on 2016-05-19:
You do have continuous joints specified for your wheels. So you need some node to publish the respective joint_states. I guess this is the state_publisher in the package r2d2. Is this on GitHub? This will simplify debugging. If not, poste the respective parts of this file, please.

Comment by Xyden on 2016-05-19:
The code is now include,the state_publisher is a CPP code.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You have the three following joints: base_to_right_wheel, base_to_left_wheel and base_to_stable.

In the code you posted, you publish joint_states for: swivel, tilt and periscope.

This does obviously not match. You need to publish the joint_states for the (non-fixed) joints that you define in your URDF...


Originally posted by mgruhler with karma: 12390 on 2016-05-19

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Xyden on 2016-05-19:
so...is that mean i need to change the swivel/tilt/periscope into the joint that I define???

Comment by mgruhler on 2016-05-19:
yes, the joint_state.name[i] field is used to find out which joint is driven by the position in joint_state.position[i].

Comment by Xyden on 2016-05-19:
Ok!Thanks you! But still can't fix my problem,is that more anything to change? I already change the name to the joint name,and how to do later??

$\endgroup$

Your Answer

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