0
$\begingroup$

Rosanswers logo

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 sure what it is. Below is the message when I ran launch file.

  1. My question is I cannot find the .ros folder in ubuntu folder. How to access this log file?
  2. What is the error about?
  3. What is urdf.rviz file? I saw this file in the book code but I would like how to create this file as well as urdf.vcg. Does these files required by rviz?

Console:

ubuntu@tegra-ubuntu:~/Documents/WorkSpaceMasteringRosRobot$ roslaunch mastering_ros_robot_description_pkg view_demo.launch
... logging to /home/ubuntu/.ros/log/525e4ccc-7966-11e6-b943-00044b581868/roslaunch-tegra-ubuntu-1614.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://tegra-ubuntu:48702/

SUMMARY
========

PARAMETERS
 * /robot_description: <?xml version="1....
 * /rosdistro: indigo
 * /rosversion: 1.11.19
 * /use_gui: True

NODES
  /
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/state_publisher)
    rviz (rviz/rviz)

auto-starting new master
process[master]: started with pid [1625]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 525e4ccc-7966-11e6-b943-00044b581868
process[rosout-1]: started with pid [1638]
started core service [/rosout]
process[joint_state_publisher-2]: started with pid [1641]
process[robot_state_publisher-3]: started with pid [1647]
process[rviz-4]: started with pid [1654]
================================================================================REQUIRED process [rviz-4] has died!
process has died [pid 1654, exit code -7, cmd /opt/ros/indigo/lib/rviz/rviz -d /home/ubuntu/Documents/WorkSpaceMasteringRosRobot/src/mastering_ros_robot_description_pkg/urdf.rviz __name:=rviz __log:=/home/ubuntu/.ros/log/525e4ccc-7966-11e6-b943-00044b581868/rviz-4.log].
log file: /home/ubuntu/.ros/log/525e4ccc-7966-11e6-b943-00044b581868/rviz-4*.log
Initiating shutdown!
================================================================================
[rviz-4] killing on exit
[robot_state_publisher-3] killing on exit
[joint_state_publisher-2] killing on exit
[joint_state_publisher-2] escalating to SIGTERM
[joint_state_publisher-2] escalating to SIGKILL
[rosout-1] killing on exit
[master] killing on exit
Shutdown errors:
 * process[joint_state_publisher-2, pid 1641]: required SIGKILL. May still be running.
shutting down processing monitor...
... shutting down processing monitor complete
done

Edit 2: Error when run launch file directly from launch folder Screenshot launch file.png


Originally posted by Thang Nguyen on ROS Answers with karma: 93 on 2016-09-12

Post score: 1


Original comments

Comment by bhavyadoshi26 on 2016-09-12:
Did you build the package after creating it? Also have you checked the $ROS_PACKAGE_PATH ?

Comment by Thang Nguyen on 2016-09-12:
I have not done this yet. Thank you for reminding me.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You can go to the directory where view_demo.launch belongs and run roslaunch view_demo.launch directly.

If you want to run roslaunch mastering_ros_robot_description_pkg view_demo.launch, you need to do catkin_make first.


Your edit1 is confusing, I don't know what is going on, but let me answer your 3rd question.

.rviz and .vcg file are both RViz configuration file, but since ROS Groovy the configuration file format has changed, from .vcg to .rviz. For detail, you can see RViz User Guide - configurations.


To display the robot URDF, you need to add a RobotModel in RViz. Like this: image description


urdf.rviz is just a configuration file for your RViz, when you open the RViz with urdf.rviz, and add or remove some items in the Displays, and save config, then your urdf.rviz will be modified. Next time you open RViz with urdf.rviz, the configuration will be same as what you had saved.


Originally posted by Shay with karma: 763 on 2016-09-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2016-09-12:
Note that your first option will only work if view_demo.launch does not refer to any resources in mastering_ros_robot_description_pkg, or if mastering_ros_robot_description_pkg is on the package path. But to get it there, you might as well catkin_make the workspace.

Comment by Thang Nguyen on 2016-09-12:
Thank you for helping me. I will try this tonight and confirm it.

Comment by Shay on 2016-09-12:
@gvdhoorn you are right.

Comment by Thang Nguyen on 2016-09-13:
I do catkin_make but I still cannot run rviz. I updated my question to include more detail information.

Comment by Thang Nguyen on 2016-09-13:
In edit 1, the error is below ==== line. I can manage to run the rviz tool independently with launch file but I don't know how to load the urdf from inside rviz. Should I suppose to use the urdf.rviz in this case? but how these file is created from my urdf file?

Comment by Thang Nguyen on 2016-09-13:
What I tried so far is remove the last line of my launch file which is the line to run rviz. I then run rviz manually. After rviz is launched, I select to load the urdf.rviz file from menu toolbar. With this sequence of steps, I can control the model manually with slide bar.

Comment by Thang Nguyen on 2016-09-14:
I ran catkin make but it still return same error. If I ran launch file directly from launch folder, I also got an error

Comment by Thang Nguyen on 2016-09-14:
At this point, I believe it's a hardware related issue.

Comment by AloshkaD on 2016-09-19:
It's not a hardware issue Thang, I have the same problem and I'm stuck for dayson this.

$\endgroup$
0
$\begingroup$

Rosanswers logo

There is a problem with this book and particularly in Chapter 2 & 3. Here is the solution for that. From the tutorials, I believe you have the soft codes of this book, there will be file in the main pkg file named urdf.rviz and urdf.vcg. Copy these files into your created package file. After that, try what you are doing currently and let me know the problem if it occurs. In case, if you don't have codes for the tutorials download it from here (Link). Best of luck.


Originally posted by Abdul Mannan with karma: 167 on 2016-09-12

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Thang Nguyen on 2016-09-12:
Thanks Dr Abdul Mannan. I would like to understand what actually is happening. I believe since I have not built the package so ROS don't understand my files.

Comment by Thang Nguyen on 2016-09-13:
@Dr Abdul Mannan: I understand more about your answer now. I include these two files in the package folder but it still not run.

Comment by Abdul Mannan on 2016-10-16:
Oh, I just read it. I guess, problem is already solved.

$\endgroup$

Your Answer

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