Skip to content
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

[JTC] Proposal for custom "controller" plugins #885

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
67e55bf
First draft of trajectory controllers plugins
christophfroehlich Dec 6, 2023
82b5ce0
Move pid plugin to own package
christophfroehlich Dec 6, 2023
be6ed12
Move base class to separate package
christophfroehlich Dec 6, 2023
8174ba7
Delete duplicate parameters
christophfroehlich Dec 6, 2023
beeb779
Reactivate tests
christophfroehlich Dec 6, 2023
5fcb11d
Fix unused parameter warnings
christophfroehlich Dec 6, 2023
1e2dedd
Remove duplicate LICENSE file
christophfroehlich Dec 6, 2023
875f1a5
Rename jtc plugin package
christophfroehlich Dec 6, 2023
9e99582
Add class_loader as persistent jtc-class member variable
christophfroehlich Dec 6, 2023
63e630d
Set PID parameters during tests only if plugin is loaded
christophfroehlich Dec 6, 2023
2ef3cc4
Add test to propery initialize PID plugin
christophfroehlich Dec 6, 2023
45f7403
Use lifecycle_node inside trajectory_controller plugin
christophfroehlich Dec 6, 2023
0df086e
Deactivate reconfigure of controller plugin
christophfroehlich Dec 6, 2023
d559007
Compute gains on on_activate
christophfroehlich Dec 6, 2023
f80bb68
Let PID controller parse command joint names instead of joints
christophfroehlich Dec 6, 2023
0e76f19
Rename pid_adapter variable and update gains with every new trajectory
christophfroehlich Dec 6, 2023
7b01481
Split non-RT and RT methods
christophfroehlich Dec 6, 2023
9c2a3c4
Use command joints instead of joints for gains structure
christophfroehlich Dec 6, 2023
0da4883
Add RT buffer to base class
christophfroehlich Dec 6, 2023
b2adbcd
Add trajectory start time
christophfroehlich Dec 6, 2023
441b556
Rename variable
christophfroehlich Dec 6, 2023
408357c
Remove local vars and just call compute-commands with duration in tra…
christophfroehlich Dec 6, 2023
4e9814b
Update control law also for hold position
christophfroehlich Dec 6, 2023
89d63b6
Fix parameter updates and tests after rebase
christophfroehlich Dec 6, 2023
2bdc162
Export dependencies and update comments
christophfroehlich Dec 6, 2023
b9315a7
Rename updateGains method
christophfroehlich Dec 6, 2023
8b249df
Call activate() of traj_contr_
christophfroehlich Dec 6, 2023
04900a7
Merge branch 'master' into jtc/controller_plugin
christophfroehlich Dec 12, 2023
37639c4
Add missing )
christophfroehlich Dec 12, 2023
b9ad937
Parse traj_control gains before sending hold position
christophfroehlich Dec 14, 2023
f0db289
Merge branch 'master' into jtc/controller_plugin
christophfroehlich Jan 2, 2024
ce9386a
Merge branch 'master' into jtc/controller_plugin
christophfroehlich Jan 11, 2024
97c5a81
Fix wrong text in test
christophfroehlich Feb 14, 2024
9c0252f
Merge branch 'master' into jtc/controller_plugin
christophfroehlich Mar 7, 2024
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: 2 additions & 0 deletions joint_trajectory_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
generate_parameter_library
hardware_interface
joint_trajectory_controller_plugins
pluginlib
rclcpp
rclcpp_lifecycle
Expand Down Expand Up @@ -107,4 +108,5 @@ install(TARGETS

ament_export_targets(export_joint_trajectory_controller HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
#include "control_msgs/action/follow_joint_trajectory.hpp"
#include "control_msgs/msg/joint_trajectory_controller_state.hpp"
#include "control_msgs/srv/query_trajectory_state.hpp"
#include "control_toolbox/pid.hpp"
#include "controller_interface/controller_interface.hpp"
#include "hardware_interface/types/hardware_interface_type_values.hpp"
#include "joint_trajectory_controller/interpolation_methods.hpp"
#include "joint_trajectory_controller/tolerances.hpp"
#include "joint_trajectory_controller/trajectory.hpp"
#include "joint_trajectory_controller/visibility_control.h"
#include "pluginlib/class_loader.hpp"
#include "rclcpp/duration.hpp"
#include "rclcpp/subscription.hpp"
#include "rclcpp/time.hpp"
Expand All @@ -45,8 +41,12 @@
#include "trajectory_msgs/msg/joint_trajectory_point.hpp"
#include "urdf/model.h"

// auto-generated by generate_parameter_library
#include "joint_trajectory_controller_parameters.hpp"
#include "joint_trajectory_controller/interpolation_methods.hpp"
#include "joint_trajectory_controller/tolerances.hpp"
#include "joint_trajectory_controller/trajectory.hpp"
#include "joint_trajectory_controller/visibility_control.h"
#include "joint_trajectory_controller_parameters.hpp" // auto-generated by generate_parameter_library
#include "joint_trajectory_controller_plugins/trajectory_controller_base.hpp"

using namespace std::chrono_literals; // NOLINT

Expand Down Expand Up @@ -123,6 +123,8 @@ class JointTrajectoryController : public controller_interface::ControllerInterfa

// Storing command joint names for interfaces
std::vector<std::string> command_joint_names_;
// TODO(anyone) remove this if there is another way to lock command_joints parameter
rclcpp_lifecycle::LifecycleNode::PreSetParametersCallbackHandle::SharedPtr lock_cmd_joint_names;

// Parameters from ROS for joint_trajectory_controller
std::shared_ptr<ParamListener> param_listener_;
Expand Down Expand Up @@ -151,11 +153,13 @@ class JointTrajectoryController : public controller_interface::ControllerInterfa
bool has_effort_command_interface_ = false;

/// If true, a velocity feedforward term plus corrective PID term is used
bool use_closed_loop_pid_adapter_ = false;
using PidPtr = std::shared_ptr<control_toolbox::Pid>;
std::vector<PidPtr> pids_;
// Feed-forward velocity weight factor when calculating closed loop pid adapter's command
std::vector<double> ff_velocity_scale_;
bool use_external_control_law_ = false;
// class loader for actual trajectory controller
std::shared_ptr<
pluginlib::ClassLoader<joint_trajectory_controller_plugins::TrajectoryControllerBase>>
traj_controller_loader_;
// The actual trajectory controller
std::shared_ptr<joint_trajectory_controller_plugins::TrajectoryControllerBase> traj_contr_;
// Configuration for every joint if it wraps around (ie. is continuous, position error is
// normalized)
std::vector<bool> joints_angle_wraparound_;
Expand Down Expand Up @@ -237,7 +241,10 @@ class JointTrajectoryController : public controller_interface::ControllerInterfa
JOINT_TRAJECTORY_CONTROLLER_PUBLIC
bool validate_trajectory_msg(const trajectory_msgs::msg::JointTrajectory & trajectory) const;
JOINT_TRAJECTORY_CONTROLLER_PUBLIC
void add_new_trajectory_msg(
void add_new_trajectory_msg_nonRT(
const std::shared_ptr<trajectory_msgs::msg::JointTrajectory> & traj_msg);
JOINT_TRAJECTORY_CONTROLLER_PUBLIC
void add_new_trajectory_msg_RT(
const std::shared_ptr<trajectory_msgs::msg::JointTrajectory> & traj_msg);
JOINT_TRAJECTORY_CONTROLLER_PUBLIC
bool validate_trajectory_point_field(
Expand Down Expand Up @@ -288,8 +295,6 @@ class JointTrajectoryController : public controller_interface::ControllerInterfa
std::shared_ptr<control_msgs::srv::QueryTrajectoryState::Response> response);

private:
void update_pids();

bool contains_interface_type(
const std::vector<std::string> & interface_type_list, const std::string & interface_type);

Expand Down
5 changes: 3 additions & 2 deletions joint_trajectory_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

<depend>angles</depend>
<depend>backward_ros</depend>
<depend>controller_interface</depend>
<depend>control_msgs</depend>
<depend>control_toolbox</depend>
<depend>controller_interface</depend>
<depend>generate_parameter_library</depend>
<depend>hardware_interface</depend>
<depend>joint_trajectory_controller_plugins</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rclcpp</depend>
<depend>realtime_tools</depend>
<depend>rsl</depend>
<depend>tl_expected</depend>
Expand Down
Loading
Loading