Minimum requirement to view urdf in RViz?
Hi, I am learning build 3D model with urdf. I am following the book "Mastering ROS for robotics programming". I am confused since all of tutorials relating to urdf, I found online, require to start with a built package. I would like to know if I have a good urdf file, what is the minimum requirement to view this file in RViz? I did the steps below: I started with creating a package folder
$catkin_create_pkg mastering_ros_robot_description_pkg roscpp tf geometry_msgs urdf rviz xacro
I created a sub-folder name urdf and created this pan_tilt.urdf file:
<?xml version="1.0"?>
<robot name="pan_tilt">
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.01" radius="0.2"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="pan_joint" type="revolute">
<parent link="base_link"/>
<child link="pan_link"/>
<origin xyz="0 0 0.1"/>
<axis xyz="0 0 1" />
<limit effort="300" velocity="0.1" lower="-3.14" upper="3.14"/>
</joint>
<link name="pan_link">
<visual>
<geometry>
<cylinder length="0.4" radius="0.04"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0.09"/>
<material name="red">
<color rgba="0 0 1 1"/>
</material>
</visual>
</link>
<joint name="tilt_joint" type="revolute">
<parent link="pan_link"/>
<child link="tilt_link"/>
<origin xyz="0 0 0.2"/>
<axis xyz="0 1 0" />
<limit effort="300" velocity="0.1" lower="-4.64" upper="-1.5"/>
</joint>
<link name="tilt_link">
<visual>
<geometry>
<cylinder length="0.4" radius="0.04"/>
</geometry>
<origin rpy="0 1.5 0" xyz="0 0 0"/>
<material name="green">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
</robot>
I checked that the urdf file does not contain any error:
ubuntu@tegra-ubuntu:~/Documents/WorkSpaceMasteringRosRobot/mastering_ros_robot_d
escription_pkg/urdf$ check_urdf pan_tilt.urdf
robot name is: pan_tilt
---------- Successfully Parsed XML ---------------
root Link: base_link has 1 child(ren)
child(1): pan_link
child(1): tilt_link
I created another folder same level with urdf folder name launch. I created view_demo.launch file
<launch>
<arg name="model" />
<param name="robot_description" textfile="$(find mastering_ros_robot_description_pkg)/urdf/pan_tilt.urdf" />
<param name="use_gui" value="true"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mastering_ros_robot_description_pkg)/urdf.rviz" required="true" />
</launch>
From package folder, I ran this launch file and I got below error:
ubuntu@tegra-ubuntu:~/Documents/WorkSpaceMasteringRosRobot/mastering_ros_robot_d
escription_pkg$ roslaunch mastering_ros_robot_description_pkg view_demo.launch
[view_demo.launch] is neither a launch file in package [mastering_ros_robot_description_pkg] nor is [mastering_ros_robot_description_pkg] a launch file name
The traceback for the exception was written to the log file
Please tell me what I am missing and how to solve the problem. Thank you for your time reading and answering my question.
Regards, Thang Nguyen
Edit 1: Sorry, the code format does not work with my edit.
Thanks for your help I ran catkin_make to compile the package then I try to ran the view_demo.launch file again. I got an error with rviz. I am not ...
Did you build the package after creating it? Also have you checked the
$ROS_PACKAGE_PATH
?I have not done this yet. Thank you for reminding me.