22 trajectory_planning_msgs::msg::Trajectory tf_trajectory;
26 }
catch (tf2::TransformException& ex) {
27 RCLCPP_WARN(this->get_logger(),
"Transformation is not available. Init high-level instead. Ex: %s", ex.what());
32 std::vector<double> TIME, V, Y, A, THETA, DELTA;
33 for (
int i = 0; i < trajectory_planning_msgs::trajectory_access::getSamplePointSize(tf_trajectory); i++) {
34 TIME.push_back(trajectory_planning_msgs::trajectory_access::getT(tf_trajectory, i));
35 Y.push_back(trajectory_planning_msgs::trajectory_access::getY(tf_trajectory, i));
36 V.push_back(trajectory_planning_msgs::trajectory_access::getV(tf_trajectory, i));
37 A.push_back(trajectory_planning_msgs::trajectory_access::getA(tf_trajectory, i));
38 THETA.push_back(trajectory_planning_msgs::trajectory_access::getTheta(tf_trajectory, i));
39 DELTA.push_back(trajectory_planning_msgs::trajectory_access::getDeltaAck(tf_trajectory, i));
43 double v_tgt = 0.0, a_tgt = 0.0, y_tgt = 0.0, theta_tgt = 0.0, delta_tgt = 0.0;
44 double des_time = (rclcpp::Time(ego_data.header.stamp) - rclcpp::Time(tf_trajectory.header.stamp)).seconds();
46 if (!
linearInterpolation(TIME, V, des_time, v_tgt)) v_tgt = perception_msgs::object_access::getVelLon(ego_data);
47 if (!
linearInterpolation(TIME, A, des_time, a_tgt)) a_tgt = perception_msgs::object_access::getAccLon(ego_data);
50 delta_tgt = perception_msgs::object_access::getSteeringAngleAck(ego_data);
53 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,
54 theta_tgt, delta_tgt);
58 if (fabs(v_tgt - perception_msgs::object_access::getVelLon(ego_data)) >
bi_level_dV_) {
59 const auto ego_v = perception_msgs::object_access::getVelLon(ego_data);
60 const auto ego_a = perception_msgs::object_access::getAccLon(ego_data);
61 RCLCPP_WARN(this->get_logger(),
"Velocity reinit: v_tgt: %f, a_tgt: %f, ego_v: %f, ego_a: %f", v_tgt, a_tgt, ego_v, ego_a);
67 const auto ego_delta = perception_msgs::object_access::getSteeringAngleAck(ego_data);
68 RCLCPP_WARN(this->get_logger(),
69 "Lateral reinit: y_tgt: %f, theta_tgt: %f, delta_tgt: %f, ego_y: %f, ego_theta: %f, ego_delta: %f", y_tgt,
70 theta_tgt, delta_tgt, 0.0, 0.0, ego_delta);
73 delta_tgt = ego_delta;
76 std::vector<double> x_init(*
nlp_dims_->nx, 0.0);
82 x_init[5] = theta_tgt;
83 x_init[6] = delta_tgt;
98 for (
int i = 0; i <=
n_shots_; ++i) {
99 trajectory_planning_msgs::trajectory_access::setX(trajectory,
xtraj_[i * *
nlp_dims_->nx + 0], i);
100 trajectory_planning_msgs::trajectory_access::setY(trajectory,
xtraj_[i * *
nlp_dims_->nx + 1], i);
101 trajectory_planning_msgs::trajectory_access::setS(trajectory,
xtraj_[i * *
nlp_dims_->nx + 2], i);
102 trajectory_planning_msgs::trajectory_access::setV(trajectory,
xtraj_[i * *
nlp_dims_->nx + 3], i);
103 trajectory_planning_msgs::trajectory_access::setA(trajectory,
xtraj_[i * *
nlp_dims_->nx + 4], i);
104 trajectory_planning_msgs::trajectory_access::setTheta(trajectory,
xtraj_[i * *
nlp_dims_->nx + 5], i);
105 trajectory_planning_msgs::trajectory_access::setDeltaAck(trajectory,
xtraj_[i * *
nlp_dims_->nx + 6], i);