Skip to content

Commit

Permalink
tmp modify for smoother
Browse files Browse the repository at this point in the history
Signed-off-by: Takamasa Horibe <[email protected]>
  • Loading branch information
TakaHoribe committed Jan 26, 2024
1 parent f0b8555 commit a360bd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "geometry_msgs/msg/accel_with_covariance_stamped.hpp"
#include "nav_msgs/msg/odometry.hpp"
#include "tier4_debug_msgs/msg/float32_stamped.hpp" // temporary
#include "tier4_debug_msgs/msg/bool_stamped.hpp" // temporary
#include "tier4_planning_msgs/msg/stop_speed_exceeded.hpp" // temporary
#include "tier4_planning_msgs/msg/velocity_limit.hpp" // temporary
#include "visualization_msgs/msg/marker_array.hpp"
Expand Down Expand Up @@ -89,6 +90,8 @@ class MotionVelocitySmootherNode : public rclcpp::Node
rclcpp::Subscription<Trajectory>::SharedPtr sub_current_trajectory_;
rclcpp::Subscription<VelocityLimit>::SharedPtr sub_external_velocity_limit_;
rclcpp::Subscription<OperationModeState>::SharedPtr sub_operation_mode_;
rclcpp::Subscription<tier4_debug_msgs::msg::BoolStamped>::SharedPtr sub_tmp_;
bool break_path_ = false;

Odometry::ConstSharedPtr current_odometry_ptr_; // current odometry
AccelWithCovarianceStamped::ConstSharedPtr current_acceleration_ptr_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ MotionVelocitySmootherNode::MotionVelocitySmootherNode(const rclcpp::NodeOptions
"~/input/operation_mode_state", 1,
[this](const OperationModeState::ConstSharedPtr msg) { operation_mode_ = *msg; });

sub_tmp_ = create_subscription<tier4_debug_msgs::msg::BoolStamped>(
"/tmp/break_path", 1,
[this](const tier4_debug_msgs::msg::BoolStamped::ConstSharedPtr msg) { break_path_ = msg->data; });

// parameter update
set_param_res_ = this->add_on_set_parameters_callback(
std::bind(&MotionVelocitySmootherNode::onParameter, this, _1));
Expand Down Expand Up @@ -501,8 +505,16 @@ void MotionVelocitySmootherNode::onCurrentTrajectory(const Trajectory::ConstShar
flipVelocity(output_resampled);
}

if (break_path_) {
const size_t closest = findNearestIndexFromEgo(output_resampled);
TrajectoryPoints clipped;
clipped.insert(clipped.end(), output_resampled.begin(), output_resampled.begin() + closest);
publishTrajectory(clipped);
} else {
publishTrajectory(output_resampled);
}

// publish message
publishTrajectory(output_resampled);

// publish debug message
publishStopDistance(output);
Expand Down

0 comments on commit a360bd0

Please sign in to comment.