Skip to content

Commit b4f4dec

Browse files
committed
added stuff for motion_primitive_from_trajectory_controller (ros-controls/ros2_controllers#1837)
1 parent 3523225 commit b4f4dec

8 files changed

+97
-32
lines changed

ur_moveit_config/config/moveit_controllers.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ moveit_simple_controller_manager:
1111
controller_names:
1212
- scaled_joint_trajectory_controller
1313
- joint_trajectory_controller
14+
- motion_primitive_from_trajectory_controller
1415

1516
scaled_joint_trajectory_controller:
1617
action_ns: follow_joint_trajectory
1718
type: FollowJointTrajectory
18-
default: true
19+
default: false
1920
joints:
2021
- shoulder_pan_joint
2122
- shoulder_lift_joint
@@ -36,3 +37,16 @@ moveit_simple_controller_manager:
3637
- wrist_1_joint
3738
- wrist_2_joint
3839
- wrist_3_joint
40+
41+
42+
motion_primitive_from_trajectory_controller:
43+
action_ns: follow_joint_trajectory
44+
type: FollowJointTrajectory
45+
default: true
46+
joints:
47+
- shoulder_pan_joint
48+
- shoulder_lift_joint
49+
- elbow_joint
50+
- wrist_1_joint
51+
- wrist_2_joint
52+
- wrist_3_joint

ur_robot_driver/README_MotionPrimitive.md

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ Hardware interface for executing motion primitives on a UR robot using the ROS 2
55

66
![Licence](https://img.shields.io/badge/License-BSD-3-Clause-blue.svg)
77

8-
# Demo Video with URSim
9-
[![Play Video](doc/motion_primitive_ur_driver/motion_primitive_demo_video_preview.png)](https://www.youtube.com/watch?v=htUJtfkgr6Q)
10-
11-
# Related packages/ repos
12-
- [control_msgs](https://github.com/ros-controls/control_msgs/blob/motion_primitives/control_msgs/action/ExecuteMotionPrimitiveSequence.action)
13-
- [ros2_controllers with motion_primitives_forward_controller](https://github.com/b-robotized-forks/ros2_controllers/tree/motion_primitive_forward_controller/motion_primitives_forward_controller)
14-
- [Universal_Robots_ROS2_Driver with motion_primitive_ur_driver](https://github.com/b-robotized-forks/Universal_Robots_ROS2_Driver_MotionPrimitive)
15-
- [Universal_Robots_Client_Library](https://github.com/UniversalRobots/Universal_Robots_Client_Library)
8+
# Demo Video with motion_primitives_forward_controller
9+
[![Play Video](doc/motion_primitive_ur_driver/moprim_forward_controller_ur_demo_thumbnail.png)](https://youtu.be/SKz6LFvJmhQ)
1610

11+
# Demo Video with motion_primitives_from_trajectory_controller
12+
[![Play Video](doc/motion_primitive_ur_driver/moprim_from_traj_controller_ur_demo_thumbnail.png)](https://youtu.be/nsG4sW8BfLI)
1713

1814
# Architecture
19-
15+
**with motion_primitives_forward_controller**
2016
![Architecture Overview](doc/motion_primitive_ur_driver/ros2_control_motion_primitives_ur.drawio.png)
2117

18+
**with motion_primitives_from_trajectory_controller**
19+
![Architecture Overview](doc/motion_primitive_ur_driver/ros2_control_motion_primitives_from_traj_ur.drawio.png)
20+
2221
# Command and State Interfaces
2322

2423
In motion primitives mode, the following state and command interfaces are used to enable communication between the controller and the hardware interface.
@@ -104,42 +103,40 @@ ros2 run ur_client_library start_ursim.sh -m ur10e
104103
Remote control needs to be enabled:
105104
https://robodk.com/doc/en/Robots-Universal-Robots-How-enable-Remote-Control-URe.html
106105

107-
## Launch hardware_interface with motion_primitives_ur_driver
108-
With URSim:
106+
## With motion_primitives_forward_controller
107+
**With URSim:**
109108
```
110109
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10e robot_ip:=192.168.56.101 launch_rviz:=true headless_mode:=true initial_joint_controller:=motion_primitive_forward_controller
111110
```
112-
With H-KA UR10e:
111+
**With H-KA UR10e:**
113112
```
114113
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10e robot_ip:=192.168.1.102 launch_rviz:=true headless_mode:=true initial_joint_controller:=motion_primitive_forward_controller
115114
```
116-
## (optional) switching control mode
115+
**(optional) switching control mode**
117116
```
118117
ros2 control switch_controllers --activate motion_primitive_forward_controller --deactivate scaled_joint_trajectory_controller
119118
```
120-
## Send motion primitives
119+
**Send motion primitives from python script**
121120
> [!WARNING]
122121
> Ensure that the robot in your configuration is able to execute these motion primitives without any risk of collision.
123122
```
124123
ros2 run ur_robot_driver send_dummy_motion_primitives_ur10e.py
125124
```
126125
During the execution of the motion primitives, the movement can be stopped by pressing the Enter key in the terminal.
127126

127+
## With motion_primitives_from_trajectory_controller with MoveIt + RViz
128+
**Start MoveIt + RViz**
129+
```
130+
ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur10e launch_rviz:=true
131+
```
132+
**Start Controller + HW-Interface with URSim**
133+
```
134+
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10e robot_ip:=192.168.56.101 initial_joint_controller:=motion_primitive_from_trajectory_controller launch_rviz:=false
135+
```
136+
**Start Controller + HW-Interface with H-KA UR10e**
137+
```
138+
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10e robot_ip:=192.168.1.102 initial_joint_controller:=motion_primitive_from_trajectory_controller launch_rviz:=false
139+
```
140+
128141
# TODOs/ Improvements
129-
- if trajectory is finished while `instruction_executer->cancelMotion()` is called --> returns with execution_status ERROR --> no new command can be sent to hw-interface --> need to call `instruction_executer->cancelMotion()` a second time
130-
- The default `hardware_interface` implementation and the `InstructionExecutor` used to execute motion primitives both rely on a callback function that is triggered when a trajectory is completed. In the current implementation, the callback function of the `ur_driver` is overwritten, meaning that only one of the callback functions can be active at a time. This issue has been addressed by registering the `InstructionExecutor`'s callback when motion primitives mode is activated, and restoring the `hardware_interface`'s callback when the mode is deactivated. To enable this, a method `registerTrajDoneCallback()` was added to the `InstructionExecutor` in the `ur_client_library`:
131-
```cpp
132-
void urcl::InstructionExecutor::registerTrajDoneCallback()
133-
{
134-
driver_->registerTrajectoryDoneCallback(
135-
std::bind(&InstructionExecutor::trajDoneCallback, this, std::placeholders::_1));
136-
}
137-
```
138-
--> Is there a better solution for this?
139-
140-
# Useful sources
141-
- https://docs.universal-robots.com/Universal_Robots_ROS_Documentation/doc/ur_client_library/doc/architecture/instruction_executor.html
142-
- https://docs.universal-robots.com/Universal_Robots_ROS_Documentation/doc/ur_client_library/doc/examples/instruction_executor.html
143-
- https://rtw.b-robotized.com/master/use-cases/ros_workspaces/aliases.html
144-
- https://control.ros.org/master/doc/ros2_control/ros2controlcli/doc/userdoc.html
145-
- ...
142+
- if trajectory is finished while `instruction_executer->cancelMotion()` is called --> returns with execution_status ERROR --> no new command can be sent to hw-interface --> need to call `instruction_executer->cancelMotion()` a second time

ur_robot_driver/config/ur_controllers.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ controller_manager:
5353
motion_primitive_forward_controller:
5454
type: motion_primitives_forward_controller/MotionPrimitivesForwardController
5555

56+
motion_primitive_from_trajectory_controller:
57+
type: motion_primitives_from_trajectory_controller/MotionPrimitivesFromTrajectoryController
58+
5659
speed_scaling_state_broadcaster:
5760
ros__parameters:
5861
state_publish_rate: 100.0
@@ -223,3 +226,52 @@ motion_primitive_forward_controller:
223226
state_interfaces:
224227
- $(var tf_prefix)motion_primitive/execution_status
225228
- $(var tf_prefix)motion_primitive/ready_for_new_primitive
229+
230+
motion_primitive_from_trajectory_controller:
231+
ros__parameters:
232+
command_interfaces:
233+
- $(var tf_prefix)motion_primitive/motion_type
234+
- $(var tf_prefix)motion_primitive/q1
235+
- $(var tf_prefix)motion_primitive/q2
236+
- $(var tf_prefix)motion_primitive/q3
237+
- $(var tf_prefix)motion_primitive/q4
238+
- $(var tf_prefix)motion_primitive/q5
239+
- $(var tf_prefix)motion_primitive/q6
240+
- $(var tf_prefix)motion_primitive/pos_x
241+
- $(var tf_prefix)motion_primitive/pos_y
242+
- $(var tf_prefix)motion_primitive/pos_z
243+
- $(var tf_prefix)motion_primitive/pos_qx
244+
- $(var tf_prefix)motion_primitive/pos_qy
245+
- $(var tf_prefix)motion_primitive/pos_qz
246+
- $(var tf_prefix)motion_primitive/pos_qw
247+
- $(var tf_prefix)motion_primitive/pos_via_x
248+
- $(var tf_prefix)motion_primitive/pos_via_y
249+
- $(var tf_prefix)motion_primitive/pos_via_z
250+
- $(var tf_prefix)motion_primitive/pos_via_qx
251+
- $(var tf_prefix)motion_primitive/pos_via_qy
252+
- $(var tf_prefix)motion_primitive/pos_via_qz
253+
- $(var tf_prefix)motion_primitive/pos_via_qw
254+
- $(var tf_prefix)motion_primitive/blend_radius
255+
- $(var tf_prefix)motion_primitive/velocity
256+
- $(var tf_prefix)motion_primitive/acceleration
257+
- $(var tf_prefix)motion_primitive/move_time
258+
state_interfaces:
259+
- $(var tf_prefix)motion_primitive/execution_status
260+
- $(var tf_prefix)motion_primitive/ready_for_new_primitive
261+
local_joint_order:
262+
- shoulder_pan_joint
263+
- shoulder_lift_joint
264+
- elbow_joint
265+
- wrist_1_joint
266+
- wrist_2_joint
267+
- wrist_3_joint
268+
approximate_mode: "RDP_LIN" # "RDP_LIN" or "RDP_PTP"
269+
use_time_not_vel_and_acc: true
270+
epsilon_joint_angle: 0.05
271+
epsilon_cart_position: 0.01
272+
epsilon_cart_angle: 0.05
273+
# blend_radius_overwrite: 0.01
274+
# joint_vel_overwrite: 0.5
275+
# joint_acc_overwrite: 0.5
276+
# cart_vel_overwrite: 0.5
277+
# cart_acc_overwrite: 0.5
896 KB
Loading
931 KB
Loading
618 KB
Loading

ur_robot_driver/launch/ur_control.launch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def controller_spawner(controllers, active=True):
194194
"freedrive_mode_controller",
195195
"tool_contact_controller",
196196
"motion_primitive_forward_controller",
197+
"motion_primitive_from_trajectory_controller",
197198
]
198199
if activate_joint_controller.perform(context) == "true":
199200
controllers_active.append(initial_joint_controller.perform(context))
@@ -349,6 +350,7 @@ def generate_launch_description():
349350
"freedrive_mode_controller",
350351
"passthrough_trajectory_controller",
351352
"motion_primitive_forward_controller",
353+
"motion_primitive_from_trajectory_controller",
352354
],
353355
description="Initially loaded robot controller.",
354356
)

0 commit comments

Comments
 (0)