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] Move PID to controller plugin #2

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
32d93ec
First draft of trajectory controllers plugins
christophfroehlich Dec 6, 2023
202d6ab
Move pid plugin to own package
christophfroehlich Dec 6, 2023
d148cee
Move base class to separate package
christophfroehlich Dec 6, 2023
1288610
Delete duplicate parameters
christophfroehlich Dec 6, 2023
319826e
Reactivate tests
christophfroehlich Dec 6, 2023
08dfd5a
Fix unused parameter warnings
christophfroehlich Dec 6, 2023
32f2f7f
Remove duplicate LICENSE file
christophfroehlich Dec 6, 2023
91b36b4
Rename jtc plugin package
christophfroehlich Dec 6, 2023
c165317
Add class_loader as persistent jtc-class member variable
christophfroehlich Dec 6, 2023
9ada3e1
Set PID parameters during tests only if plugin is loaded
christophfroehlich Dec 6, 2023
deda645
Add test to propery initialize PID plugin
christophfroehlich Dec 6, 2023
7c797fe
Use lifecycle_node inside trajectory_controller plugin
christophfroehlich Dec 6, 2023
fc78ece
Deactivate reconfigure of controller plugin
christophfroehlich Dec 6, 2023
d5a3b72
Compute gains on on_activate
christophfroehlich Dec 6, 2023
a9a2cbf
Let PID controller parse command joint names instead of joints
christophfroehlich Dec 6, 2023
74ae3b9
Rename pid_adapter variable and update gains with every new trajectory
christophfroehlich Dec 6, 2023
581f7b2
Split non-RT and RT methods
christophfroehlich Dec 6, 2023
a97511b
Use command joints instead of joints for gains structure
christophfroehlich Dec 6, 2023
81828bf
Add RT buffer to base class
christophfroehlich Dec 6, 2023
35ff9db
Add trajectory start time
christophfroehlich Dec 6, 2023
7055584
Rename variable
christophfroehlich Dec 6, 2023
dc0793c
Remove local vars and just call compute-commands with duration in tra…
christophfroehlich Dec 6, 2023
74af177
Update control law also for hold position
christophfroehlich Dec 6, 2023
5864456
Fix parameter updates and tests after rebase
christophfroehlich Dec 6, 2023
f30dc68
Export dependencies and update comments
christophfroehlich Dec 6, 2023
11b7d20
Rename updateGains method
christophfroehlich Dec 6, 2023
4927435
Call activate() of traj_contr_
christophfroehlich Dec 6, 2023
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 @@ -19,6 +19,7 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
rsl
tl_expected
trajectory_msgs
joint_trajectory_controller_plugins
)

find_package(ament_cmake REQUIRED)
Expand Down Expand Up @@ -104,4 +105,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 @@ -25,12 +25,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/visibility_control.h"
#include "pluginlib/class_loader.hpp"
#include "rclcpp/duration.hpp"
#include "rclcpp/subscription.hpp"
#include "rclcpp/time.hpp"
Expand All @@ -45,8 +42,11 @@
#include "trajectory_msgs/msg/joint_trajectory.hpp"
#include "trajectory_msgs/msg/joint_trajectory_point.hpp"

// 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/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 @@ -134,6 +134,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 @@ -162,11 +164,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 position error is wrapped around
std::vector<bool> joints_angle_wraparound_;
// reserved storage for result of the command when closed loop pid adapter is used
Expand Down Expand Up @@ -233,7 +237,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 @@ -285,8 +292,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
1 change: 1 addition & 0 deletions joint_trajectory_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<depend>rsl</depend>
<depend>tl_expected</depend>
<depend>trajectory_msgs</depend>
<depend>joint_trajectory_controller_plugins</depend>

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>controller_manager</test_depend>
Expand Down
Loading