@@ -54,6 +54,7 @@ using namespace std;
5454#include < iomanip>
5555#include < iostream>
5656#include < string>
57+ #include < cmath>
5758
5859using autoware_vehicle_msgs::msg::ControlModeReport;
5960
@@ -148,6 +149,17 @@ void actuation_cmd_callback(
148149 TargetSteerCmd_temp = msg->actuation .steer_cmd ;
149150}
150151
152+ double computeLateralVelocity (double vehicle_speed_mps,
153+ double gps_course_deg,
154+ double integrated_yaw_deg) {
155+ constexpr double DEG_TO_RAD = M_PI / 180.0 ;
156+ double course_rad = gps_course_deg * DEG_TO_RAD;
157+ double yaw_rad = integrated_yaw_deg * DEG_TO_RAD;
158+
159+ return vehicle_speed_mps * std::sin (course_rad - yaw_rad);
160+ }
161+
162+
151163// ===== MAIN FUNCTION =====
152164
153165int main (int argc, char **argv) {
@@ -404,10 +416,23 @@ int main(int argc, char **argv) {
404416 current_SteeringStatus.steering_tire_angle = CurrentSteer_pc * MAX_STEER_ANG;
405417 steering_status_pub->publish (current_SteeringStatus);
406418
407- current_VelocityStatus.stamp = node->get_clock ()->now ();
408- current_VelocityStatus.longitudinal_velocity = ;
409- velocity_status_pub-> publish ( current_VelocityStatus) ;
419+ current_VelocityStatus.header . stamp = node->get_clock ()->now ();
420+ current_VelocityStatus.header . frame_id = " base_link " ;
421+ current_VelocityStatus. longitudinal_velocity = CurrentTwistLinearCANSD_Mps ;
410422
423+ // TODO: Recheck
424+ static double integrated_yaw_deg = 0.0 ;
425+ constexpr double dt = 0.05 ;
426+ integrated_yaw_deg += IMU_Rate_Z * dt;
427+
428+ current_VelocityStatus.lateral_velocity = computeLateralVelocity (
429+ CurrentTwistLinearCANImu_Mps,
430+ IMU_Angle_Z,
431+ integrated_yaw_deg);
432+ // current_VelocityStatus.lateral_velocity = 0
433+
434+ velocity_status_pub->publish (current_VelocityStatus);
435+
411436 // not simulation mode - publish control commands to vehicle
412437 if (!_sd_simulation_mode) {
413438 sent_msgs_pub->publish (CustomerControlCANTx);
0 commit comments