Having a hard time reading *.urdf and *.rob file in Klampt - ros

Hopefully, somebody used Klampt before here, but I am not able to read. So this question is merely about what am I missing in the urdf file, it seems correct, and this is straight from an example in a e-book that used Klampt for modeling and simulation of robots
from __future__ import print_function,division
from klampt import *
import math
import os
world = WorldModel()
fileurdf = r"planar2R.urdf"
path = os.path.join(r"data",fileurdf)
res = world.readFile(path)
assert res, "There was an error loading data/planar2R.urdf"
the urdf file is well formated
<robot name="test_robot">
<link name="base_link">
</link>
<link name="link1">
</link>
<link name="link2">
</link>
<link name="link3">
</link>
<link name="end_effector">
</link>
<joint name="joint1" type="revolute">
<parent link="base_link"/>
<child link="link1"/>
</joint>
<joint name="joint2" type="revolute">
<origin xyz="1 0 0" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<parent link="link1"/>
<child link="link2"/>
</joint>
<joint name="joint3" type="revolute">
<parent link="link2"/>
<child link="link3"/>
</joint>
<joint name="joint4" type="fixed">
<parent link="link3"/>
<child link="end_effector"/>
</joint>
</robot>
I get a failure of parsing the file

There could be many reasons for which you'll get "unable to load urdf" error.
Reason 1: File address specified is not correct/readable.
Reason 2: urdf file itself has an error. keep in mind that it is possible to load urdf file in one urdf simulator without any error, but same file may cause an error in klampt.
I faced this problem for quite some time and had to debug it by trying and writing my whole urdf file, learning from example urdf.
Try 1: First make sure the file address is not making any issue.
Try 2: Start with an given example. Make small changes in the urdf file and debug simultaneously.
Try 3: about urdf specifically for klampt, it need last <klampt> </klampt> data. unless it is properly given, compiling will give "unable to load urdf" error.
<klampt> </klampt> data could be given something like this:
<klampt world_frame="world" defaultAccMax="4" use_vis_geom="1">
<noselfcollision group1="" group2="" />
<link name="world" />
<link name="base_link" />
<link name="link_1" servoP="1400" servoI="0" servoD="6" dryFriction="0.5" viscousFriction="8" />
<link name="link_2" servoP="1400" servoI="0" servoD="6" dryFriction="0.5" viscousFriction="8" />
<link name="fcp" />
</klampt>
</robot>
One thing that I don't like about this klampt package is that they don't specify the reason for failure to load urdf file and thus make it difficult to understand for beginner.

Related

ROS URDF: redefining global symbol: pi when processing file

While running xacro on a ros urdf.xacro file, had an error "redefining global symbol: pi".
The steps to reproduce are below.
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- transmission -->
<xacro:include filename="$(find tm_grasp_description)/urdf/tm.transmission.xacro" />
<!-- Mass parameters -->
<xacro:property name="pi" value="3.14159265" />
<xacro:macro name="tm700_robot" params="prefix joint_limited">
<!-- transmission prefix -->
<xacro:tm_arm_transmission prefix="${prefix}" />
<joint name="${prefix}shoulder_1_joint" type="revolute">
<parent link="${prefix}base_link" />
<child link = "${prefix}shoulder_1_link" />
<origin xyz="0.0 0.0 ${shoulder_height}" rpy="${-0.5 * pi} 0.0 0.0" />
<axis xyz="0 -1 0" />
<xacro:unless value="${joint_limited}">
<limit lower="${-2.0 * pi}" upper="${2.0 * pi}" effort="150.0" velocity="3.15"/>
</xacro:unless>
<xacro:if value="${joint_limited}">
<limit lower="${-pi}" upper="${pi}" effort="150.0" velocity="3.15"/>
</xacro:if>
<dynamics damping="0.0" friction="0.0"/>
</joint>
...
</xacro:macro>
</robot>
i was trying to add the robot to the xacro file
<?xml version="1.0" ?>
<robot name="hrwros" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- world -->
<link name="world" />
<!-- workcell -->
<xacro:include filename="$(find hrwros_support)/urdf/workcell/workcell.urdf.xacro"/>
<xacro:workcell_urdf workcell_parent="world_interface"/>
<!-- Robot1 Pedestal -->
<xacro:include filename="$(find hrwros_support)/urdf/robot_pedestal/robot_pedestal.urdf.xacro"/>
<xacro:robot_pedestal_urdf pedestal_prefix="robot1_" pedestal_parent="world_interface" pedestal_height="0.95">
<origin xyz="0.5 1.8 0.0" rpy="0 0 0"/>
</xacro:robot_pedestal_urdf>
<!-- Robot1 -->
<xacro:include filename="$(find tm_grasp_description)/urdf/tm700.urdf.xacro"/>
<xacro:tm700_robot prefix="robot1_" joint_limited="true"/>
<!-- bins -->
<xacro:include filename="$(find hrwros_support)/urdf/bin/bin.urdf.xacro"/>
<xacro:bin_urdf prefix="bin_1_"/>
<!-- logical camera 1 collision model -->
<xacro:include filename="$(find hrwros_support)/urdf/logical_camera/logical_camera.urdf.xacro"/>
<xacro:logical_camera_urdf prefix="logical_camera1_" logical_camera_parent="world_interface">
<origin xyz="1.2 1.8 2.0" rpy="0 1.5708 0"/>
</xacro:logical_camera_urdf>
<!-- logical camera 2 collision model -->
<xacro:include filename="$(find hrwros_support)/urdf/logical_camera/logical_camera.urdf.xacro"/>
<xacro:logical_camera_urdf prefix="logical_camera2_" logical_camera_parent="world_interface">
<origin xyz="-8.3 -1.23 1.8" rpy="0 1.5708 0"/>
</xacro:logical_camera_urdf>
<!-- break beam -->
<xacro:include filename="$(find hrwros_support)/urdf/break_beam/break_beam.urdf.xacro"/>
<xacro:break_beam_urdf prefix="break_beam_"/>
but when I try to run
rosrun xacro xacro --inorder hrwros.xacro > hrwros.urdf
it shows the following error saying the redefine the symbol pi. And the robot I am trying to add is techman robot.
xacro: in-order processing became default in ROS Melodic. You can drop the option.
redefining global symbol: pi
when processing file: /home/akash/project/src/techman_robot_ros-master/tm_grasp_description/urdf/tm700.urdf.xacro
included from: hrwros.xacro
So when you have the same xacro property defined at global scope, having another with the same name redefines it.
Looking at the error report, you have it defined first in the top file, and possibly elsewhere. In math operations, pi is defined already, since the math operations use python and pi is defined there.
If you delete your global pi definition, it should now work.

Why is RVIZ telling me that there is "No transfrom from [velodyne] to [base_link]" even though I have such a joint defined in my URDF?

RVIZ is telling me that there is "No transfrom from [velodyne] to [base_link]". I have a joint between these two objects defined in my URDF file:
<robot name="jackal">
<material name="orange">
<color rgba="1.0 0.5 0.2 1" />
</material>
<material name="gray">
<color rgba="0.2 0.2 0.2 1" />
</material>
<link name="velodyne">
<visual>
<origin xyz="0.0 0.0 0.0" />
<geometry>
<cylinder length="0.07" radius="0.05" />
</geometry>
<material name="gray" />
</visual>
</link>
<link name="base_link" />
<joint name="velodyne_to_base" type="fixed">
<parent link="base_link" />
<child link="velodyne" />
<origin xyz="0.0 0.0 0.0" />
</joint>
</robot>
Why am I getting this error even though I am defining such a joint?
You will need to launch a robot_state_publisher node that publishes the tf transforms between your different links in any case - even if your links are connected with fixed joints only. Therefore either add
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
to your launch file or open another terminal, source the current workspace and run the corresponding node
rosrun robot_state_publisher robot_state_publisher
This was caused by inconsistencies between the "frame_id" property of the Velodyne launch file and the names used in the URDF file. The link name in the urdf file must match the frame ID of the corresponding sensor.

roblem with ROS control and Gazebo

I have a problem with controlling a URDF that I exported from SolidWorks. (Ubuntu 16.04 , Kinetic, Gazebo 7.x) I followed this tutorial and I wanted to implemented on my robot. All the controllers are starting correctly so as the Gazebo simulation also the Node publish the data correctly I have checked it with echo-ing the topic and with different values for the data. Is there a chance not working because the PID values ?
All the transmissions look like this :
<transmission name="tran1">
<type>transmission_interface/SimpleTransmission</type>
<joint name="Joint_1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
The controller is like this (for all joints) :
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
joint1_position_controller:
type: effort_controllers/JointPositionController
joint: Joint_1
pid: {p: 100.0, i: 0.01, d: 10.0}
And I have this node:
rospy.init_node('ArmMovement')
pub1=rospy.Publisher("/rrbot/joint1_position_controller/command",Float64,queue_size=10 )
rate = rospy.Rate(50)
ArmCor1= Float64()
ArmCor1.data=0
while not rospy.is_shutdown():
pub1.publish(ArmCor1)
rate.sleep()
Part of URDF for the Joint_1:
<joint name="Joint_1" type="revolute">
<origin
xyz="0 0 -0.008"
rpy="1.5708 0 0" />
<parent link="base_link" />
<child link="Link_1" />
<axis
xyz="0 1 0" />
<limit
lower="0"
upper="3.14"
effort="0"
velocity="0" />
</joint>
Thank you guys for your help, it actually work after your comments.
This was my Joint_1 :
<joint name="Joint_1" type="revolute">
<origin
xyz="0 0 -0.008"
rpy="1.5708 0 0" />
<parent link="base_link" />
<child link="Link_1" />
<axis
xyz="0 1 0" />
<limit
lower="0"
upper="3.14"
effort="0"
velocity="0" />
</joint>
I changed the limit section to this :
<limit
lower="0"
upper="3.14"
effort="2"
velocity="2.0" />
I have other problems like a very annoying shiver (that comes from effort value I think) but It is not for this topic.

Loading .xacro into .xacro does not have a visible effect

I'm searching for an answer to why I can not see my second .xacro file that I'm including in my first one. - Here's my MWE:
I'm succefully loading a .xacro file and seeing it in Rviz by launching following launch file:
<launch>
<param name="robot_description" textfile="$(find my_package)/urdf/test.urdf.xacro" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
<node pkg="rviz" type="rviz" name="rviz" />
</launch>
My test.urdf.xacro file has following content:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="test">
<xacro:include filename="$(find my_package)/urdf/glass.urdf.xacro" />
<link name="base_link">
<visual>
<origin xyz="0 0 1" rpy="0 0 0" />
<geometry>
<box size="0.1 0.1 1" />
</geometry>
<material name="blue1">
<color rgba="0.28 0.52 0.93 1" />
</material>
</visual>
</link>
</robot>
My second .xacro file "glass.urdf.xacro" has following content:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="test2">
<link name="base_link2">
<visual>
<origin xyz="0 1 0" rpy="0 0 0" />
<geometry>
<box size="0.1 0.1 1" />
</geometry>
<material name="blue2">
<color rgba="0.28 0.1 0.93 1" />
</material>
</visual>
</link>
</robot>
The two files work seperatly but the xacro:include doesn't seem to be doing anything...Any ideas what I should do to use it succesfully?
How can I check what my resulting urdf file looks like?
Figured this out. You need to use xacro to parse the robot_description in the launch file. Like this:
<param name="robot_description" command="xacro '$(find my_package)/urdf/test.urdf.xacro"' />
Otherwise, xacro isn't used to parse your test.urdf.xacro file and the included files are not processed.

IOS X Safari favorites icons giving 404 errors

My icons are showing on all other browsers except IOS 10 with Safari when adding to bookmarks/favourites, cannot figure out what is missing or out of place and no help on the forums or documentation. Could someone perhaps tell me the default path used by Safari in IOS 10 to add icons to favorites?
This is my code:
<link rel="apple-touch-icon-precomposed" href="http://www.mainboard.com/apple-touch-icon-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="http://www.mainboard.com/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="http://www.mainboard.com/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://www.mainboard.com/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="http://www.mainboard.com/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://www.mainboard.com/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="http://www.mainboard.com/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://www.mainboard.com/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="http://www.mainboard.com/apple-touch-icon-152x152.png" />
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="http://www.mainboard.com/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="http://www.mainboard.com/favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="http://www.mainboard.com/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="http://www.mainboard.com/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/png" href="http://www.mainboard.com/favicon-128.png" sizes="128x128" />
<link rel="icon" type="image/png" href="http://www.mainboard.com/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="http://www.mainboard.com/favicon-196x196.png" sizes="196x196" />
<meta name="application-name" content="MAINBOARD"/>
<meta name="msapplication-TileImage" content="http://www.mainboard.com/mstile-144x144.png" />
<meta name="msapplication-square70x70logo" content="http://www.mainboard.com/mstile-70x70.png" />
<meta name="msapplication-square150x150logo" content="http://www.mainboard.com/mstile-150x150.png" />
<meta name="msapplication-wide310x150logo" content="http://www.mainboard.comm/stile-310x150.png" />
<meta name="msapplication-square310x310logo" content="http://www.mainboard.com/mstile-310x310.png" />
<link rel="manifest" href="http://www.mainboard.com/manifest.json">
<link rel="mask-icon" href="http://www.mainboard.com/safari-pinned-tab.svg" color="#fff">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="http://www.mainboard.com/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
I suggest you to submit your site to the favicon checker. If will check your markups and icons. At the time of writing this answer, it is full green. So you can be nearly sure that everything is alright. Full disclosure: I'm the author of this service.
Keep in mind that browsers tend to be very lazy regarding favicon. For example, favicon caching is a recurrent web development issue. In the case of iOS Safari, I often observed that Safari does not always load the icon on time while bookmarking. Consequence: while testing your touch icon, you have the feeling that it does not work. It actually works, but you have to try again a minute later. Frustrating. Another possible issue is that, as the site author, you are constantly visiting your site under development. Maybe Safari considers your touch icon is broken (maybe it was at some point: this is a site under dev after all) so it does not reload it, but will eventually do it... later.
My advice here is to try with another iOS device if you have one at your disposal.

Resources