@@ -38,6 +38,7 @@ MotionVelocitySmootherNode::MotionVelocitySmootherNode(const rclcpp::NodeOptions
38
38
: Node(" motion_velocity_smoother" , node_options)
39
39
{
40
40
using std::placeholders::_1;
41
+ using std::placeholders::_2;
41
42
42
43
// set common params
43
44
const auto vehicle_info = vehicle_info_util::VehicleInfoUtil (*this ).getVehicleInfo ();
@@ -72,6 +73,13 @@ MotionVelocitySmootherNode::MotionVelocitySmootherNode(const rclcpp::NodeOptions
72
73
" ~/input/operation_mode_state" , 1 ,
73
74
[this ](const OperationModeState::ConstSharedPtr msg) { operation_mode_ = *msg; });
74
75
76
+ srv_force_acceleration_ = create_service<SetBool>(
77
+ " ~/adjust_common_param" ,
78
+ std::bind (&MotionVelocitySmootherNode::onForceAcceleration, this , _1, _2));
79
+ srv_slow_driving_ = create_service<SetBool>(
80
+ " ~/slow_driving" , std::bind (&MotionVelocitySmootherNode::onSlowDriving, this , _1, _2));
81
+ force_acceleration_mode_ = false ;
82
+
75
83
// parameter update
76
84
set_param_res_ = this ->add_on_set_parameters_callback (
77
85
std::bind (&MotionVelocitySmootherNode::onParameter, this , _1));
@@ -189,6 +197,14 @@ rcl_interfaces::msg::SetParametersResult MotionVelocitySmootherNode::onParameter
189
197
update_param (" ego_nearest_dist_threshold" , p.ego_nearest_dist_threshold );
190
198
update_param (" ego_nearest_yaw_threshold" , p.ego_nearest_yaw_threshold );
191
199
update_param_bool (" plan_from_ego_speed_on_manual_mode" , p.plan_from_ego_speed_on_manual_mode );
200
+
201
+ update_param (" force_acceleration.max_acc" , p.force_acceleration_param .max_acceleration );
202
+ update_param (" force_acceleration.max_jerk" , p.force_acceleration_param .max_jerk );
203
+ update_param (
204
+ " force_acceleration.max_lateral_acc" , p.force_acceleration_param .max_lateral_acceleration );
205
+ update_param (" force_acceleration.engage_velocity" , p.force_acceleration_param .engage_velocity );
206
+ update_param (
207
+ " force_acceleration.engage_acceleration" , p.force_acceleration_param .engage_acceleration );
192
208
}
193
209
194
210
{
@@ -308,6 +324,16 @@ void MotionVelocitySmootherNode::initCommonParam()
308
324
309
325
p.plan_from_ego_speed_on_manual_mode =
310
326
declare_parameter<bool >(" plan_from_ego_speed_on_manual_mode" );
327
+
328
+ p.force_acceleration_param .max_acceleration =
329
+ declare_parameter<double >(" force_acceleration.max_acc" );
330
+ p.force_acceleration_param .max_jerk = declare_parameter<double >(" force_acceleration.max_jerk" );
331
+ p.force_acceleration_param .max_lateral_acceleration =
332
+ declare_parameter<double >(" force_acceleration.max_lateral_acc" );
333
+ p.force_acceleration_param .engage_velocity =
334
+ declare_parameter<double >(" force_acceleration.engage_velocity" );
335
+ p.force_acceleration_param .engage_acceleration =
336
+ declare_parameter<double >(" force_acceleration.engage_acceleration" );
311
337
}
312
338
313
339
void MotionVelocitySmootherNode::publishTrajectory (const TrajectoryPoints & trajectory) const
@@ -1100,6 +1126,47 @@ TrajectoryPoint MotionVelocitySmootherNode::calcProjectedTrajectoryPointFromEgo(
1100
1126
return calcProjectedTrajectoryPoint (trajectory, current_odometry_ptr_->pose .pose );
1101
1127
}
1102
1128
1129
+ void MotionVelocitySmootherNode::onForceAcceleration (
1130
+ const std::shared_ptr<SetBool::Request> request, std::shared_ptr<SetBool::Response> response)
1131
+ {
1132
+ std::string message = " default" ;
1133
+
1134
+ if (request->data && !force_acceleration_mode_) {
1135
+ RCLCPP_INFO (get_logger (), " Force acceleration is activated" );
1136
+ smoother_->setMaxAccel (get_parameter (" force_acceleration.max_acc" ).as_double ());
1137
+ smoother_->setMaxJerk (get_parameter (" force_acceleration.max_jerk" ).as_double ());
1138
+ smoother_->setMaxLatAccel (get_parameter (" force_acceleration.max_lateral_acc" ).as_double ());
1139
+ node_param_.engage_velocity = get_parameter (" force_acceleration.engage_velocity" ).as_double ();
1140
+ node_param_.engage_acceleration =
1141
+ get_parameter (" force_acceleration.engage_acceleration" ).as_double ();
1142
+
1143
+ force_acceleration_mode_ = true ;
1144
+ message = " Trigger force acceleration" ;
1145
+ } else if (!request->data && force_acceleration_mode_) {
1146
+ RCLCPP_INFO (get_logger (), " Force acceleration is deactivated" );
1147
+ smoother_->setMaxAccel (get_parameter (" normal.max_acc" ).as_double ());
1148
+ smoother_->setMaxJerk (get_parameter (" normal.max_jerk" ).as_double ());
1149
+ smoother_->setMaxLatAccel (get_parameter (" max_lateral_accel" ).as_double ());
1150
+
1151
+ node_param_.engage_velocity = get_parameter (" engage_velocity" ).as_double ();
1152
+ node_param_.engage_acceleration = get_parameter (" engage_acceleration" ).as_double ();
1153
+
1154
+ force_acceleration_mode_ = false ;
1155
+ message = " Trigger normal acceleration" ;
1156
+ }
1157
+
1158
+ response->success = true ;
1159
+ }
1160
+
1161
+ void MotionVelocitySmootherNode::onSlowDriving (
1162
+ const std::shared_ptr<SetBool::Request> request, std::shared_ptr<SetBool::Response> response)
1163
+ {
1164
+ const std::string message = request->data ? " Slow driving" : " Default" ;
1165
+
1166
+ response->success = true ;
1167
+ response->message = message;
1168
+ }
1169
+
1103
1170
} // namespace motion_velocity_smoother
1104
1171
1105
1172
#include " rclcpp_components/register_node_macro.hpp"
0 commit comments