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.
Related
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.
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.
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.
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.
I am trying to develop a gadget that will ultimately incorporate ChartJS, but I am having issues with the default gadget, as it does not load.
The code I am putting into the attlassian-plugin.xml is the following:
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="report"/>
<!-- add our web resources -->
<web-resource key="report-resources" name="report Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="report.css" location="/css/report.css"/>
<resource type="download" name="report.js" location="/js/report.js"/>
<resource type="download" name="images/" location="/images"/>
<context>report</context>
</web-resource>
<!-- publish our component -->
<component key="myPluginComponent" class="com.wfs.report.MyPluginComponentImpl" public="true">
<interface>com.wfs.report.MyPluginComponent</interface>
</component>
<!-- import from the product container -->
<component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" />
<webwork1 key="demoaction" name="JTricks Demo Action" class="java.lang.Object">
<actions>
<action name="com.wfs.report.DemoAction" alias="DemoAction">
<view name="input">/templates/input.vm</view>
<view name="success">/templates/joy.vm</view>
<view name="error">/templates/tears.vm</view>
</action>
</actions>
</webwork1>
<atlassian-plugin name="Hello World" key="example.plugin.helloworld" plugins-version="2">
<plugin-info>
<description>A basic gadget module</description>
<vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
<version>1.0</version>
</plugin-info>
<gadget key="unique-gadget-key" location="gadget.xml"/>
</atlassian-plugin>
</atlassian-plugin>
and my gadget.xml which i put in the resources directory is:
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="JIRA Issues" author_email="adent#example.com" directory_title="JIRA Issues"
screenshot="images/screenshot.png"
thumbnail="images/thumbnail.png">
<Optional feature="dynamic-height" />
</ModulePrefs>
<Content type="html">
<![CDATA[
Hello, world!
]]>
</Content>
</Module>
</xml>
which I copied from https://developer.atlassian.com/display/GADGETS/Creating+your+Gadget+XML+Specification
yet I still get
It looks like you have one plugin descriptor nested inside another plugin descriptor. (I'm surprised that it actually passed validation!)
Change this:
<atlassian-plugin name="Hello World" key="example.plugin.helloworld" plugins-version="2">
<plugin-info>
<description>A basic gadget module</description>
<vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
<version>1.0</version>
</plugin-info>
<gadget key="unique-gadget-key" location="gadget.xml"/>
</atlassian-plugin>
to just this:
<gadget key="unique-gadget-key" location="gadget.xml"/>