Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 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
332f00d
copied controller hpp, cpp and plugin xml file and modified them to run
mathias31415 Jul 2, 2025
b1f1537
changed action to FollowJTrajAction, goal_received_callback() and go…
mathias31415 Jul 2, 2025
cf104d4
added std::atomic<bool> moprim_queue_write_enabled_
mathias31415 Jul 3, 2025
632ca1a
added std::atomic<bool> moprim_queue_write_enabled_
mathias31415 Jul 3, 2025
cb32821
added std::atomic moprim_queue_write_enabled_ to moprim_from_traj_con…
mathias31415 Jul 3, 2025
02ac151
added files from https://github.com/mathias31415/motion_primitives_fr…
mathias31415 Jul 3, 2025
9b8e261
working with hardcoded primitives in goal_accepted_callback()
mathias31415 Jul 3, 2025
9928983
integrated fk, not working yet
mathias31415 Jul 3, 2025
9b19863
PTP working, but code needs cleanup (FK for LIN still not working)
mathias31415 Jul 3, 2025
9143c71
fk call working
mathias31415 Jul 7, 2025
d3bd21c
LIN working
mathias31415 Jul 7, 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
8b40488
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Jul 9, 2025
5e955d3
pre-commit fixes
mathias31415 Jul 9, 2025
aa3112e
modified moprim_from_traj_controller according to moprim_forward_cont…
mathias31415 Jul 9, 2025
d2df2be
added param file for moprim_from_traj_controller
mathias31415 Jul 14, 2025
61c638e
motion_primitive_from_trajectory_controller: Added params for local_j…
mathias31415 Jul 14, 2025
b055205
calculate cart vel and acc from time_from_start
mathias31415 Jul 14, 2025
2f3e0ea
calculate joint vel and acc from time_from_start
mathias31415 Jul 14, 2025
b9261a3
Added publisher for planned_trajectory, planned_poses and motion_prim…
mathias31415 Jul 15, 2025
0e20eb3
added python script to record planned_trajectory, planned_poses and m…
mathias31415 Jul 15, 2025
5bd7e48
added python implementation to compare planned, reduced and executed …
mathias31415 Jul 15, 2025
e9ed2cd
added rdp for quaternion inbetween reduced positions
mathias31415 Jul 15, 2025
309e047
chagend prints from cout to RCLCPP
mathias31415 Jul 15, 2025
c6a7e66
changed "added primitive ..." print in approx_primitives_with_rdp to …
mathias31415 Jul 16, 2025
e88c216
moved fk_client_ initialisation from on_configure to on_activate
mathias31415 Jul 16, 2025
f290219
removed was_executing_ = false; in execution_status_==ExecutionState…
mathias31415 Jul 16, 2025
2f33e90
added filenames to compare.py
mathias31415 Jul 17, 2025
c1e08f8
pass full interface names to the controller (such as $(var tf_prefix)…
mathias31415 Jul 17, 2025
a97c200
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
db4d8d8
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Jul 18, 2025
b47e7ea
Moprim_from_traj_controller: pass full interface names to the control…
mathias31415 Jul 18, 2025
e4e37e7
Moprim_from_traj_controller: Wrapped rt_goal_handle_ in RealtimeThrea…
mathias31415 Jul 18, 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
d91a401
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Jul 21, 2025
bf53eda
argument_name --> name, argument_value --> value
mathias31415 Jul 21, 2025
fc46588
PTP: For velocity and acceleration, the maximum values from the joint…
mathias31415 Jul 21, 2025
e6601b0
added blend_radius_overwrite
mathias31415 Jul 21, 2025
2de2acd
moved evaluation stuff to https://github.com/mathias31415/evaluate_mo…
mathias31415 Jul 21, 2025
d247930
clamped blend radius between 0.01 and 0.1
mathias31415 Jul 22, 2025
f22f4a9
edited readme
mathias31415 Jul 28, 2025
fac1455
Merge branch 'master' into motion_primitive_forward_controller
christophfroehlich Jul 28, 2025
7f4d604
Merge branch 'ros-controls:master' into motion_primitives_from_trajec…
mathias31415 Jul 29, 2025
4cae3a9
pre-commit whitespace fixes
mathias31415 Jul 29, 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
c585773
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Jul 29, 2025
825cddc
added ExecutionState STOPPING
mathias31415 Jul 29, 2025
665079d
pre-commit fix
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
f181aa9
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Jul 31, 2025
cf96c59
reject trajectories when the controller isn't active
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
a763960
Merge branch 'motion_primitive_forward_controller' into motion_primit…
mathias31415 Aug 11, 2025
e400ffe
Implemented the interface names fixed in the controller.
mathias31415 Aug 11, 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
4 changes: 4 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ pid_controller
* The legacy ``antiwindup`` boolean and integral clamp parameters ``i_clamp_max``/``i_clamp_min`` have been deprecated in favor of the new ``antiwindup_strategy`` parameter. A ``tracking_time_constant`` parameter has also been introduced to configure the back-calculation strategy.
* A new ``error_deadband`` parameter stops integration when the error is within a specified range.
* PID state publisher can be turned off or on by using ``activate_state_publisher`` parameter. (`#1823 <https://github.com/ros-controls/ros2_controllers/pull/1823>`_).

motion_primitives_forward_controller
*******************************************
* 🚀 The motion_primitives_forward_controller was added 🎉 (`#1636 <https://github.com/ros-controls/ros2_controllers/pull/1636>`_).
157 changes: 157 additions & 0 deletions motion_primitives_forward_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
cmake_minimum_required(VERSION 3.10)
project(motion_primitives_forward_controller)

find_package(ros2_control_cmake REQUIRED)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_msgs
controller_interface
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
realtime_tools
std_srvs
moveit_msgs
geometry_msgs
tf2
tf2_geometry_msgs
)

find_package(ament_cmake REQUIRED)
find_package(generate_parameter_library REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
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
SHARED
src/motion_primitives_forward_controller.cpp
)
add_library(
motion_primitives_from_trajectory_controller
SHARED
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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_include_directories(motion_primitives_from_trajectory_controller PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_link_libraries(motion_primitives_forward_controller PUBLIC
motion_primitives_forward_controller_parameters
controller_interface::controller_interface
hardware_interface::hardware_interface
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
realtime_tools::realtime_tools
${control_msgs_TARGETS}
${std_srvs_TARGETS}
)
target_link_libraries(motion_primitives_from_trajectory_controller PUBLIC
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
${control_msgs_TARGETS}
${geometry_msgs_TARGETS}
${moveit_msgs_TARGETS}
${std_srvs_TARGETS}
tf2::tf2
tf2_geometry_msgs::tf2_geometry_msgs
)

target_compile_definitions(motion_primitives_forward_controller PRIVATE "MOTION_PRIMITIVES_FORWARD_CONTROLLER_BUILDING_DLL")

pluginlib_export_plugin_description_file(
controller_interface motion_primitives_forward_controller.xml)

pluginlib_export_plugin_description_file(
controller_interface motion_primitives_from_trajectory_controller.xml)

install(
TARGETS
motion_primitives_forward_controller
motion_primitives_forward_controller_parameters
EXPORT motion_primitives_forward_controller_targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(
TARGETS
motion_primitives_from_trajectory_controller
motion_primitives_from_trajectory_controller_parameters
EXPORT motion_primitives_from_trajectory_controller_targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
ament_export_targets(motion_primitives_forward_controller_targets)
ament_export_targets(motion_primitives_from_trajectory_controller_targets)

install(
DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)

ament_export_include_directories(
include
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}
)
ament_export_libraries(
motion_primitives_forward_controller
motion_primitives_from_trajectory_controller
)

ament_package()

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(controller_manager REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

ament_add_gmock(
test_load_motion_primitives_forward_controller
test/test_load_motion_primitives_forward_controller.cpp
)
target_link_libraries(test_load_motion_primitives_forward_controller
motion_primitives_forward_controller
controller_manager::controller_manager
ros2_control_test_assets::ros2_control_test_assets
)

add_rostest_with_parameters_gmock(
test_motion_primitives_forward_controller
test/test_motion_primitives_forward_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/motion_primitives_forward_controller_params.yaml
)
target_link_libraries(test_motion_primitives_forward_controller
motion_primitives_forward_controller
controller_interface::controller_interface
hardware_interface::hardware_interface
ros2_control_test_assets::ros2_control_test_assets
)
endif()
114 changes: 114 additions & 0 deletions motion_primitives_forward_controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
motion_primitive_controllers
==========================================

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


**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
Both controllers use the following command and state interfaces to transmit the motion primitives.

### 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.

A blending radius is also calculated automatically, based on the distance to neighboring target points, and clamped between 0.01 m and 0.1 m.

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/nsG4sW8BfLI)


## Demo-Video with KR3
[![KUKA demo video](doc/moprim_from_traj_controller_kuka_demo_thumbnail.png)](https://youtu.be/zaRkU-whyPM)
Loading