Skip to content

Commit dfd39d5

Browse files
committed
fix ci errors and pr comments
1 parent 9a701d5 commit dfd39d5

File tree

6 files changed

+53
-30
lines changed

6 files changed

+53
-30
lines changed

auv_control_msgs/action/FollowEndEffectorTrajectory.action

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
# The end effector trajectory to follow.
2+
#
3+
# The trajectory header stamp is used to set the trajectory start time. This can be
4+
# set to zero to indicate that the controller should start following the trajectory
5+
# now.
16
auv_control_msgs/EndEffectorTrajectory trajectory
27

8+
# The maximum error that the controller is allowed when following the trajectory.
9+
# When this is set to 0, the tolerance will not be applied during control.
310
float64 path_tolerance
411

12+
# The maximum terminal error that the controller is allowed.
13+
# When this is set to 0, the tolerance will not affect the success of the action.
514
float64 goal_tolerance
615

716
---
@@ -12,10 +21,20 @@ int32 OLD_HEADER_TIMESTAMP = -2
1221
int32 PATH_TOLERANCE_VIOLATED = -3
1322
int32 GOAL_TOLERANCE_VIOLATED = -4
1423

24+
# A human-readable error description.
1525
string error_string
1626

1727
---
1828
std_msgs/Header header
29+
30+
# The reference pose for the controller at the current time instance.
31+
# This is distinct from the sample, which is retrieved at the next time
32+
# instance.
1933
geometry_msgs/Pose desired
34+
35+
# The current end effector state.
2036
geometry_msgs/Pose actual
37+
38+
# The squared Euclidean norm of the geodesic distance between the desired
39+
# and actual states.
2140
float64 error
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The sequence of end effector poses.
22
geometry_msgs/Pose point
33

4-
# The duration of the trajectory.
4+
# The time that this point should be reached, measured from the start of the trajectory.
55
builtin_interfaces/Duration time_from_start

end_effector_trajectory_controller/include/end_effector_trajectory_controller/end_effector_trajectory_controller.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ class EndEffectorTrajectoryController : public controller_interface::ControllerI
8888
// the end effector trajectories can be set using either the topic or action server
8989
// the action server is preferred and easier to integrate into state-machines/behavior trees, but can be a bit
9090
// cumbersome to interface with. on the other hand, the topic interface is easier to use, but doesn't integrate
91-
// well with high-level coordination
91+
// well with high-level coordinators
9292
realtime_tools::RealtimeBuffer<Trajectory> rt_trajectory_;
9393
std::shared_ptr<rclcpp::Subscription<auv_control_msgs::msg::EndEffectorTrajectory>> trajectory_sub_;
9494

95-
using FollowTrajectoryAction = auv_control_msgs::action::FollowEndEffectorTrajectory;
96-
using RealtimeGoalHandle = realtime_tools::RealtimeServerGoalHandle<FollowTrajectoryAction>;
95+
using FollowTrajectory = auv_control_msgs::action::FollowEndEffectorTrajectory;
96+
using RealtimeGoalHandle = realtime_tools::RealtimeServerGoalHandle<FollowTrajectory>;
9797
using RealtimeGoalHandlePtr = std::shared_ptr<RealtimeGoalHandle>;
9898
using RealtimeGoalHandleBuffer = realtime_tools::RealtimeBuffer<RealtimeGoalHandlePtr>;
9999

100-
std::shared_ptr<rclcpp_action::Server<FollowTrajectoryAction>> action_server_;
100+
std::shared_ptr<rclcpp_action::Server<FollowTrajectory>> action_server_;
101101
RealtimeGoalHandleBuffer rt_active_goal_;
102102
realtime_tools::RealtimeBuffer<bool> rt_goal_in_progress_;
103103
std::shared_ptr<rclcpp::TimerBase> goal_handle_timer_;
@@ -113,6 +113,8 @@ class EndEffectorTrajectoryController : public controller_interface::ControllerI
113113
end_effector_trajectory_controller::Params params_;
114114

115115
// error tolerances
116+
// the default tolerances are extracted from the parameters and applied when the action interface is not used
117+
// if the action interface is being used, then the tolerances set in the goal are applied
116118
double default_path_tolerance_, default_goal_tolerance_;
117119
realtime_tools::RealtimeBuffer<double> rt_goal_tolerance_, rt_path_tolerance_;
118120

end_effector_trajectory_controller/include/end_effector_trajectory_controller/trajectory.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,23 @@ class Trajectory
4848
Trajectory(const auv_control_msgs::msg::EndEffectorTrajectory & trajectory, const geometry_msgs::msg::Pose & state);
4949

5050
/// Whether or not the trajectory is empty.
51-
auto empty() const -> bool;
51+
[[nodiscard]] auto empty() const -> bool;
5252

5353
/// Get the starting time of the trajectory.
54-
auto start_time() const -> rclcpp::Time;
54+
[[nodiscard]] auto start_time() const -> rclcpp::Time;
5555

5656
/// Get the ending time of the trajectory.
57-
auto end_time() const -> rclcpp::Time;
57+
[[nodiscard]] auto end_time() const -> rclcpp::Time;
5858

5959
/// Get the first point in the trajectory.
60-
auto start_point() const -> std::optional<geometry_msgs::msg::Pose>;
60+
[[nodiscard]] auto start_point() const -> std::optional<geometry_msgs::msg::Pose>;
6161

6262
/// Get the last point in the trajectory.
63-
auto end_point() const -> std::optional<geometry_msgs::msg::Pose>;
63+
[[nodiscard]] auto end_point() const -> std::optional<geometry_msgs::msg::Pose>;
6464

6565
/// Sample a point in the trajectory at the given time.
66-
auto sample(const rclcpp::Time & sample_time) const -> std::expected<geometry_msgs::msg::Pose, SampleError>;
66+
[[nodiscard]] auto sample(const rclcpp::Time & sample_time) const
67+
-> std::expected<geometry_msgs::msg::Pose, SampleError>;
6768

6869
/// Reset the initial end effector state and trajectory start time.
6970
auto reset_initial_state(const geometry_msgs::msg::Pose & state) -> void;

end_effector_trajectory_controller/src/end_effector_trajectory_controller.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ auto EndEffectorTrajectoryController::validate_trajectory(
107107
trajectory.header.stamp = get_node()->now();
108108
}
109109

110+
// NOLINTNEXTLINE(readability-use-anyofallof)
110111
for (const auto [p1, p2] : std::views::zip(trajectory.points, trajectory.points | std::views::drop(1))) {
111112
const rclcpp::Duration p1_start = p1.time_from_start;
112113
const rclcpp::Duration p2_start = p2.time_from_start;
@@ -160,8 +161,8 @@ auto EndEffectorTrajectoryController::on_configure(const rclcpp_lifecycle::State
160161
});
161162

162163
auto handle_goal =
163-
[this](const rclcpp_action::GoalUUID & /*uuid*/, std::shared_ptr<const FollowTrajectoryAction::Goal> goal) {
164-
RCLCPP_INFO(logger_, "Received new trajectory goal"); // NOLINT
164+
[this](const rclcpp_action::GoalUUID & /*uuid*/, std::shared_ptr<const FollowTrajectory::Goal> goal) { // NOLINT
165+
RCLCPP_INFO(logger_, "Received new trajectory goal"); // NOLINT
165166
if (get_lifecycle_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE) {
166167
RCLCPP_ERROR(logger_, "Can't accept new action goals. Controller is not running."); // NOLINT
167168
return rclcpp_action::GoalResponse::REJECT;
@@ -178,12 +179,12 @@ auto EndEffectorTrajectoryController::on_configure(const rclcpp_lifecycle::State
178179
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
179180
};
180181

181-
auto handle_cancel = [this](const std::shared_ptr<rclcpp_action::ServerGoalHandle<FollowTrajectoryAction>> gh) {
182-
RCLCPP_INFO(logger_, "Received cancel action goal"); // NOLINT
182+
auto handle_cancel = [this](const std::shared_ptr<rclcpp_action::ServerGoalHandle<FollowTrajectory>> gh) { // NOLINT
183+
RCLCPP_INFO(logger_, "Received cancel action goal"); // NOLINT
183184
const auto active_goal = *rt_active_goal_.readFromNonRT();
184185
if (active_goal && active_goal->gh_ == gh) {
185186
RCLCPP_INFO(logger_, "Canceling active goal"); // NOLINT
186-
auto action_result = std::make_shared<FollowTrajectoryAction::Result>();
187+
auto action_result = std::make_shared<FollowTrajectory::Result>();
187188
active_goal->setCanceled(action_result);
188189
rt_holding_position_.writeFromNonRT(true);
189190
rt_first_sample_.writeFromNonRT(true);
@@ -192,14 +193,14 @@ auto EndEffectorTrajectoryController::on_configure(const rclcpp_lifecycle::State
192193
return rclcpp_action::CancelResponse::ACCEPT;
193194
};
194195

195-
auto handle_accepted = [this](std::shared_ptr<rclcpp_action::ServerGoalHandle<FollowTrajectoryAction>> gh) {
196-
RCLCPP_INFO(logger_, "Received accepted action goal"); // NOLINT
196+
auto handle_accepted = [this](std::shared_ptr<rclcpp_action::ServerGoalHandle<FollowTrajectory>> gh) { // NOLINT
197+
RCLCPP_INFO(logger_, "Received accepted action goal"); // NOLINT
197198
rt_goal_in_progress_.writeFromNonRT(true);
198199
const auto active_goal = *rt_active_goal_.readFromNonRT();
199200
if (active_goal) {
200201
RCLCPP_INFO(logger_, "Canceling active goal"); // NOLINT
201-
auto action_result = std::make_shared<FollowTrajectoryAction::Result>();
202-
action_result->error_code = FollowTrajectoryAction::Result::INVALID_GOAL;
202+
auto action_result = std::make_shared<FollowTrajectory::Result>();
203+
action_result->error_code = FollowTrajectory::Result::INVALID_GOAL;
203204
action_result->error_string = "Current goal cancelled by a new incoming action.";
204205
active_goal->setCanceled(action_result);
205206
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
@@ -208,7 +209,7 @@ auto EndEffectorTrajectoryController::on_configure(const rclcpp_lifecycle::State
208209
rt_goal_tolerance_.writeFromNonRT(gh->get_goal()->goal_tolerance);
209210
rt_path_tolerance_.writeFromNonRT(gh->get_goal()->path_tolerance);
210211

211-
RealtimeGoalHandlePtr rt_gh = std::make_shared<RealtimeGoalHandle>(gh);
212+
const RealtimeGoalHandlePtr rt_gh = std::make_shared<RealtimeGoalHandle>(gh);
212213
rt_gh->execute();
213214
rt_active_goal_.writeFromNonRT(rt_gh);
214215

@@ -392,7 +393,7 @@ auto EndEffectorTrajectoryController::update(const rclcpp::Time & time, const rc
392393

393394
case SampleError::SAMPLE_TIME_AFTER_END: {
394395
const double goal_tolerance = *rt_goal_tolerance_.readFromRT();
395-
double goal_error = geodesic_error(trajectory->end_point().value(), end_effector_state);
396+
const double goal_error = geodesic_error(trajectory->end_point().value(), end_effector_state);
396397
RCLCPP_INFO(logger_, "Trajectory sample time is after trajectory end time."); // NOLINT
397398
if (goal_tolerance > 0.0) {
398399
if (goal_error > goal_tolerance) {
@@ -416,7 +417,7 @@ auto EndEffectorTrajectoryController::update(const rclcpp::Time & time, const rc
416417

417418
if (active_goal) {
418419
// write feedback to the action server
419-
auto feedback = std::make_shared<FollowTrajectoryAction::Feedback>();
420+
auto feedback = std::make_shared<FollowTrajectory::Feedback>();
420421
feedback->header.stamp = time;
421422
feedback->desired = reference_state;
422423
feedback->actual = end_effector_state;
@@ -425,20 +426,20 @@ auto EndEffectorTrajectoryController::update(const rclcpp::Time & time, const rc
425426

426427
// check terminal conditions
427428
if (goal_tolerance_exceeded) {
428-
auto action_result = std::make_shared<FollowTrajectoryAction::Result>();
429-
action_result->error_code = FollowTrajectoryAction::Result::PATH_TOLERANCE_VIOLATED;
429+
auto action_result = std::make_shared<FollowTrajectory::Result>();
430+
action_result->error_code = FollowTrajectory::Result::PATH_TOLERANCE_VIOLATED;
430431
action_result->error_string = "Trajectory execution aborted. Goal tolerance exceeded.";
431432
active_goal->setAborted(action_result);
432433
rt_holding_position_.writeFromNonRT(true);
433434
} else if (trajectory_suceeded) {
434-
auto action_result = std::make_shared<FollowTrajectoryAction::Result>();
435-
action_result->error_code = FollowTrajectoryAction::Result::SUCCESSFUL;
435+
auto action_result = std::make_shared<FollowTrajectory::Result>();
436+
action_result->error_code = FollowTrajectory::Result::SUCCESSFUL;
436437
action_result->error_string = "Trajectory execution completed successfully!";
437438
active_goal->setSucceeded(action_result);
438439
rt_holding_position_.writeFromNonRT(true);
439440
} else if (path_tolerance_exceeded) {
440-
auto action_result = std::make_shared<FollowTrajectoryAction::Result>();
441-
action_result->error_code = FollowTrajectoryAction::Result::PATH_TOLERANCE_VIOLATED;
441+
auto action_result = std::make_shared<FollowTrajectory::Result>();
442+
action_result->error_code = FollowTrajectory::Result::PATH_TOLERANCE_VIOLATED;
442443
action_result->error_string = "Trajectory execution aborted. Path tolerance exceeded.";
443444
active_goal->setAborted(action_result);
444445
rt_holding_position_.writeFromNonRT(true);

end_effector_trajectory_controller/src/trajectory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ auto interpolate(
9696
Trajectory::Trajectory(
9797
const auv_control_msgs::msg::EndEffectorTrajectory & trajectory,
9898
const geometry_msgs::msg::Pose & state)
99-
: points_(std::move(trajectory)),
99+
: points_(trajectory),
100100
initial_time_(static_cast<rclcpp::Time>(trajectory.header.stamp)),
101101
initial_state_(state)
102102
{

0 commit comments

Comments
 (0)