Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 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
d957c75
Merge remote-tracking branch 'upstream/master' into moprim_from_traj_…
mathias31415 Sep 10, 2025
8fb3ba9
clean up
mathias31415 Sep 10, 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
24 changes: 24 additions & 0 deletions motion_primitives_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,25 +29,37 @@ 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(
${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(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
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}
)

Expand All @@ -58,6 +74,14 @@ install(
RUNTIME DESTINATION bin
)

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

install(TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
Expand Down
84 changes: 67 additions & 17 deletions motion_primitives_controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ motion_primitive_controllers

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

# Description
This project 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.
> [!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.

- 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.
**This package contains two controllers:**
1. [motion_primitives_forward_controller](#moprim_forward_controller)
2. [motion_primitives_from_trajectory_controller](#moprim_from_traj_controller)

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.
<a name="moprim_forward_controller"/>

## Command and State Interfaces
To transmit the motion primitives, the following command and state interfaces are required. All interfaces use the naming scheme `tf_prefix_ + "motion_primitive/<interface name>"` where the `tf_prefix` is provided to the controller as a parameter.
Both 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:
Expand All @@ -46,7 +39,23 @@ These interfaces are used to communicate the internal status of the hardware int
- `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

# Architecture Overview
# 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)
Expand All @@ -55,8 +64,49 @@ Architecture for a KUKA robot with [`kuka_eki_motion_primitives_hw_interface`](h

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

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

# Demo-Video with KR3
## 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)
6 changes: 6 additions & 0 deletions motion_primitives_controllers/controller_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2025, b»robotized
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Authors: Mathias Fuhrer

#ifndef MOTION_PRIMITIVES_CONTROLLERS__APPROX_PRIMITIVES_WITH_RDP_HPP_
#define MOTION_PRIMITIVES_CONTROLLERS__APPROX_PRIMITIVES_WITH_RDP_HPP_

#include <string>
#include <vector>
#include "control_msgs/msg/motion_argument.hpp"
#include "control_msgs/msg/motion_primitive.hpp"
#include "control_msgs/msg/motion_primitive_sequence.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "motion_primitives_controllers/rdp.hpp"

using MotionSequence = control_msgs::msg::MotionPrimitiveSequence;

namespace approx_primitives_with_rdp
{

struct PlannedTrajectoryPoint
{
double time_from_start;
std::vector<double> joint_positions;
geometry_msgs::msg::Pose pose;
};

// Approximate with LIN Primitives in Cartesian Space
MotionSequence approxLinPrimitivesWithRDP(
const std::vector<PlannedTrajectoryPoint> & trajectory, double epsilon_position,
double epsilon_angle, double cart_vel, double cart_acc, bool use_time_not_vel_and_acc = false,
double blend_overwrite = -1.0, double blend_scale = 0.1, double blend_lower_limit = 0.0,
double blend_upper_limit = 1.0);

// Approximate with PTP Primitives in Joint Space
MotionSequence approxPtpPrimitivesWithRDP(
const std::vector<PlannedTrajectoryPoint> & trajectory, double epsilon, double joint_vel,
double joint_acc, bool use_time_not_vel_and_acc = false, double blend_overwrite = -1.0,
double blend_scale = 0.1, double blend_lower_limit = 0.0, double blend_upper_limit = 1.0);

double calculateBlendRadius(
const rdp::Point & previous_point, const rdp::Point & current_point,
const rdp::Point & next_point, double blend_scale, double blend_lower_limit,
double blend_upper_limit);
} // namespace approx_primitives_with_rdp

#endif // MOTION_PRIMITIVES_CONTROLLERS__APPROX_PRIMITIVES_WITH_RDP_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2025, b»robotized
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Authors: Mathias Fuhrer

#ifndef MOTION_PRIMITIVES_CONTROLLERS__FK_CLIENT_HPP_
#define MOTION_PRIMITIVES_CONTROLLERS__FK_CLIENT_HPP_

#include <string>
#include <vector>

#include <geometry_msgs/msg/pose.hpp>
#include <moveit_msgs/srv/get_position_fk.hpp>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/joint_state.hpp>

class FKClient : public rclcpp::Node
{
public:
explicit FKClient(const std::string & node_name = "fk_client");

geometry_msgs::msg::Pose computeFK(
const std::vector<std::string> & joint_names, const std::vector<double> & joint_positions,
const std::string & from_frame, const std::string & to_link);

private:
rclcpp::Client<moveit_msgs::srv::GetPositionFK>::SharedPtr fk_client_;
};

#endif // MOTION_PRIMITIVES_CONTROLLERS__FK_CLIENT_HPP_
Loading
Loading