30 trajectory_planning_msgs::msg::Trajectory tf_trajectory;
34 }
catch (tf2::TransformException& ex) {
35 RCLCPP_WARN(this->get_logger(),
"Transformation is not available. Init high-level instead. Ex: %s", ex.what());
40 std::vector<double> TIME, V, Y, A, THETA, DELTA_FRONT, DELTA_REAR;
41 for (
int i = 0; i < trajectory_planning_msgs::trajectory_access::getSamplePointSize(tf_trajectory); i++) {
42 TIME.push_back(trajectory_planning_msgs::trajectory_access::getT(tf_trajectory, i));
43 Y.push_back(trajectory_planning_msgs::trajectory_access::getY(tf_trajectory, i));
44 V.push_back(trajectory_planning_msgs::trajectory_access::getV(tf_trajectory, i));
45 A.push_back(trajectory_planning_msgs::trajectory_access::getA(tf_trajectory, i));
46 THETA.push_back(trajectory_planning_msgs::trajectory_access::getTheta(tf_trajectory, i));
47 DELTA_FRONT.push_back(trajectory_planning_msgs::trajectory_access::getDeltaFront(tf_trajectory, i));
48 DELTA_REAR.push_back(trajectory_planning_msgs::trajectory_access::getDeltaRear(tf_trajectory, i));
52 double v_tgt = 0.0, a_tgt = 0.0, y_tgt = 0.0, theta_tgt = 0.0, delta_front_tgt = 0.0, delta_rear_tgt = 0.0;
53 double des_time = (rclcpp::Time(ego_data.header.stamp) - rclcpp::Time(tf_trajectory.header.stamp)).seconds();
56 if (!
linearInterpolation(TIME, V, des_time, v_tgt)) v_tgt = perception_msgs::object_access::getVelocityMagnitude(ego_data);
58 a_tgt =
projectVectorAonV(perception_msgs::object_access::getAcceleration(ego_data),
59 perception_msgs::object_access::getVelocity(ego_data));
62 delta_front_tgt = perception_msgs::object_access::getSteeringAngleFront(ego_data);
65 delta_rear_tgt = perception_msgs::object_access::getSteeringAngleRear(ego_data);
68 RCLCPP_DEBUG(this->get_logger(),
"y_tgt: %f, v_tgt: %f, a_tgt: %f, theta_tgt: %f, delta_front_tgt: %f, delta_rear_tgt: %f",
69 y_tgt, v_tgt, a_tgt, theta_tgt, delta_front_tgt, delta_rear_tgt);
73 double a_path =
projectVectorAonV(perception_msgs::object_access::getAcceleration(ego_data),
74 perception_msgs::object_access::getVelocity(ego_data));
75 if (fabs(v_tgt - perception_msgs::object_access::getVelocityMagnitude(ego_data)) >
bi_level_dV_ ||
77 v_tgt = perception_msgs::object_access::getVelocityMagnitude(ego_data);
84 delta_front_tgt = perception_msgs::object_access::getSteeringAngleFront(ego_data);
85 delta_rear_tgt = perception_msgs::object_access::getSteeringAngleRear(ego_data);
86 }
else if (fabs(delta_front_tgt - perception_msgs::object_access::getSteeringAngleFront(ego_data)) >
88 delta_front_tgt = perception_msgs::object_access::getSteeringAngleFront(ego_data);
89 }
else if (fabs(delta_rear_tgt - perception_msgs::object_access::getSteeringAngleRear(ego_data)) >
91 delta_rear_tgt = perception_msgs::object_access::getSteeringAngleRear(ego_data);
94 std::vector<double> x_init(*
nlp_dims_->nx, 0.0);
100 x_init[5] = theta_tgt;
101 x_init[6] = delta_front_tgt;
102 x_init[7] = delta_rear_tgt;
120 for (
int i = 0; i <=
n_shots_; ++i) {
121 trajectory_planning_msgs::trajectory_access::setX(trajectory,
xtraj_[i * *
nlp_dims_->nx + 0], i);
122 trajectory_planning_msgs::trajectory_access::setY(trajectory,
xtraj_[i * *
nlp_dims_->nx + 1], i);
123 trajectory_planning_msgs::trajectory_access::setS(trajectory,
xtraj_[i * *
nlp_dims_->nx + 2], i);
124 trajectory_planning_msgs::trajectory_access::setV(trajectory,
xtraj_[i * *
nlp_dims_->nx + 3], i);
125 trajectory_planning_msgs::trajectory_access::setA(trajectory,
xtraj_[i * *
nlp_dims_->nx + 4], i);
126 trajectory_planning_msgs::trajectory_access::setTheta(trajectory,
xtraj_[i * *
nlp_dims_->nx + 5], i);
127 trajectory_planning_msgs::trajectory_access::setDeltaFront(trajectory,
xtraj_[i * *
nlp_dims_->nx + 6], i);
128 trajectory_planning_msgs::trajectory_access::setDeltaRear(trajectory,
xtraj_[i * *
nlp_dims_->nx + 7], i);
129 trajectory_planning_msgs::trajectory_access::setBeta(
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.