Using Urdf build a robot in rviz.
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 ...
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...
you mean post mine urdf file?ok i will attach later
You do have
continuous
joints specified for your wheels. So you need some node to publish the respectivejoint_states
. I guess this is thestate_publisher
in the packager2d2
. Is this on GitHub? This will simplify debugging. If not, poste the respective parts of this file, please.The code is now include,the state_publisher is a CPP code.