25 trajectory_planning_msgs::msg::Trajectory tf_trajectory;
29 }
catch (tf2::TransformException& ex) {
30 RCLCPP_WARN(this->get_logger(),
"Transformation is not available. Init high-level instead. Ex: %s", ex.what());
35 std::vector<double> TIME, V, Y, A, THETA, DELTA;
36 for (
int i = 0; i < trajectory_planning_msgs::trajectory_access::getSamplePointSize(tf_trajectory); i++) {
37 TIME.push_back(trajectory_planning_msgs::trajectory_access::getT(tf_trajectory, i));
38 Y.push_back(trajectory_planning_msgs::trajectory_access::getY(tf_trajectory, i));
39 V.push_back(trajectory_planning_msgs::trajectory_access::getV(tf_trajectory, i));
40 A.push_back(trajectory_planning_msgs::trajectory_access::getA(tf_trajectory, i));
41 THETA.push_back(trajectory_planning_msgs::trajectory_access::getTheta(tf_trajectory, i));
42 DELTA.push_back(trajectory_planning_msgs::trajectory_access::getDeltaAck(tf_trajectory, i));
46 double v_tgt = 0.0, a_tgt = 0.0, y_tgt = 0.0, theta_tgt = 0.0, delta_tgt = 0.0;
47 double des_time = (rclcpp::Time(ego_data.header.stamp) - rclcpp::Time(tf_trajectory.header.stamp)).seconds();
49 if (!
linearInterpolation(TIME, V, des_time, v_tgt)) v_tgt = perception_msgs::object_access::getVelLon(ego_data);
50 if (!
linearInterpolation(TIME, A, des_time, a_tgt)) a_tgt = perception_msgs::object_access::getAccLon(ego_data);
53 delta_tgt = perception_msgs::object_access::getSteeringAngleAck(ego_data);
56 RCLCPP_DEBUG(this->get_logger(),
"y_tgt: %f, v_tgt: %f, a_tgt: %f, theta_tgt: %f, delta_tgt: %f", y_tgt, v_tgt, a_tgt,
57 theta_tgt, delta_tgt);
61 if (fabs(v_tgt - perception_msgs::object_access::getVelLon(ego_data)) >
bi_level_dV_ ||
62 fabs(a_tgt - perception_msgs::object_access::getAccLon(ego_data)) >
bi_level_dA_) {
63 RCLCPP_WARN(this->get_logger(),
"Lon reinit: v_tgt: %f, a_tgt: %f, ego_v: %f, ego_a: %f", v_tgt, a_tgt,
64 perception_msgs::object_access::getVelLon(ego_data), perception_msgs::object_access::getAccLon(ego_data));
65 v_tgt = perception_msgs::object_access::getVelLon(ego_data);
66 a_tgt = perception_msgs::object_access::getAccLon(ego_data);
70 RCLCPP_WARN(this->get_logger(),
"Lat reinit: y_tgt: %f, theta_tgt: %f", y_tgt, theta_tgt);
73 delta_tgt = perception_msgs::object_access::getSteeringAngleAck(ego_data);
74 }
else if (fabs(delta_tgt - perception_msgs::object_access::getSteeringAngleAck(ego_data)) >
bi_level_dDelta_ * M_PI / 180.0) {
75 RCLCPP_WARN(this->get_logger(),
"Delta reinit: delta_tgt: %f, ego_delta: %f", delta_tgt,
76 perception_msgs::object_access::getSteeringAngleAck(ego_data));
77 delta_tgt = perception_msgs::object_access::getSteeringAngleAck(ego_data);
80 std::vector<double> x_init(*
nlp_dims_->nx, 0.0);
86 x_init[5] = theta_tgt;
87 x_init[6] = delta_tgt;
102 for (
int i = 0; i <=
n_shots_; ++i) {
103 trajectory_planning_msgs::trajectory_access::setX(trajectory,
xtraj_[i * *
nlp_dims_->nx + 0], i);
104 trajectory_planning_msgs::trajectory_access::setY(trajectory,
xtraj_[i * *
nlp_dims_->nx + 1], i);
105 trajectory_planning_msgs::trajectory_access::setS(trajectory,
xtraj_[i * *
nlp_dims_->nx + 2], i);
106 trajectory_planning_msgs::trajectory_access::setV(trajectory,
xtraj_[i * *
nlp_dims_->nx + 3], i);
107 trajectory_planning_msgs::trajectory_access::setA(trajectory,
xtraj_[i * *
nlp_dims_->nx + 4], i);
108 trajectory_planning_msgs::trajectory_access::setTheta(trajectory,
xtraj_[i * *
nlp_dims_->nx + 5], i);
109 trajectory_planning_msgs::trajectory_access::setDeltaAck(trajectory,
xtraj_[i * *
nlp_dims_->nx + 6], i);
void declareAndLoadParameter(const std::string &name, T ¶m, const std::string &description, const bool add_to_auto_reconfigurable_params=true, const bool is_required=false, const bool read_only=false, const std::optional< double > &from_value=std::nullopt, const std::optional< double > &to_value=std::nullopt, const std::optional< double > &step_value=std::nullopt, const std::string &additional_constraints="")
Declares a ROS parameter, loads its value and optionally registers it for runtime updates.