-
Notifications
You must be signed in to change notification settings - Fork 287
Hardware interface for sending motion primitives to the robot via the Instruction Executor instead of trajectories #1341
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
Open
mathias31415
wants to merge
100
commits into
UniversalRobots:main
Choose a base branch
from
b-robotized-forks:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 93 commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
8e0b277
outsourced updateNonDoubleValues() in helper: build and launch succes…
mathias31415 f39acad
outsourced export_state_interfaces() in helper: build and launch succ…
mathias31415 d67a261
outsourced readData() in helper: build and launch successfull
mathias31415 ad6aa99
outsourced readBitsetData() in helper: build and launch successfull
mathias31415 56530c2
outsourced quaternion definition
mathias31415 e603b37
outsourced extractToolPose() in helper: build and launch successfull
mathias31415 b9dfa02
outsourced transformForceTorque() in helper: build and launch success…
mathias31415 0bdc8e1
outsourced big parts of read() in helper: build uccessfull, but rtde …
mathias31415 eb48701
fixed some bugs --> launch successfull
mathias31415 f22ae3a
changed double& tcp_rotation_buffer_x, _y, _z, _w to Quaternion& tcp_…
mathias31415 3c4704f
fixed types for update_non_double_values() parameters
mathias31415 10f2528
using meber variables instead of passing references for the function …
mathias31415 f72c178
removed some commented stuff
mathias31415 c15dd16
prepared hardware_interface and ur_state_helper implementation for me…
mathias31415 cbf193a
Merge branch 'header-extraktion-state-interfaces'
mathias31415 12c70e6
changed if (ur_driver_->getVersion().major >= 5) to if (get_robot_sof…
mathias31415 d465478
renamed ur_state_helper.hpp to tateinterface_helper.hpp
mathias31415 f5059b4
changed method names in stateinterface_helper.hpp from snake to camel…
mathias31415 ff8fc72
added motion_primitives_ur_driver_pkg from https://github.com/mathias…
mathias31415 aa8ed59
renamed motion_primitives_ur_driver_pkg to ur_robot_motion_primitives…
mathias31415 7f1ef70
added functionallity to execute multiple primitives as a motion sequence
mathias31415 9838fdd
Added new state interface ready_for_new_primitive to indicate whether…
mathias31415 a84380f
removed case 33 block with hardcoded motion sequence (was only for te…
mathias31415 c17773f
edited readme
mathias31415 3eb633b
reduced blend radius for moveL
mathias31415 20de441
integrated ur_robot_motion_primitives_driver into ur_robot_driver pkg
mathias31415 c01db85
changed namespace from ur_robot_motion_primitives_driver to ur_robot_…
mathias31415 d73b46a
edited readme
mathias31415 4d261a8
removed ur_controllers_motion_primitive.yaml
mathias31415 eed2cf9
removed motion_primitive_ur.urdf.xacro and motion_primitive_ur_rsp.la…
mathias31415 443031e
edited readme
mathias31415 5e2a1b2
edited readme
mathias31415 d34dabf
changed THIS_PACKAGE_INCLUDE_DEPENDS
mathias31415 a980686
chenaged/ semoved some comments
mathias31415 3b2cddb
edited readme
mathias31415 72ec14f
edited readme
mathias31415 722908f
changed images in readme to white background
mathias31415 9de677a
edited Related packages/ repos in readme
mathias31415 c782a7f
moved quaternion definition to stateinterface_helper.hpp
mathias31415 66c0cf7
added/ modified copyright headers
mathias31415 04d794b
edited readme
mathias31415 1303cf1
removed visibility control
mathias31415 3987b35
added demo video to readme
mathias31415 68cf020
pre-commit fixes
mathias31415 4f8c7ef
fixed prints
mathias31415 b917b51
added ExecutionState STOPPED and added handling for MotionType RESET_…
mathias31415 7028805
edited readme
mathias31415 55b6953
updated MotionPrimitiveExecutionWithHelperTypes draw.io
mathias31415 8e52e7c
added python script for tests with ur10e at H-KA
mathias31415 1d8033a
Reverted the outsourcing of state-interface functionallity to statein…
mathias31415 02a591b
integrated motion_primitives_ur_driver into hardware_interface. build…
mathias31415 9b1ad3d
integrated motion_primitives_ur_driver into hardware_interface. Execu…
mathias31415 faf98b9
pre-commit fixes
mathias31415 b410003
edited readme
mathias31415 9cbab0f
modified python script for action based moprim controller instead of …
mathias31415 f98f258
Update README_MotionPrimitive.md
mathias31415 cc715d3
edited readme
mathias31415 e59aca6
changed blend radius to 0 for eval sequence
mathias31415 beda5eb
changed quaternionToEuler() function from manual calculation to tf2 lib
mathias31415 fbc758d
changed quaternionToEuler() to quaternionToRotVec() because robot nee…
mathias31415 8c97594
removed include <cmath>
mathias31415 91e0add
removed queue_size param
mathias31415 71a1342
removed name from ros__parameters of motion_primitive_controller
mathias31415 3e37d6e
Adjusted ExecutionState and MotionType for Enum definition in moprim …
mathias31415 0953a67
renamed motion_primitive_controller to motion_primitive_forward_contr…
mathias31415 f2fda76
Adjusted Action GoalStatus handling to changes in the controller impl…
mathias31415 4554f8a
Using MotionType from msg definition and MotionHelperType from enum i…
mathias31415 65f3298
using ros-controls/control_msgs#228 instead of industrial_robot_motio…
mathias31415 db68d02
Merge remote-tracking branch 'upstream/main'
mathias31415 7c9e5b0
changed {motion_primitives_forward_controller_TARGETS}
mathias31415 fbe4d68
Removed duplicate entries in ament_export_dependencies
mathias31415 988af31
fixed motion_primitives_forward_controller included
mathias31415 5370095
fixed missing ,
mathias31415 869840c
pre-commit fixes
mathias31415 374c3a9
removed send_joint_positions.py
mathias31415 cfd07e2
removed hka in send_dummy_motion_primitives_hka_ur10e.py
mathias31415 fe5b872
changed license in send_dummy_motion_primitives_ur10e.py from apache …
mathias31415 7f2c44a
Changed rolling.repos file for ros2_controllers and control_msgs. Nee…
mathias31415 df338be
Using https://github.com/UniversalRobots/Universal_Robots_Client_Libr…
mathias31415 ccabe99
modified z position in send_dummy_motion_primitives_ur10e.py
mathias31415 ff6ab76
Auto-update pre-commit hooks
github-actions[bot] 192131f
Merge pull request #1 from b-robotized-forks/update-ci/pre-commit-aut…
mathias31415 a60acf5
Modified rolling repos since https://github.com/ros-controls/control_…
mathias31415 227140e
pass full interface names to the controller (such as $(var tf_prefix)…
mathias31415 3523225
argument_name --> name, argument_value --> value
mathias31415 265909d
edited readme
mathias31415 bc4bffd
Changed back Universal_Robots_Client_Library in rolling.repos because…
mathias31415 8cb1eeb
fixed bsd-3 license link in readme
mathias31415 0cc909f
removed second ur_driver_->registerToolContactResultCallback()
mathias31415 db0754f
removed stop thread
mathias31415 5cae525
changed implementation for current_moprim_execution_status_ after ins…
mathias31415 87f6551
Replaced moprim_cmd_mutex_ with realtime_tools::LockFreeSPSCQueue<std…
mathias31415 94e83be
wrapped current_moprim_execution_status_ into an std::atomic<>
mathias31415 a540986
Updated link for MoveC modes
mathias31415 c8973f0
removed "Author modifications: Mathias Fuhrer" in launchfile
mathias31415 b414756
changed headless_mode default value back to false
mathias31415 e0066d1
removed new_moprim_cmd_available_
mathias31415 3220c76
added execution_status STOPPING to readme
mathias31415 789e960
Implemented the interface names fixed in the controller --> only tf_p…
mathias31415 7f9a782
edited readme
mathias31415 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
hardware_interface in motion primitives mode | ||
========================================== | ||
|
||
Hardware interface for executing motion primitives on a UR robot using the ROS 2 control framework. It allows the controller to execute linear (LINEAR_CARTESIAN/ LIN/ MOVEL), circular (CIRCULAR_CARTESIAN/ CIRC/ MOVEC), and joint-based (LINEAR_JOINT/ PTP/ MOVEJ) motion commands asynchronously and supports motion sequences for smooth trajectory execution. | ||
|
||
[](https://opensource.org/licenses/BSD-3-Clause) | ||
|
||
# Demo Video with motion_primitives_forward_controller | ||
[](https://youtu.be/SKz6LFvJmhQ) | ||
|
||
# Architecture | ||
**with motion_primitives_forward_controller** | ||
 | ||
|
||
# Command and State Interfaces | ||
|
||
In motion primitives mode, the following state and command interfaces are used to enable communication between the controller and the hardware interface. | ||
|
||
## Command Interfaces | ||
|
||
These interfaces are used to send motion primitive data to the hardware interface: | ||
|
||
- `motion_type`: Type of motion primitive (LINEAR_JOINT, LINEAR_CARTESIAN, CIRCULAR_CARTESIAN) | ||
- `q1` – `q6`: Target joint positions for joint-based motion | ||
- `pos_x`, `pos_y`, `pos_z`: Target Cartesian position | ||
- `pos_qx`, `pos_qy`, `pos_qz`, `pos_qw`: Orientation quaternion of the target pose | ||
- `pos_via_x`, `pos_via_y`, `pos_via_z`: Intermediate via-point position for circular motion | ||
- `pos_via_qx`, `pos_via_qy`, `pos_via_qz`, `pos_via_qw`: Orientation quaternion of via-point | ||
- `blend_radius`: Blending radius for smooth transitions | ||
- `velocity`: Desired motion velocity | ||
- `acceleration`: Desired motion acceleration | ||
- `move_time`: Optional duration for time-based execution (For LINEAR_JOINT and LINEAR_CARTESIAN. If move_time > 0, velocity and acceleration are ignored) | ||
|
||
## State Interfaces | ||
|
||
These interfaces are used to communicate the internal status of the hardware interface back to the [`motion_primitives_forward_controller`](https://github.com/b-robotized-forks/ros2_controllers/tree/motion_primitive_forward_controller/motion_primitives_forward_controller): | ||
|
||
- `execution_status`: Indicates the current execution state of the primitive. Possible values are: | ||
- `IDLE`: No motion in progress | ||
- `EXECUTING`: Currently executing a primitive | ||
- `SUCCESS`: Last command finished successfully | ||
- `ERROR`: An error occurred during execution | ||
- `STOPPED`: The robot was stopped using the `STOP_MOTION` command and must be reset with the `RESET_STOP` command before executing new commands. | ||
- `ready_for_new_primitive`: Boolean flag indicating whether the interface is ready to receive a new motion primitive | ||
|
||
In addition to these, the driver also provides all standard state interfaces from the original UR hardware interface (e.g., joint positions, velocities). These are used by components like the `joint_state_broadcaster` and allow tools like RViz to visualize the current robot state. | ||
|
||
|
||
# Supported Motion Primitives | ||
|
||
- Support for basic motion primitives: | ||
- `LINEAR_JOINT` | ||
- `LINEAR_CARTESIAN` | ||
- `CIRCULAR_CARTESIAN` | ||
- Additional helper types: | ||
- `STOP_MOTION`: Immediately stops the current robot motion and clears all pending primitives in the controller's queue. | ||
- `RESET_STOP`: After `RESET_STOP`, new commands can get handled. | ||
- `MOTION_SEQUENCE_START` / `MOTION_SEQUENCE_END`: Define a motion sequence block. All primitives between these two markers will be executed as a single, continuous sequence. This allows seamless transitions (blending) between primitives. | ||
|
||
 | ||
|
||
# Overview | ||
|
||
In contrast to the standard UR hardware interface, this driver does not compute or execute trajectories on the ROS 2 side. Instead, it passes high-level motion primitives directly to the robot controller, which then computes and executes the trajectory internally. | ||
|
||
This approach offers two key advantages: | ||
|
||
- **Reduced real-time requirements** on the ROS 2 side, since trajectory planning and execution are offloaded to the robot. | ||
- **Improved motion quality**, as the robot controller has better knowledge of the robot's kinematics and dynamics, leading to more optimized and accurate motion execution. | ||
|
||
|
||
## write() Method | ||
|
||
In motion primitives mode, the `write()` method checks whether a new motion primitive command has been received from the controller via the command interfaces. If a new command is present: | ||
|
||
1. If the command is `STOP_MOTION`, a flag is set which leads to interrupting the current motion inside the `asyncStopMotionThread()`. If the command is `RESET_STOP`, the flag is reset, and new motion primitives can be received and executed. | ||
2. For other commands, they are passed to the `asyncCommandThread()` and executed asynchronously. Individual primitives are executed directly via the Instruction Executor. | ||
If a `MOTION_SEQUENCE_START` command is received, all subsequent primitives are added to a motion sequence. Once `MOTION_SEQUENCE_END` is received, the entire sequence is executed via the Instruction Executor. | ||
|
||
Threading is required since calls to the Instruction Executor are blocking. Offloading these to separate threads ensures the control loop remains responsive during motion execution. The stopping functionality is also threaded to allow interrupting a primitive even during execution or in a motion sequence. | ||
|
||
## read() Method | ||
|
||
The `read()` method: | ||
|
||
- Publishes the `execution_status` over a state interface with possible values: `IDLE`, `EXECUTING`, `SUCCESS`, `ERROR`, `STOPPED`. | ||
- Publishes `ready_for_new_primitive` over a state interface to signal whether the interface is ready to receive a new primitive. | ||
- Handles additional state interfaces from the UR driver, such as joint states, enabling RViz to visualize the current robot pose. | ||
|
||
|
||
# Example usage notes with UR10e | ||
## (optional) URSim | ||
Start UR-Sim according to the [Universal Robots ROS 2 Driver Documentation](https://docs.universal-robots.com/Universal_Robots_ROS2_Documentation/doc/ur_client_library/doc/setup/ursim_docker.html) or the [Documentation for universalrobots/ursim_e-series docker container](https://hub.docker.com/r/universalrobots/ursim_e-series) | ||
``` | ||
ros2 run ur_client_library start_ursim.sh -m ur10e | ||
``` | ||
Remote control needs to be enabled: | ||
https://robodk.com/doc/en/Robots-Universal-Robots-How-enable-Remote-Control-URe.html | ||
|
||
## With motion_primitives_forward_controller | ||
**With URSim:** | ||
``` | ||
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 | ||
``` | ||
**With H-KA UR10e:** | ||
``` | ||
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 | ||
``` | ||
**(optional) switching control mode** | ||
``` | ||
ros2 control switch_controllers --activate motion_primitive_forward_controller --deactivate scaled_joint_trajectory_controller | ||
``` | ||
**Send motion primitives from python script** | ||
> [!WARNING] | ||
> Ensure that the robot in your configuration is able to execute these motion primitives without any risk of collision. | ||
``` | ||
ros2 run ur_robot_driver send_dummy_motion_primitives_ur10e.py | ||
``` | ||
During the execution of the motion primitives, the movement can be stopped by pressing the Enter key in the terminal. | ||
|
||
# TODOs/ Improvements | ||
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+95 KB
...otion_primitive_ur_driver/MotionPrimitiveExecutionWithHelperTypes_UR.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+896 KB
.../doc/motion_primitive_ur_driver/moprim_forward_controller_ur_demo_thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+365 KB
...ver/doc/motion_primitive_ur_driver/ros2_control_motion_primitives_ur.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for reference. These will have to be applied once everything is merged upstream.