Robotics StackExchange | Archived questions

Joint torques for a simulated UR3e robot

Hi everyone, I am simulating a UR3e in ROS gazebo and i am trying to get the motor torques of all the joints. When I read out the effort values in the joint_states topic they always remain 0.0, even when the robot is moving. How can I get the joint torques? Kind regards Dimitri

Asked by dimitri on 2020-05-25 06:31:01 UTC

Comments

The robot controller is set to effort_controllers?

Asked by Teo Cardoso on 2020-05-25 12:51:46 UTC

Honestly I don't know. I think its position controlled. How do I check/set that?

Asked by dimitri on 2020-05-25 14:25:24 UTC

Probably it is in line 5, in the file ur3_robot.urdf.xacro. If I'm not say anything wrong, the default controller, is the position. And I believe with this option, there is no feedback on the effort. How ever, with effort controllers you can use the effort/position, which is a controller using effort with input in position, using a feedback loop and PID. And this one, I'm sure that gives you the effort feedback on joint_states topic.

Asked by Teo Cardoso on 2020-05-25 16:58:19 UTC

Thank you. But I did not find any specification of a controller in any of the urdf files. But i did find under /universal_robot/ur_e_gazebo/controller the file arm_controller_ur3e.yaml with the following content (the [...] signifies there was more but it didn't fit in here):

arm_controller:
  type: position_controllers/JointTrajectoryController
  joints:
     - shoulder_pan_joint
     - shoulder_lift_joint
     - elbow_joint
     - wrist_1_joint
     - wrist_2_joint
     - wrist_3_joint
  constraints:
[...]
  stop_trajectory_duration: 0.5
  state_publish_rate:  25
  action_monitor_rate: 10
joint_group_position_controller:
  type: position_controllers/JointGroupPositionController
  joints:
     - shoulder_pan_joint
     - shoulder_lift_joint
     - elbow_joint
     - wrist_1_joint
     - wrist_2_joint
     - wrist_3_joint

Do I need to change the controller here?

Asked by dimitri on 2020-05-26 03:33:53 UTC

You need change there too. However, it needs to change in the xacro file yet.

Asked by Teo Cardoso on 2020-05-26 08:09:54 UTC

Ok. Because the file you mentioned above (ur3_robot.urdf.xacro) looks like this>

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

  <xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface"/>

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

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

  <!-- arm -->
  <xacro:ur3_robot prefix="" joint_limited="false"
    transmission_hw_interface="$(arg transmission_hw_interface)"
  />

  <link name="world" />

  <joint name="world_joint" type="fixed">
    <parent link="world" />
    <child link = "base_link" />
    <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
  </joint>

</robot>

Where exactly would I need to put in the effort controller?

Asked by dimitri on 2020-05-26 09:15:44 UTC

From:

To:

and on your yaml file:

  type: **position_controllers**/JointTrajectoryController
  type: **effort_controllers**/JointTrajectoryController

  type: **position_controllers**/JointGroupPositionController
  type: **effort_controllers**/JointGroupPositionController

I never tried this before. However, it makes sense.

Asked by Teo Cardoso on 2020-05-26 12:53:24 UTC

Ok i did as you said. I get the following error:

[ERROR] [1590516223.569938532, 0.247000000]: Exception thrown: Could not find resource 'shoulder_pan_joint' in 'hardware_interface::EffortJointInterface'.
[ERROR] [1590516223.570058650, 0.247000000]: Failed to initialize the controller
[ERROR] [1590516223.570113416, 0.247000000]: Initializing controller 'joint_group_position_controller' failed

and

[ERROR] [1590516223.807461567, 0.392000000]: Could not find joint 'shoulder_pan_joint' in 'hardware_interface::EffortJointInterface'.
[ERROR] [1590516223.807695648, 0.392000000]: Failed to initialize the controller
[ERROR] [1590516223.807882994, 0.393000000]: Initializing controller 'arm_controller' failed
Error when loading 'arm_controller'
[ERROR] [1590516223.813253582, 0.397000000]: Could not start controller with name 'arm_controller' because no controller with this name exists

any ideas?

Asked by dimitri on 2020-05-26 13:14:43 UTC

ok I also changed the file ur.transmission.xacro and replaced hardwareInterface of all the transmissions from hardware_interface/PositionJointInterface to hardware_interface/EffortJointInterface

Now i get this error:

[ERROR] [1590518384.005703663, 0.391000000]: No p gain specified for pid.  Namespace: /joint_group_position_controller/shoulder_pan_joint/pid
[ERROR] [1590518384.005910143, 0.391000000]: Failed to load PID parameters from shoulder_pan_joint/pid
[ERROR] [1590518384.006038740, 0.391000000]: Failed to initialize the controller
[ERROR] [1590518384.006093491, 0.391000000]: Initializing controller 'joint_group_position_controller' failed
Error when loading 'joint_group_position_controller'
Loaded 'joint_state_controller'
Started ['joint_state_controller'] successfully
[ERROR] [1590518384.079059054, 0.460000000]: No p gain specified for pid.  Namespace: /arm_controller/gains/shoulder_pan_joint

Asked by dimitri on 2020-05-26 13:44:57 UTC

and this:

[gazebo-2] process has died [pid 15251, exit code 139, cmd /opt/ros/melodic/lib/gazebo_ros/gzserver -e ode worlds/empty.world roku/roku/IMU:=roku/IMU __name:=gazebo __log:=/home/dimitri/.ros/log/41e98804-9f80-11ea-944c-c0b6f9fd3f63/gazebo-2.log].
log file: /home/dimitri/.ros/log/41e98804-9f80-11ea-944c-c0b6f9fd3f63/gazebo-2*.log
[arm_controller_spawner-7] process has died [pid 15268, exit code 1, cmd /opt/ros/melodic/lib/controller_manager/controller_manager spawn arm_controller roku/roku/IMU:=roku/IMU __name:=arm_controller_spawner __log:=/home/dimitri/.ros/log/41e98804-9f80-11ea-944c-c0b6f9fd3f63/arm_controller_spawner-7.log].
log file: /home/dimitri/.ros/log/41e98804-9f80-11ea-944c-c0b6f9fd3f63/arm_controller_spawner-7*.log

and

[ERROR] [1590518424.112222655, 0.477000000]: Unable to connect to move_group action server 'move_group' within allotted time (30s)

Asked by dimitri on 2020-05-26 13:45:51 UTC

Ok after adding PID gains to the file arm_controller_ur3e.yaml it seems to work.

gains:
      shoulder_pan_joint: {p: 70.0, i: 10.0, d: 0.0}
      shoulder_lift_joint: {p: 70.0, i: 10.0, d: 0.0}
      elbow_joint: {p: 50.0, i: 6.0, d: 0.0}
      wrist_1_joint: {p: 8.0, i: 6.0, d: 0.0}
      wrist_2_joint: {p: 8.0, i: 6.0, d: 0.0}
      wrist_3_joint: {p: 8.0, i: 6.0, d: 0.0}

Thanks a lot Teo Cardoso!

Asked by dimitri on 2020-05-26 17:52:03 UTC

See ros-industrial/universal_robot#227 for a PR which implements exactly this.

Asked by gvdhoorn on 2020-05-27 02:50:29 UTC

Thank you gvdhoorn.

The pull request you mentioned only changes the hardware interface, but I guess it is also necessary to set the controllers to be effort_controllers for it to work?

In the pull request conversation you say that there is no joint torque control interface for UR. what I need is just the values of the joint torques, I do not intend to use an effort controller on the real robot. Is this possible?

Asked by dimitri on 2020-05-27 07:34:35 UTC

Thank you very much! I think that's exactly what I need. I have a question though: How does Universal_Robots_ROS_Driver work together with ros-industrial/universal_robot? I'm sorry I'm a little confused there. Are they complementary or are they different things for the same purpose?

Asked by dimitri on 2020-05-27 09:16:04 UTC

Thank you very much! I think that's exactly what I need.

as long as you've noticed that the actual effort is not being published. It's the joint current. Those are related, but not identical.

How does Universal_Robots_ROS_Driver work together with ros-industrial/universal_robot?

No drivers other than ur_robot_driver (which is hosted at UniversalRobots/Universal_Robots_ROS_Driver) are supported any more. ur_driver has never worked for e-Series robots. ur_modern_driver is deprecated, same for wiki/ur_driver.

ros-industrial/universal_robot provides description packages, Gazebo compatibility and MoveIt configurations, but that's it. The driver comes from UniversalRobots/Universal_Robots_ROS_Driver.

Asked by gvdhoorn on 2020-05-27 09:20:11 UTC

as long as you've noticed that the actual effort is not being published. It's the joint current.

Yes I got that

ros-industrial/universal_robot provides description packages, Gazebo compatibility and MoveIt configurations, but that's it. The driver comes from UniversalRobots/Universal_Robots_ROS_Driver

Sorry i am still not sure if i get it right. So for simulating the robot in gazebo (possibly in connection with moveit) i only need the ros-industrial/universal_robot, if i am working with the real robot on the other hand i need UniversalRobots/Universal_Robots_ROS_Driver ? Or do I need both of them both times? Because in ros-industrial/universal_robot I have a folder called "ur_driver".

Asked by dimitri on 2020-05-27 09:45:15 UTC

What is unclear exactly? I wrote that ur_driver is both deprecated (ie: should never be used any more) and has never worked with e-Series robots. So even though you may have that folder, there is nothing there you should use with your real robot.

None of the UR drivers are used with simulations.

Asked by gvdhoorn on 2020-05-27 09:53:14 UTC

Ok I think I get it. So as long as I am just working with simulations I can forget about the drivers. And when I start working with the real robot I need the ur_robot_driver and forget about the ros-industrial/universal_robot. Is that correct?

So the efforts from ur_robot_driver are the motor currents, but the efforts from ros-industrial/universal_robot are the "real" torques from the gazebo simulation?

Asked by dimitri on 2020-05-27 10:03:23 UTC

And when I start working with the real robot I need the ur_robot_driver

yes.

and forget about the ros-industrial/universal_robot. Is that correct?

Not quite: you'd still use ur_description and possibly the MoveIt packges (I don't know what you intend to do exactly), but not ur_driver nor ur_gazebo.

It's actually slightly different, as you'd use a fork of these packages, but that's not important right now. Just make sure to follow the instructions in the readme of UniversalRobots/Universal_Robots_ROS_Driver correctly.

So the efforts from ur_robot_driver are the motor currents

Yes.

but the efforts from ros-industrial/universal_robot are the "real" torques from the gazebo simulation?

Well, technically, "the efforts in the JointState messages coming out of Gazebo when using it with ur_gazebo are the simulated torques from the robot in the simulation".

It's important to be precise here.

Asked by gvdhoorn on 2020-05-27 11:23:03 UTC

gvdhoorn you are an angel! Thanks a lot for the quick and patient answers. I think that's all I need for now.

I am not really used to forums like these. Should I put a summarizing answer at the end so people will see it without going through all these comments?

Asked by dimitri on 2020-05-27 11:34:53 UTC

I would say @Teo Cardoso should have posted his comment as an answer, as it really was the answer: you have to change the hardware_interface used in the simulated robot model to one which supports effort, otherwise no efforts will be reported.

If he can do that, you should accept this answer.

Asked by gvdhoorn on 2020-05-27 11:36:49 UTC

Answers