-
Notifications
You must be signed in to change notification settings - Fork 706
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
feat(motion_velocity_smoother): add force acceleration function #7180
Changes from all commits
34b3bf6
b8a1eb1
8e6f973
ca551be
85830a4
bfff4bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2021 Tier IV, Inc. | ||
Check notice on line 1 in planning/motion_velocity_smoother/src/motion_velocity_smoother_node.cpp
|
||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -38,6 +38,7 @@ | |
: Node("motion_velocity_smoother", node_options) | ||
{ | ||
using std::placeholders::_1; | ||
using std::placeholders::_2; | ||
|
||
// set common params | ||
const auto vehicle_info = vehicle_info_util::VehicleInfoUtil(*this).getVehicleInfo(); | ||
|
@@ -72,6 +73,13 @@ | |
"~/input/operation_mode_state", 1, | ||
[this](const OperationModeState::ConstSharedPtr msg) { operation_mode_ = *msg; }); | ||
|
||
srv_adjust_common_param = create_service<SetBool>( | ||
"~/adjust_common_param", std::bind(&MotionVelocitySmootherNode::onAdjustParam, this, _1, _2)); | ||
adjustParam = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this variable necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thought it might not be necessary to set the force acceleration parameter every time when the request is continuously true. The same applies when false is continuous. |
||
|
||
srv_slow_driving = create_service<SetBool>( | ||
"~/slow_driving", std::bind(&MotionVelocitySmootherNode::onSlow, this, _1, _2)); | ||
|
||
// parameter update | ||
set_param_res_ = this->add_on_set_parameters_callback( | ||
std::bind(&MotionVelocitySmootherNode::onParameter, this, _1)); | ||
|
@@ -189,6 +197,10 @@ | |
update_param("ego_nearest_dist_threshold", p.ego_nearest_dist_threshold); | ||
update_param("ego_nearest_yaw_threshold", p.ego_nearest_yaw_threshold); | ||
update_param_bool("plan_from_ego_speed_on_manual_mode", p.plan_from_ego_speed_on_manual_mode); | ||
|
||
update_param("adjusted_max_acceleration", p.adjusted_max_acceleration); | ||
update_param("adjusted_max_jerk", p.adjusted_max_jerk); | ||
update_param("adjusted_max_lateral_acceleration", p.adjusted_max_lateral_acceleration); | ||
Check warning on line 203 in planning/motion_velocity_smoother/src/motion_velocity_smoother_node.cpp
|
||
} | ||
|
||
{ | ||
|
@@ -308,6 +320,11 @@ | |
|
||
p.plan_from_ego_speed_on_manual_mode = | ||
declare_parameter<bool>("plan_from_ego_speed_on_manual_mode"); | ||
|
||
p.adjusted_max_acceleration = declare_parameter<double>("adjusted_max_acceleration"); | ||
p.adjusted_max_jerk = declare_parameter<double>("adjusted_max_jerk"); | ||
p.adjusted_max_lateral_acceleration = | ||
declare_parameter<double>("adjusted_max_lateral_acceleration"); | ||
} | ||
|
||
void MotionVelocitySmootherNode::publishTrajectory(const TrajectoryPoints & trajectory) const | ||
|
@@ -1100,6 +1117,41 @@ | |
return calcProjectedTrajectoryPoint(trajectory, current_odometry_ptr_->pose.pose); | ||
} | ||
|
||
void MotionVelocitySmootherNode::onAdjustParam( | ||
const std::shared_ptr<SetBool::Request> request, std::shared_ptr<SetBool::Response> response) | ||
{ | ||
bool success = true; | ||
|
||
if (request->data && !adjustParam) { | ||
smoother_->setMaxAccel(get_parameter("adjusted_max_acceleration").as_double()); | ||
smoother_->setMaxJerk(get_parameter("adjusted_max_jerk").as_double()); | ||
smoother_->setMaxLatAccel(get_parameter("adjusted_max_lateral_acceleration").as_double()); | ||
|
||
adjustParam = true; | ||
} else if (!request->data && adjustParam) { | ||
smoother_->setMaxAccel(get_parameter("normal.max_acc").as_double()); | ||
smoother_->setMaxJerk(get_parameter("normal.max_jerk").as_double()); | ||
smoother_->setMaxLatAccel(get_parameter("max_lateral_accel").as_double()); | ||
|
||
adjustParam = false; | ||
} | ||
std::string message = success ? "Operation completed successfully" : "Operation failed"; | ||
|
||
response->success = success; | ||
response->message = message; | ||
} | ||
|
||
void MotionVelocitySmootherNode::onSlow( | ||
const std::shared_ptr<SetBool::Request> request, std::shared_ptr<SetBool::Response> response) | ||
{ | ||
bool success = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to define the variable |
||
|
||
std::string message = request->data ? "Slow driving" : "Default"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add const |
||
|
||
response->success = success; | ||
response->message = message; | ||
} | ||
|
||
} // namespace motion_velocity_smoother | ||
|
||
#include "rclcpp_components/register_node_macro.hpp" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
_
at the last of the member variables' names.