Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UR arms breaks - Warthog description update #529

Closed
tahir1069 opened this issue Jul 14, 2020 · 18 comments
Closed

UR arms breaks - Warthog description update #529

tahir1069 opened this issue Jul 14, 2020 · 18 comments

Comments

@tahir1069
Copy link

tahir1069 commented Jul 14, 2020

I am trying to update warthog description, by attaching three universal robot arms(2 UR5, 1 UR3). I am following the second approach pointed here. I was succesfull in adding all the robot descriptions needed. But UR arm breaks which actually is included later. In the following example:

  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/right_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_RIGHT_ARM 0)">
    <joint name="right_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="right_arm_mount_link"/>
      <child link="right_arm/base_link" />
    </joint>
  </xacro:if>

  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/left_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_LEFT_ARM 0)">
    <joint name="left_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="left_arm_mount_link"/>
      <child link="left_arm/base_link" />
    </joint>
  </xacro:if>
  
  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/center_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_CENTER_ARM 0)">
    <joint name="center_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 3.1415" />
      <parent link="center_arm_mount_link"/>
      <child link="center_arm/base_link" />
    </joint>
  </xacro:if>

Here I have added right and left (both UR5e) and than center(UR3), so the arm in the center breaks its joints and goes to the length of UR5e.

And if I take the center arm at the top like here:

<xacro:include filename="$(find mbs_description)/urdf/accessories/arms/center_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_CENTER_ARM 0)">
    <joint name="center_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 3.1415" />
      <parent link="center_arm_mount_link"/>
      <child link="center_arm/base_link" />
    </joint>
  </xacro:if>
  
  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/right_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_RIGHT_ARM 0)">
    <joint name="right_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="right_arm_mount_link"/>
      <child link="right_arm/base_link" />
    </joint>
  </xacro:if>

  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/left_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_LEFT_ARM 0)">
    <joint name="left_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="left_arm_mount_link"/>
      <child link="left_arm/base_link" />
    </joint>
  </xacro:if>

Now center arm will be fine but both right and left will shrink to the length of center arm i.e. UR3.

I am not able to sort out this issue, can anyone have an insight on the problem.

Note:

The robot descriptions UR5e and UR3 are the same as on the official supported repo

Note:
The same issue is raised on Warthog's repo as currently I don't know where the problem could be.

@tahir1069
Copy link
Author

center_broken
front_broken

@gavanderhoorn
Copy link
Member

Please check whether the version of ur_description in melodic-devel-staging also exhibits this problem.

It's likely some parameters are not namespaced properly, causing last-setting-wins behaviour.

@tahir1069
Copy link
Author

Thank you so much for your comment @gavanderhoorn .

I have changed the xacro file for each arm as in melodic-devel-staging according to ur.xacro but I get the following error.


[Errno 21] Is a directory: u'/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/' 
when evaluating expression 'load_yaml(joint_limits_parameters_file)' 
when evaluating expression '__joint_limit_parameters['joint_limits']' 
when evaluating expression '__limits['shoulder_pan']['min_position']'
when instantiating macro: read_model_data (/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/inc/ur_common.xacro)
instantiated from: ur_robot (/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/ur_macro.xacro)
in file: /home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/ur.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/accessories/arms/center_ur_arm.urdf.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/accessories.urdf.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/warthog.urdf.xacro
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/kinetic/lib/warthog_description/env_run                   /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/configs/mbs_warthog                   /opt/ros/kinetic/lib/xacro/xacro /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/warthog.urdf.xacro                   --inorder] returned with code [2]. 

Param xml is <param command="$(find warthog_description)/scripts/env_run                   $(find mbs_description)/configs/$(arg config)                   $(find xacro)/xacro $(find mbs_description)/urdf/warthog.urdf.xacro                   --inorder" name="robot_description"/>
The traceback for the exception was written to the log file

Here is my current xacro file for one robot.

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro"
       name="ur3_robot" >

  <!-- ur -->
  <xacro:include filename="$(find ur_description)/urdf/ur.xacro" />

  <!--ur3 parameters files -->
  <xacro:arg name="joint_limit_params" default="$(find ur_description)/config/ur3/joint_limits.yaml"/>
  <xacro:arg name="kinematics_params" default="$(find ur_description)/config/ur3/default_kinematics.yaml"/>
  <xacro:arg name="physical_params" default="$(find ur_description)/config/ur3/physical_parameters.yaml"/>
  <xacro:arg name="visual_params" default="$(find ur_description)/config/ur3/visual_parameters.yaml"/>
  <!--common parameters -->
  <xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface" />
  <xacro:arg name="safety_limits" default="false" doc="If True, enable the safety limits controller"/>
  <xacro:arg name="safety_pos_margin" default="0.15" doc="The lower/upper limits in the safety controller" />
  <xacro:arg name="safety_k_position" default="20" doc="Used to set k position in the safety controller" />

  <xacro:ur_robot 
                prefix="center_arm/"
                joint_limits_parameters_file="$(arg joint_limit_params)"
                kinematics_parameters_file="$(arg kinematics_params)"
                physical_parameters_file="$(arg physical_params)"
                visual_parameters_file="$(arg visual_params)"
                transmission_hw_interface="$(arg transmission_hw_interface)"
                safety_limits="$(arg safety_limits)"
                safety_pos_margin="$(arg safety_pos_margin)"
                safety_k_position="$(arg safety_k_position)"
                />
</robot>

Sorry for asking an error here but I was not able to get where the problem could be?

@gavanderhoorn
Copy link
Member

I'm not sure what you've done exactly, as the error output from xacro mentions fmauch_universal_robot. If/when using melodic-devel-staging, that is not what I would expect.

This isn't going to be a simple copy-paste replacement I'm afraid. You can't take just a single file.

You must use the entire new ur_description.

@gavanderhoorn
Copy link
Member

Perhaps UniversalRobots/Universal_Robots_ROS_Driver#97 can help.

@gavanderhoorn
Copy link
Member

Oh and btw cross-posting to this repository, the CP one and ROS Answers seems like a bit too much.

I would recommend you pick one venue for diagnosing your issue and close the others (for now).

@tahir1069
Copy link
Author

I'm not sure what you've done exactly, as the error output from xacro mentions fmauch_universal_robot. If/when using melodic-devel-staging, that is not what I would expect.

This isn't going to be a simple copy-paste replacement I'm afraid. You can't take just a single file.

You must use the entire new ur_description.

I have replaced the ur_description in fmauch_universal_robot from melodic-devel-staging, so I am using the new description.

Oh and btw cross-posting to this repository, the CP one and ROS Answers seems like a bit too much.

I would recommend you pick one venue for diagnosing your issue and close the others (for now).

actually initially I was not sure where the problem would be so I cross posted by mentioning everything. But yes I will close the other ones by mentioning to this issue

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Jul 17, 2020

I have replaced the ur_description in fmauch_universal_robot from melodic-devel-staging, so I am using the new description.

This traceback seems to suggest something is still using the fmauch_universal_robot fork:

I have changed the xacro file for each arm as in melodic-devel-staging according to ur.xacro but I get the following error.

[Errno 21] Is a directory: u'/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/' 
when evaluating expression 'load_yaml(joint_limits_parameters_file)' 
when evaluating expression '__joint_limit_parameters['joint_limits']' 
when evaluating expression '__limits['shoulder_pan']['min_position']'
when instantiating macro: read_model_data (/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/inc/ur_common.xacro)
instantiated from: ur_robot (/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/ur_macro.xacro)
in file: /home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/ur.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/accessories/arms/center_ur_arm.urdf.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/accessories.urdf.xacro
included from: /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/warthog.urdf.xacro
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/kinetic/lib/warthog_description/env_run                   /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/configs/mbs_warthog                   /opt/ros/kinetic/lib/xacro/xacro /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/warthog.urdf.xacro                   --inorder] returned with code [2]. 

Param xml is <param command="$(find warthog_description)/scripts/env_run                   $(find mbs_description)/configs/$(arg config)                   $(find xacro)/xacro $(find mbs_description)/urdf/warthog.urdf.xacro                   --inorder" name="robot_description"/>
The traceback for the exception was written to the log file

If you mean you've essentially overwritten the ur_description directory in @fmauch's fork with the one from melodic-devel-staging then that could work, but no guarantees.

This:

Is a directory: u'/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/'

seems to suggest you're passing a directory instead of a path to a file for one of the xacro args. That may be something to look into.

Also: I've no idea how the Clearpath packages make use of the macro xacros, so it could well be there are (implicit) assumptions there which melodic-devel-staging is now breaking.

@tahir1069
Copy link
Author

tahir1069 commented Jul 17, 2020

This traceback seems to suggest something is still using the fmauch_universal_robot fork:

OK now I have created a new workspace. Cloned the driver from this repo, changed branch to melodic-devel-staging, copied my own description and built the workspace. After running the launch file I get the same error as stated above.

If you mean you've essentially overwritten the ur_description directory in @fmauch's fork with the one from melodic-devel-staging then that could work, but no guarantees.

The new workspace gives the same error. I have question here. @fmauch 's fork is for calliberation, can I replace it with this master repo? than I will have everything consistent.

Is a directory: u'/home/student/warthog_data/TUD/warthog_ws/src/fmauch_universal_robot/ur_description/urdf/'
seems to suggest you're passing a directory instead of a path to a file for one of the xacro args. That may be something to look into.

I am using the same arguments from launch file load_ur3.launch and load_ur5e.launch, but yes in a xacro file which I have pasted above. There I only changed the prefix.

Also: I've no idea how the Clearpath packages make use of the macro xacros, so it could well be there are (implicit) assumptions there which melodic-devel-staging is now breaking.

Clearpath description let us include xacro files by defining an environment variable.

<xacro:include filename="$(find mbs_description)/urdf/accessories/arms/center_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_CENTER_ARM 0)">
    <joint name="center_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 3.1415" />
      <parent link="center_arm_mount_link"/>
      <child link="center_arm/base_link" />
    </joint>
  </xacro:if>

Here is the only part which is responsible for center_arm in Clearpath package. And center_arm.urdf.xacro is the same which I have posted here

@ipa-nhg
Copy link
Member

ipa-nhg commented Jul 22, 2020

@tahir1069 which distro are you using? melodic or kinetic?

The error you copied says:

Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/**kinetic**/lib/warthog_description/env_run                   /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/configs/mbs_warthog                   /opt/ros/**kinetic**/lib/xacro/xacro /home/student/warthog_data/TUD/warthog_ws/src/mbs/mbs_description/urdf/warthog.urdf.xacro                   --inorder] returned with code [2]. 

I am not sure, but could be that some of the xacro expresion/tags from the melodic-devel-staging branch version were not supported for kinetic. Unfortunately I haven't got a kinetic installation to reproduce the error.

@tahir1069
Copy link
Author

I have figured out the issue.
Actually I was importing ur.xacro where I was setting all the parameters. But I have to import ur_macro.xacro where after setting the correct parameters I was able to solve the above mentioned error.

@tahir1069
Copy link
Author

So problem here now is the same as mentioned above. This time the arms does not break as because of the same ur_macro.xacro but all of the models are same. If the ur3 is at the top, than all three arms will be ur3. As is the same case for ur5e if it is at the top than all three arms will be the same i.e. ur5e

Here is the code responsible for all three arms:

 <!-- Arms -->
  
  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/right_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_RIGHT_ARM 0)">
    <joint name="right_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="right_arm_mount_link"/>
      <child link="right_arm/base_link" />
    </joint>
  </xacro:if>

  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/left_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_LEFT_ARM 0)">
    <joint name="left_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 0" />
      <parent link="left_arm_mount_link"/>
      <child link="left_arm/base_link" />
    </joint>
  </xacro:if>
  
  <xacro:include filename="$(find mbs_description)/urdf/accessories/arms/center_ur_arm.urdf.xacro" />
  <xacro:if value="$(optenv WARTHOG_CENTER_ARM 0)">
    <joint name="center_arm_joint" type="fixed">
      <origin xyz="0 0 -0.025" rpy="0 0 3.1415" />
      <parent link="center_arm_mount_link"/>
      <child link="center_arm/base_link" />
    </joint>
  </xacro:if>

and for all three center_arm, right_arm and left_arm the configuration is the same as in the launch files, only included in xacro xml format.

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro"
       name="ur3_robot" >

  <!-- ur -->
  <xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro" />

  <!--ur3 parameters files -->
  <xacro:arg name="joint_limit_params" default="$(find ur_description)/config/ur3/joint_limits.yaml"/>
  <xacro:arg name="kinematics_params" default="$(find ur_description)/config/ur3/default_kinematics.yaml"/>
  <xacro:arg name="physical_params" default="$(find ur_description)/config/ur3/physical_parameters.yaml"/>
  <xacro:arg name="visual_params" default="$(find ur_description)/config/ur3/visual_parameters.yaml"/>
  <!--common parameters -->
  <xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface" />
  <xacro:arg name="safety_limits" default="false" doc="If True, enable the safety limits controller"/>
  <xacro:arg name="safety_pos_margin" default="0.15" doc="The lower/upper limits in the safety controller" />
  <xacro:arg name="safety_k_position" default="20" doc="Used to set k position in the safety controller" />

  <xacro:ur_robot 
                prefix="center_arm/"
                joint_limits_parameters_file="$(arg joint_limit_params)"
                kinematics_parameters_file="$(arg kinematics_params)"
                physical_parameters_file="$(arg physical_params)"
                visual_parameters_file="$(arg visual_params)"
                transmission_hw_interface="$(arg transmission_hw_interface)"
                safety_limits="$(arg safety_limits)"
                safety_pos_margin="$(arg safety_pos_margin)"
                safety_k_position="$(arg safety_k_position)"
                />
</robot>

For both right and left ur5e are there so there xacro descriptions are the same only with different prefixes:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro"
       name="ur5e" >

  <!-- ur -->
  <xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro" />

  <!--ur5e parameters files -->
  <xacro:arg name="joint_limit_params" default="$(find ur_description)/config/ur5e/joint_limits.yaml"/>
  <xacro:arg name="kinematics_params" default="$(find ur_description)/config/ur5e/default_kinematics.yaml"/>
  <xacro:arg name="physical_params" default="$(find ur_description)/config/ur5e/physical_parameters.yaml"/>
  <xacro:arg name="visual_params" default="$(find ur_description)/config/ur5e/visual_parameters.yaml"/>
  <!--common parameters -->
  <xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface" />
  <xacro:arg name="safety_limits" default="false" doc="If True, enable the safety limits controller"/>
  <xacro:arg name="safety_pos_margin" default="0.15" doc="The lower/upper limits in the safety controller" />
  <xacro:arg name="safety_k_position" default="20" doc="Used to set k position in the safety controller" />
  
  <xacro:ur_robot 
                prefix="right_arm/"
                joint_limits_parameters_file="$(arg joint_limit_params)"
                kinematics_parameters_file="$(arg kinematics_params)"
                physical_parameters_file="$(arg physical_params)"
                visual_parameters_file="$(arg visual_params)"
                transmission_hw_interface="$(arg transmission_hw_interface)"
                safety_limits="$(arg safety_limits)"
                safety_pos_margin="$(arg safety_pos_margin)"
                safety_k_position="$(arg safety_k_position)"                
                />

  />
</robot>

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Jul 28, 2020

I'm going to have to ask you to create an SSCCE, as having to go through all the Clearpath xacros and .launch files is not doable.

Once you have an SSCCE, post a link to it here and we could take a look.

Note: it's very likely a proper SSCCE does not have to include any reference to any Clearpath files.

@tahir1069
Copy link
Author

tahir1069 commented Jul 28, 2020

I am creating the SSCCE here, so that it can help others in future to benefit. Everything below is from this current repo of universal_robot nothing from Clearpath.

I will share each and every step with files to recreate the issue.

mkdir -p test_ws/src && cd test_ws/src 

git clone https://github.com/ros-industrial/universal_robot/

cd universal_robot

git checkout melodic-devel-staging

cd ..

catkin_create_pkg test_urdf

# Extract robot_model.tar.gz(attached to this comment) to test_urdf package just created. 

cd ..

catkin_make

source devel/setup.bash

roslaunch test_urdf model.launch

robot_model.tar.gz

Currently all three arms will be ur5e because right_arm is at the top in test.urdf.xacro. Just taking center_arm to the top will make all three arms to ur3

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Jul 28, 2020

The files in urdf/arms are not macros, but top-level .xacros. You cannot xacro:include those in another file, as "the last one" will essentially overwrite the values for all the xacro:args of the others -- which seems to explain what you report.

Can you clarify why you create those files?

They appear not to be needed, as you could "just" xacro:include the ur_macro.xacro once, and then instantiate the model three times, supplying the appropriate arguments to the xacro:ur_robot macro.

@gavanderhoorn
Copy link
Member

I'm going to assume the xacro macros in this repository are actually OK, and the reported behaviour is the result of a configuration error on the user side for now.

I'll also close this issue in anticipation of confirmation of this by @tahir1069.

If it turns out something is actually wrong here in universal_robot, we can re-open.

@gavanderhoorn
Copy link
Member

@tahir1069: could you please confirm xacro:includeing the correct files fixes the issue for you?

Note: during WRID20 we had a discussion about creating "convenience" macros which would provide the same defaults as the ones set in the top-level .xacro, but per-variant. See melodic-devel-staging...gavanderhoorn:convenience_macros for a WIP.

@tahir1069
Copy link
Author

The files in urdf/arms are not macros, but top-level .xacros. You cannot xacro:include those in another file, as "the last one" will essentially overwrite the values for all the xacro:args of the others -- which seems to explain what you report.

Yes this was the issue. I actually didn't knew that this would happen because they were in seperate files. But as they are included in a top level file so essentially this should over write the values. But still the the solution suggested by you worked out and the model is fixed.

Can you clarify why you create those files?

To have everything separate in the repository and include the ones dependent upon the environment variables.

@tahir1069: could you please confirm xacro:includeing the correct files fixes the issue for you?

Yes indeed!

See melodic-devel-staging...gavanderhoorn:convenience_macros for a WIP.

Exactly this is what I tried to do and now its working.

Thank you so much for your help so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants