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

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.

Related

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

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.

ROS1: AMCL doesn't move from initial position

I'm trying to do an AMCL localization for a pre-created map. AMCL should take laserScan played back from .bag file (containing 2 lasers that are combined into /scan_multi). Issue is that AMCL doesn't seem to do anything, even though odometry works and TF tree should be linked correctly.
Tried also for different initial positions specified from launch file, all of which are correctly represented on map in rviz.
Parts of my launch file that might be relevant:
<arg name="map_file" default="$(find project2)/map/map.yaml"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<node pkg="tf" type="static_transform_publisher" name="map_to_odom" args="0.0 0.0 0.0 0.0 0.0 0.0 /map /odom 40" />
<node pkg="tf" type="static_transform_publisher" name="odom_to_base_footprint" args="0.0 0.0 0.0 0.0 0.0 0.0 /odom /base_footprint 40" />
<node pkg="tf" type="static_transform_publisher" name="base_footprint_base_link" args="0.0 0.0 0.0 0.0 0.0 0.0 /base_footprint /base_link 40" />
<arg name="scan_topic" default="scan"/>
<arg name="initial_pose_x" default="0.0"/>
<arg name="initial_pose_y" default="0.0"/>
<arg name="initial_pose_a" default="0.0"/>
<node pkg="amcl" type="amcl" name="amcl">
<param name="initial_pose_x" value="$(arg initial_pose_x)"/>
<param name="initial_pose_y" value="$(arg initial_pose_y)"/>
<param name="initial_pose_a" value="$(arg initial_pose_a)"/>
<param name="odom_frame_id" value="odom"/>
<param name="base_frame_id" value="base_footprint"/>
<param name="frame_id" value="base_link"/>
<param name="map_frame_id" value="map"/>
<param name="use_map_topic" value="true"/>
<remap from="map" to="/map"/>
<remap from="scan" to="scan_multi"/>
</node>
Structure of TF tree: /map -> /odom -> /base_footprint -> /base_link -> /laser front
I tried using roswtf, got only 1 warning:
The following node subscriptions are unconnected: * /rviz: * /map_updates
Follow here for the whole project: https://drive.google.com/file/d/1AQz4...
Thanks for any help!
Deleting all static transforms from the .launch file and replacing them with a dynamic one between /odom and /base_footprint solved the issue. You can directly use the node from the src folder:
<node pkg="project2" name="odom_tf" respawn="false" type="odom_tf" output="screen"/>

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.

Resources