Skip to content

Commit 489b0ca

Browse files
committed
add patch
Signed-off-by: wep21 <[email protected]>
1 parent 0621ca7 commit 489b0ca

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/src/scaled_joint_trajectory_controller.cpp b/src/scaled_joint_trajectory_controller.cpp
2+
index 4a6320fa..fd039fb9 100644
3+
--- a/src/scaled_joint_trajectory_controller.cpp
4+
+++ b/src/scaled_joint_trajectory_controller.cpp
5+
@@ -115,7 +115,7 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
6+
const auto current_trajectory_msg = current_trajectory_->get_trajectory_msg();
7+
auto new_external_msg = new_trajectory_msg_.readFromRT();
8+
// Discard, if a goal is pending but still not active (somewhere stuck in goal_handle_timer_)
9+
- if (current_trajectory_msg != *new_external_msg && (*(rt_has_pending_goal_.readFromRT()) && !active_goal) == false) {
10+
+ if (current_trajectory_msg != *new_external_msg && (rt_has_pending_goal_ && !active_goal) == false) {
11+
fill_partial_goal(*new_external_msg);
12+
sort_to_local_joint_order(*new_external_msg);
13+
// TODO(denis): Add here integration of position and velocity
14+
@@ -175,8 +175,7 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
15+
16+
// have we reached the end, are not holding position, and is a timeout configured?
17+
// Check independently of other tolerances
18+
- if (!before_last_point && *(rt_is_holding_.readFromRT()) == false && cmd_timeout_ > 0.0 &&
19+
- time_difference > cmd_timeout_) {
20+
+ if (!before_last_point && !rt_is_holding_ && cmd_timeout_ > 0.0 && time_difference > cmd_timeout_) {
21+
RCLCPP_WARN(logger, "Aborted due to command timeout");
22+
23+
new_trajectory_msg_.reset();
24+
@@ -190,13 +189,13 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
25+
// Always check the state tolerance on the first sample in case the first sample
26+
// is the last point
27+
// print output per default, goal will be aborted afterwards
28+
- if ((before_last_point || first_sample) && *(rt_is_holding_.readFromRT()) == false &&
29+
+ if ((before_last_point || first_sample) && !rt_is_holding_ &&
30+
!check_state_tolerance_per_joint(state_error_, index, active_tol->state_tolerance[index],
31+
true /* show_errors */)) {
32+
tolerance_violated_while_moving = true;
33+
}
34+
// past the final point, check that we end up inside goal tolerance
35+
- if (!before_last_point && *(rt_is_holding_.readFromRT()) == false &&
36+
+ if (!before_last_point && !rt_is_holding_ &&
37+
!check_state_tolerance_per_joint(state_error_, index, active_tol->goal_state_tolerance[index],
38+
false /* show_errors */)) {
39+
outside_goal_tolerance = true;
40+
@@ -277,7 +276,7 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
41+
// TODO(matthew-reynolds): Need a lock-free write here
42+
// See https://github.com/ros-controls/ros2_controllers/issues/168
43+
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
44+
- rt_has_pending_goal_.writeFromNonRT(false);
45+
+ rt_has_pending_goal_ = false;
46+
47+
RCLCPP_WARN(logger, "Aborted due to state tolerance violation");
48+
49+
@@ -293,7 +292,7 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
50+
// TODO(matthew-reynolds): Need a lock-free write here
51+
// See https://github.com/ros-controls/ros2_controllers/issues/168
52+
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
53+
- rt_has_pending_goal_.writeFromNonRT(false);
54+
+ rt_has_pending_goal_ = false;
55+
56+
RCLCPP_INFO(logger, "Goal reached, success!");
57+
58+
@@ -310,7 +309,7 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
59+
// TODO(matthew-reynolds): Need a lock-free write here
60+
// See https://github.com/ros-controls/ros2_controllers/issues/168
61+
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
62+
- rt_has_pending_goal_.writeFromNonRT(false);
63+
+ rt_has_pending_goal_ = false;
64+
65+
RCLCPP_WARN(logger, "%s", error_string.c_str());
66+
67+
@@ -318,13 +317,13 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
68+
new_trajectory_msg_.initRT(set_hold_position());
69+
}
70+
}
71+
- } else if (tolerance_violated_while_moving && *(rt_has_pending_goal_.readFromRT()) == false) {
72+
+ } else if (tolerance_violated_while_moving && !rt_has_pending_goal_) {
73+
// we need to ensure that there is no pending goal -> we get a race condition otherwise
74+
RCLCPP_ERROR(logger, "Holding position due to state tolerance violation");
75+
76+
new_trajectory_msg_.reset();
77+
new_trajectory_msg_.initRT(set_hold_position());
78+
- } else if (!before_last_point && !within_goal_time && *(rt_has_pending_goal_.readFromRT()) == false) {
79+
+ } else if (!before_last_point && !within_goal_time && !rt_has_pending_goal_) {
80+
RCLCPP_ERROR(logger, "Exceeded goal_time_tolerance: holding position...");
81+
82+
new_trajectory_msg_.reset();

0 commit comments

Comments
 (0)