Ask Your Question
0

Using Urdf build a robot in rviz.

asked 2016-05-18 04:21:12 -0500

Xyden gravatar image

updated 2016-10-24 09:08:29 -0500

ngrennan gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

Comments

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

mgruhler gravatar imagemgruhler ( 2016-05-18 04:28:42 -0500 )edit

you mean post mine urdf file?ok i will attach later

Xyden gravatar imageXyden ( 2016-05-18 05:49:56 -0500 )edit

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.

mgruhler gravatar imagemgruhler ( 2016-05-19 01:06:43 -0500 )edit

The code is now include,the state_publisher is a CPP code.

Xyden gravatar imageXyden ( 2016-05-19 01:54:42 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-05-19 02:11:00 -0500

mgruhler gravatar image

updated 2016-05-19 02:11:25 -0500

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

edit flag offensive delete link more

Comments

so...is that mean i need to change the swivel/tilt/periscope into the joint that I define???

Xyden gravatar imageXyden ( 2016-05-19 02:38:03 -0500 )edit

yes, the joint_state.name[i] field is used to find out which joint is driven by the position in joint_state.position[i].

mgruhler gravatar imagemgruhler ( 2016-05-19 03:05:16 -0500 )edit

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??

Xyden gravatar imageXyden ( 2016-05-19 03:15:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-05-18 04:21:12 -0500

Seen: 660 times

Last updated: May 19 '16