Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
98cd2e3
added COLCON_IGNORE to every controller folder to not build it every …
mathias31415 Apr 8, 2025
783d129
added motion_primitive_forward_controller from https://github.com/mat…
mathias31415 Apr 8, 2025
6ed1181
renamed motion_primitives_controller_pkg to motion_primitives_forward…
mathias31415 Apr 8, 2025
9074829
added functionallity to execute multiple primitives as a motion sequence
mathias31415 Apr 9, 2025
2cf7b09
Added new state interface ready_for_new_primitive to indicate whether…
mathias31415 Apr 9, 2025
c09d1fd
removed case 33 block with hardcoded motion sequence (was only for te…
mathias31415 Apr 9, 2025
f4abcbd
removed mail
mathias31415 Apr 10, 2025
79e47be
added command_mutex_
mathias31415 Apr 10, 2025
316ad54
edited readme
mathias31415 Apr 10, 2025
28adf54
changed image in readme to white background
mathias31415 Apr 11, 2025
e28554d
edited Related packages/ repos in readme
mathias31415 Apr 11, 2025
c451fb4
added/ modified copyright headers
mathias31415 Apr 11, 2025
188f8b5
removed LICENSE file
mathias31415 Apr 24, 2025
93cc787
removed repos files
mathias31415 Apr 24, 2025
1122a31
changed license from BSD-3-Clause to Apache License 2.0
mathias31415 Apr 24, 2025
af63eab
added email to package.xml
mathias31415 Apr 24, 2025
3f3881f
changed version to fit the rest of the repo, added maintainers and ur…
mathias31415 Apr 24, 2025
ce8b937
removed .gitignore (was not supposed to be pushed to the repo)
mathias31415 Apr 24, 2025
92ee810
removed visibility control
mathias31415 Apr 24, 2025
bce1031
removed/ changed license headers from template files
mathias31415 Apr 30, 2025
82786cb
Merge branch 'master' into motion_primitive_forward_controller
bmagyar May 2, 2025
ae083e7
removed license header from motion_primitives_forward_controller.yaml
mathias31415 May 5, 2025
487e88a
changed license in readme to apache 2.0
mathias31415 May 5, 2025
e0d87c6
uncommented test_motion_primitives_forward_controller
mathias31415 May 5, 2025
9fa58b4
changed msg_queue_ form private to protected to be accessible in tests
mathias31415 May 5, 2025
3eb44c2
changed test_motion_primitives_forward_controller implementation from…
mathias31415 May 5, 2025
d9d4c67
uncommented test_motion_primitives_forward_controller_preceeding impl…
mathias31415 May 5, 2025
e76a8d0
changed test_motion_primitives_forward_controller_preceeding implemen…
mathias31415 May 5, 2025
11bec4d
moved reset_controller_reference_msg into motion_primitives_forward_c…
mathias31415 May 5, 2025
6c98434
changed get_value() to get_optional()
mathias31415 May 5, 2025
d2ef095
cleanup on comments and commented code
mathias31415 May 5, 2025
7c4f167
clarified motion primitive publishing to ~/reference topic
mathias31415 May 5, 2025
59ecb5b
pre-commit fixes
mathias31415 May 6, 2025
a2eaaea
added ExecutionState STOPPED and MotionType RESET_STOP
mathias31415 May 8, 2025
558de38
discard new commands while robot is stopped
mathias31415 May 12, 2025
29356d5
added missing test_depend's to package.xml
mathias31415 May 21, 2025
48dd4f1
moved test dependencies to if(BUILD_TESTING) block in CMakeLists.txt
mathias31415 May 21, 2025
c96da97
changed reference topic to action
mathias31415 Jun 5, 2025
53147b9
modified tests for action based controller
mathias31415 Jun 5, 2025
7a8bcb2
updated readme
mathias31415 Jun 5, 2025
72fa44f
Update motion_primitives_forward_controller/CMakeLists.txt
mathias31415 Jun 26, 2025
e670fdd
removed ament_target_dependencies from CMakeLists.txt
mathias31415 Jun 26, 2025
a49cbb5
reference the final package destinations in redme and added shematic …
mathias31415 Jun 26, 2025
51b7b0a
Removed STATE_MY_ITFS and CMD_MY_ITFS. References to command and stat…
mathias31415 Jun 26, 2025
123cdb1
removed static constexpr rmw_qos_profile_t rmw_qos_profile_services_h…
mathias31415 Jun 26, 2025
cb2e1d6
changed ExecutionState, MotionType and ReadyForNewPrimitive to enum
mathias31415 Jun 26, 2025
f19e43e
removed validate_motion_primitives_forward_controller_parameters.hpp
mathias31415 Jun 30, 2025
06ba279
Changed some RCLCPP_INFO prints to _DEBUG to reduce output
mathias31415 Jun 30, 2025
cd95fde
renamed robot_stopped_ to robot_stop_requested_ and changed it from b…
mathias31415 Jun 30, 2025
14adc0e
removed queue_size_ parameter
mathias31415 Jun 30, 2025
c47834c
wrapped moprim_queue_.push with start and end marker into a lambda
mathias31415 Jun 30, 2025
1e2691a
Moved functionallity to cancle movement from goal_cancelled_callback(…
mathias31415 Jun 30, 2025
5e95340
removed execute_goal() in extra thread. Integrated it into goal_accep…
mathias31415 Jun 30, 2025
55a59a3
updated action draw.io
mathias31415 Jun 30, 2025
d1b772c
Merge branch 'ros-controls:master' into motion_primitive_forward_cont…
mathias31415 Jun 30, 2025
bf3d2f6
changed version to match the other controllers
mathias31415 Jun 30, 2025
fddc824
removed name parameter for the moprim controller
mathias31415 Jun 30, 2025
f366f46
Merge branch 'ros-controls:master' into motion_primitive_forward_cont…
mathias31415 Jul 2, 2025
632ca1a
added std::atomic<bool> moprim_queue_write_enabled_
mathias31415 Jul 3, 2025
4a96de5
changed fprintf to RCLCPP_ERROR
mathias31415 Jul 7, 2025
40d78fc
changed moprim_queue_ from std::queue to realtime_tools::LockFreeSPSC…
mathias31415 Jul 7, 2025
29d5a5e
using realtime_tools::RealtimeServerGoalHandle
mathias31415 Jul 8, 2025
c4bc089
Preallocate std::shared_ptr<MotionPrimitive> current_moprim_
mathias31415 Jul 8, 2025
01a24e8
using get_latest instead of while(pop)
mathias31415 Jul 8, 2025
42542e7
pushing primitives directly into the q instead of using shared pointers
mathias31415 Jul 8, 2025
a80e592
added check for remaining q-size before accepting the goal
mathias31415 Jul 8, 2025
a0744ab
Merge branch 'ros-controls:master' into motion_primitive_forward_cont…
mathias31415 Jul 8, 2025
b942ec5
Using MotionType from msg definition and MotionHelperType from enum i…
mathias31415 Jul 8, 2025
1669026
increased moprim_queue_ capacity to 1024
mathias31415 Jul 8, 2025
a4c1367
using ros-controls/control_msgs#228 instead of industrial_robot_motio…
mathias31415 Jul 8, 2025
371fb50
Add export and install for parameter library
mathias31415 Jul 9, 2025
a8bcee3
control_msgs in ros2_controllers.rolling.repos needs to get changed b…
mathias31415 Jul 9, 2025
c1e08f8
pass full interface names to the controller (such as $(var tf_prefix)…
mathias31415 Jul 17, 2025
5102a82
Wrapped rt_goal_handle_ in RealtimeThreadSafeBox and introduced std::…
mathias31415 Jul 17, 2025
3be4bac
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Jul 20, 2025
71d3b6b
Update ros2_controllers.rolling.repos
christophfroehlich Jul 20, 2025
e5457e4
pre-commit fix
mathias31415 Jul 21, 2025
2f205c1
modified tests for full cmd and state interface names
mathias31415 Jul 21, 2025
b2550d1
argument_name --> name, argument_value --> value
mathias31415 Jul 21, 2025
fac1455
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Jul 28, 2025
2502208
added ExecutionState STOPPING
mathias31415 Jul 29, 2025
7987abd
removed hka from example python script link
mathias31415 Jul 29, 2025
da7f3ec
removed test_motion_primitives_forward_controller_preceeding since it…
mathias31415 Jul 29, 2025
5ccfd11
added demo videos to readme
mathias31415 Jul 30, 2025
602776f
reject trajectories when the controller isn't active
mathias31415 Jul 30, 2025
a30396c
added missing include for lifecycle_msgs
mathias31415 Jul 31, 2025
fe8ace9
changed cmake_minimum_required to 3.10
mathias31415 Aug 11, 2025
6818ccb
modified compile options, ... to be consistent with other packages
mathias31415 Aug 11, 2025
ae0354f
removed license header in readme as it is global in the whole repo
mathias31415 Aug 11, 2025
3a00262
removed TODOs from readme
mathias31415 Aug 11, 2025
4260634
Merge branch 'ros-controls:master' into motion_primitive_forward_cont…
mathias31415 Aug 11, 2025
03d43c8
updated version
mathias31415 Aug 11, 2025
c187395
added description for interfaces and linked param files in readme
mathias31415 Aug 11, 2025
c69ac43
added motion_primitives_forward_controller to release_notes.rst
mathias31415 Aug 11, 2025
5a3d0bd
add extra braces to std::array initializers to fix -Werror=missing-br…
mathias31415 Aug 11, 2025
1c5e3d0
Implemented the interface names fixed in the controller.
mathias31415 Aug 11, 2025
8c02b08
renamed package and namespace to motion_primitives_controllers
mathias31415 Aug 13, 2025
b6b9b58
pre-commit fixes
mathias31415 Aug 13, 2025
9faa0ee
added base controllers (copies from forward_controller)
mathias31415 Aug 13, 2025
735c9ff
all functionallity of forward controller is in base controller --> fo…
mathias31415 Aug 13, 2025
798fad7
only common functionallity in base controller
mathias31415 Aug 13, 2025
ecdf354
added moprim_from_traj_controller from https://github.com/b-robotized…
mathias31415 Aug 13, 2025
bb1fc40
use base controller for moprim_from_traj_controller
mathias31415 Aug 13, 2025
0302034
/*time*/
mathias31415 Aug 13, 2025
570e118
Merge branch 'motion_primitive_forward_controller' into refactoring_t…
mathias31415 Aug 13, 2025
feaa557
/*time*/
mathias31415 Aug 13, 2025
d1aad7c
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 13, 2025
688c31b
edited readme
mathias31415 Aug 13, 2025
c387f43
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Aug 13, 2025
cb14501
added prefix to interface description in the readme
mathias31415 Aug 18, 2025
a348921
Merge branch 'motion_primitive_forward_controller' into refactoring_t…
mathias31415 Aug 18, 2025
7c7a8c9
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 18, 2025
7d24258
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Aug 18, 2025
f0d25e6
added rst file
mathias31415 Aug 18, 2025
23d39bf
fix end of file empty line
mathias31415 Aug 18, 2025
de30311
added doc8 '--ignore-path=motion_primitives_forward_controller/doc/us…
mathias31415 Aug 18, 2025
84aed98
Merge branch 'motion_primitive_forward_controller' into refactoring_t…
mathias31415 Aug 21, 2025
c0059d4
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 21, 2025
d7753f9
Fixed path for '--ignore-path=motion_primitives_controllers/doc/user…
mathias31415 Aug 21, 2025
5d1a59f
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 21, 2025
993e44f
Added parameter for blend_radius_percentage, blend_radius_lower_limit…
mathias31415 Aug 21, 2025
eb261ee
Move rst file to the same location as README
christophfroehlich Aug 24, 2025
43c0ea1
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Aug 24, 2025
f5e15d0
Merge branch 'motion_primitive_forward_controller' into refactoring_t…
mathias31415 Aug 25, 2025
f273bab
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 25, 2025
8aa7f8e
Merge branch 'master' into refactoring_to_moprim_base_controller
mathias31415 Aug 25, 2025
82eb823
removed motion_primitives_forward_controller_package (messed up merge)
mathias31415 Aug 25, 2025
0cddec6
Merge branch 'refactoring_to_moprim_base_controller' into moprim_from…
mathias31415 Aug 25, 2025
751cbcb
updated video links
mathias31415 Aug 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ repos:
args: [
'--max-line-length=100',
'--ignore=D001',
'--ignore-path=motion_primitives_forward_controller/userdoc.rst' # D000 fails with myst_parser
'--ignore-path=motion_primitives_controllers/userdoc.rst' # D000 fails with myst_parser
]
exclude: CHANGELOG\.rst$

Expand Down
3 changes: 1 addition & 2 deletions doc/controllers_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ The controllers are using `common hardware interface definitions`_, and may use
Position Controllers <../position_controllers/doc/userdoc.rst>
Velocity Controllers <../velocity_controllers/doc/userdoc.rst>
Gpio Command Controller <../gpio_controllers/doc/userdoc.rst>
Motion Primitive Controller <../motion_primitives_forward_controller/userdoc.rst>

Motion Primitive Controller <../motion_primitives_controllers/userdoc.rst>

Broadcasters
**********************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(motion_primitives_forward_controller)
project(motion_primitives_controllers)

find_package(ros2_control_cmake REQUIRED)
set_compiler_options()
Expand All @@ -14,6 +14,10 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
rclcpp_lifecycle
realtime_tools
std_srvs
moveit_msgs
geometry_msgs
tf2
tf2_geometry_msgs
)

find_package(ament_cmake REQUIRED)
Expand All @@ -25,59 +29,85 @@ endforeach()
generate_parameter_library(motion_primitives_forward_controller_parameters
src/motion_primitives_forward_controller_parameter.yaml
)
generate_parameter_library(motion_primitives_from_trajectory_controller_parameters
src/motion_primitives_from_trajectory_controller_parameter.yaml
)
add_library(
motion_primitives_forward_controller
${PROJECT_NAME}
SHARED
src/motion_primitives_base_controller.cpp
src/motion_primitives_forward_controller.cpp
src/motion_primitives_from_trajectory_controller.cpp
src/fk_client.cpp
src/rdp.cpp
src/approx_primitives_with_rdp.cpp
)
target_include_directories(motion_primitives_forward_controller PUBLIC
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_link_libraries(motion_primitives_forward_controller PUBLIC
target_link_libraries(${PROJECT_NAME} PUBLIC
motion_primitives_forward_controller_parameters
motion_primitives_from_trajectory_controller_parameters
controller_interface::controller_interface
hardware_interface::hardware_interface
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
realtime_tools::realtime_tools
tf2::tf2
tf2_geometry_msgs::tf2_geometry_msgs
${control_msgs_TARGETS}
${geometry_msgs_TARGETS}
${moveit_msgs_TARGETS}
${std_srvs_TARGETS}
)

target_compile_definitions(motion_primitives_forward_controller PRIVATE "MOTION_PRIMITIVES_FORWARD_CONTROLLER_BUILDING_DLL")
target_compile_definitions(${PROJECT_NAME} PRIVATE "MOTION_PRIMITIVES_CONTROLLERS_BUILDING_DLL")

pluginlib_export_plugin_description_file(
controller_interface motion_primitives_forward_controller.xml)
controller_interface controller_plugins.xml)

install(
TARGETS
motion_primitives_forward_controller
motion_primitives_forward_controller_parameters
EXPORT motion_primitives_forward_controller_targets
RUNTIME DESTINATION bin
TARGETS motion_primitives_forward_controller_parameters
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)


install(
DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
TARGETS motion_primitives_from_trajectory_controller_parameters
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
ament_export_targets(motion_primitives_forward_controller_targets HAS_LIBRARY_TARGET)

ament_export_include_directories(
include
install(TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}

install(DIRECTORY include/
DESTINATION include
)

install(FILES controller_plugins.xml
DESTINATION share/${PROJECT_NAME}
)

ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})

ament_export_libraries(
motion_primitives_forward_controller
${PROJECT_NAME}
)

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_package()

if(BUILD_TESTING)
Expand All @@ -91,7 +121,7 @@ if(BUILD_TESTING)
test/test_load_motion_primitives_forward_controller.cpp
)
target_link_libraries(test_load_motion_primitives_forward_controller
motion_primitives_forward_controller
${PROJECT_NAME}
controller_manager::controller_manager
ros2_control_test_assets::ros2_control_test_assets
)
Expand All @@ -102,7 +132,7 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/test/motion_primitives_forward_controller_params.yaml
)
target_link_libraries(test_motion_primitives_forward_controller
motion_primitives_forward_controller
${PROJECT_NAME}
controller_interface::controller_interface
hardware_interface::hardware_interface
ros2_control_test_assets::ros2_control_test_assets
Expand Down
121 changes: 121 additions & 0 deletions motion_primitives_controllers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
motion_primitive_controllers
==========================================

Package to control robots using motion primitives like LINEAR_JOINT (PTP/ MOVEJ), LINEAR_CARTESIAN (LIN/ MOVEL) and CIRCULAR_CARTESIAN (CIRC/ MOVEC)

> [!WARNING]
> There is no guarantee that the motion defined by the motion primitive will actually be executed exactly as planned. In particular, for motions in Cartesian space such as LIN primitives, it is not necessarily ensured that the robot will execute the motion exactly in that way, since the inverse kinematics is not always unique.

**This package contains two controllers:**
1. [motion_primitives_forward_controller](#moprim_forward_controller)
2. [motion_primitives_from_trajectory_controller](#moprim_from_traj_controller)

<a name="moprim_forward_controller"/>

## Command and State Interfaces
TBoth controllers use the following command and state interfaces to transmit the motion primitives. All interfaces use the naming scheme `tf_prefix_ + "motion_primitive/<interface name>"` where the `tf_prefix` is provided to the controller as a parameter.

### 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`.
- `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
- `STOPPING`: The hardware interface has received the `STOP_MOTION` command, but the robot has not yet come to a stop.
- `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


## Parameters
These controllers use the [`generate_parameter_library`](https://github.com/PickNikRobotics/generate_parameter_library) to handle their parameters.

For the **motion_primitives_forward_controller**, the [parameter definition file located in the src folder](https://github.com/ros-controls/ros2_controllers/blob/master/motion_primitives_forward_controller/src/motion_primitives_forward_controller_parameter.yaml) contains descriptions for all the parameters used by the controller. An example parameter file can be found in [the test directory](https://github.com/ros-controls/ros2_controllers/blob/master/motion_primitives_forward_controller/test/motion_primitives_forward_controller_params.yaml).

For the **motion_primitives_from_trajectory_controller**, the [parameter definition file located in the src folder](https://github.com/ros-controls/ros2_controllers/blob/master/motion_primitives_forward_controller_parameter/src/motion_primitives_from_trajectory_controller_parameter.yaml) contains descriptions for all the parameters used by the controller. An example parameter file can be found in [the test directory](https://github.com/ros-controls/ros2_controllers/blob/master/motion_primitives_forward_controller_parameter/test/motion_primitives_from_trajectory_controller_params.yaml).


# motion_primitives_forward_controller
This controller provides an interface for sending motion primitives to an industrial robot controller using the `ExecuteMotionPrimitiveSequence.action` action from [control_msgs](https://github.com/ros-controls/control_msgs/blob/motion_primitives/control_msgs/action/ExecuteMotionPrimitiveSequence.action). The controller receives the primitives via the action interface and forwards them through command interfaces to the robot-specific hardware interface. Currently, hardware interfaces for [Universal Robots](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver) and [KUKA Robots](https://github.com/b-robotized-forks/kuka_experimental/tree/motion_primitive_kuka_driver) are implemented.

- Supported motion primitives:
- `LINEAR_JOINT`
- `LINEAR_CARTESIAN`
- `CIRCULAR_CARTESIAN`

If multiple motion primitives are passed to the controller via the action, the controller forwards them to the hardware interface as a sequence. To do this, it first sends `MOTION_SEQUENCE_START`, followed by each individual primitive, and finally `MOTION_SEQUENCE_END`. All primitives between these two markers will be executed as a single, continuous sequence. This allows seamless transitions (blending) between primitives.

The action interface also allows stopping the current execution of motion primitives. When a stop request is received, the controller sends `STOP_MOTION` to the hardware interface, which then halts the robot's movement. Once the controller receives confirmation that the robot has stopped, it sends `RESET_STOP` to the hardware interface. After that, new commands can be sent.

![Action Image](doc/Moprim_Controller_ExecuteMotion_Action.drawio.png)

This can be done, for example, via a Python script as demonstrated in the [`example python script`](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/blob/main/ur_robot_driver/examples/send_dummy_motion_primitives_ur10e.py) in the `Universal_Robots_ROS2_Driver` package.

## Architecture Overview
Architecture for a UR robot with [`Universal_Robots_ROS2_Driver` in motion primitives mode](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver).

![UR Robot Architecture](doc/ros2_control_motion_primitives_ur.drawio.png)

Architecture for a KUKA robot with [`kuka_eki_motion_primitives_hw_interface`](https://github.com/b-robotized-forks/kuka_experimental/tree/motion_primitive_kuka_driver/kuka_eki_motion_primitives_hw_interface).

![KUKA Robot Architecture](doc/ros2_control_motion_primitives_kuka.drawio.png)

## Demo-Video with UR10e
[![UR demo video](doc/moprim_forward_controller_ur_demo_thumbnail.png)](https://youtu.be/SKz6LFvJmhQ)

## Demo-Video with KR3
[![KUKA demo video](doc/moprim_forward_controller_kuka_demo_thumbnail.png)](https://youtu.be/_BWCO36j9bg)

<a name="moprim_from_traj_controller"/>

# motion_primitives_from_trajectory_controller

The `motion_primitives_from_trajectory_controller` builds on the same architecture as the `motion_primitives_forward_controller` and uses the same command and state interfaces, making it compatible with the same hardware interfaces. However, instead of receiving motion primitives directly, it takes a `FollowJointTrajectory` action as input and approximates the trajectory using either `PTP` (`LINEAR_JOINT`) or `LIN` (`LINEAR_CARTESIAN`) motion primitives.

The approximation mode can be selected via the `approximate_mode` parameter, with options `"RDP_PTP"` or `"RDP_LIN"`, using the Ramer-Douglas-Peucker algorithm to reduce the trajectory points. Tolerances for the approximation are defined by:
- `epsilon_joint_angle` for PTP (in radians)
- `epsilon_cart_position` (in meters) and `epsilon_cart_angle` (in radians) for LIN

The `use_time_not_vel_and_acc` parameter determines whether motion duration is calculated based on time stamps or if velocity and acceleration values are used instead. For PTP primitives, joint velocity and acceleration are taken as the maximum values from the original trajectory. For LIN primitives, Cartesian velocity and acceleration are estimated numerically from the end-effector path.

The blend radius is automatically computed based on the smaller of the distances to the previous and next target points, scaled by a user-configurable blend_radius_percentage. The resulting value is then clamped between a lower and upper limit, specified by blend_radius_lower_clamp and blend_radius_upper_clamp.
All three parameters can be configured by the user:
- blend_radius_percentage (default: 0.1) – relative scale factor applied to the smaller neighboring distance
- blend_radius_lower_clamp (default: 0.01 m) – minimum allowable blend radius
- blend_radius_upper_clamp (default: 0.1 m) – maximum allowable blend radius

Alternatively, users can override velocity, acceleration, and blend radius values with the following parameters:
- PTP: `joint_vel_overwrite`, `joint_acc_overwrite`
- LIN: `cart_vel_overwrite`, `cart_acc_overwrite`
- Blend radius: `blend_radius_overwrite`

This controller enables executing collision-free trajectories planned with MoveIt using approximated motion primitives.

## Architecture Overview
Architecture for a UR robot with [`Universal_Robots_ROS2_Driver` in motion primitives mode](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver).

![UR Robot Architecture](doc/ros2_control_motion_primitives_from_traj_ur.drawio.png)

Architecture for a KUKA robot with [`kuka_eki_motion_primitives_hw_interface`](https://github.com/b-robotized-forks/kuka_experimental/tree/motion_primitive_kuka_driver/kuka_eki_motion_primitives_hw_interface).

![KUKA Robot Architecture](doc/ros2_control_motion_primitives_from_traj_kuka.drawio.png)

## Demo-Video with UR10e
[![UR demo video](doc/moprim_from_traj_controller_ur_demo_thumbnail.png)](https://youtu.be/Z_NCaSyE-KA)


## Demo-Video with KR3
[![KUKA demo video](doc/moprim_from_traj_controller_kuka_demo_thumbnail.png)](https://youtu.be/SvUU6PM1qRk)
14 changes: 14 additions & 0 deletions motion_primitives_controllers/controller_plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<library path="motion_primitives_controllers">
<class name="motion_primitives_controllers/MotionPrimitivesForwardController"
type="motion_primitives_controllers::MotionPrimitivesForwardController" base_class_type="controller_interface::ControllerInterface">
<description>
MotionPrimitivesForwardController ros2_control controller.
</description>
</class>
<class name="motion_primitives_controllers/MotionPrimitivesFromTrajectoryController"
type="motion_primitives_controllers::MotionPrimitivesFromTrajectoryController" base_class_type="controller_interface::ControllerInterface">
<description>
MotionPrimitivesFromTrajectoryController ros2_control controller.
</description>
</class>
</library>
Loading
Loading