2323#include < mppi/cost_functions/moving_car_obstacles.hpp>
2424#include < mppi/dynamics/dubins/first_order_dubins_bicycle.cuh>
2525#include < mppi/feedback_controllers/zero_feedback.cuh>
26- #include < mppi/path/path2d.hpp>
27- #include < mppi/path/path_projection.hpp>
2826#include < mppi/sampling_distributions/colored_noise/colored_noise.cuh>
2927#include < mppi/sampling_distributions/gaussian/gaussian.cuh>
3028#include < mppi/sampling_distributions/smooth-MPPI/smooth-MPPI.cuh>
@@ -57,7 +55,6 @@ constexpr int kRefHorizon = kMppiHorizon;
5755constexpr float kDt = 0 .1F ;
5856constexpr size_t kMaxIter = 10 ;
5957constexpr int kNumRollouts = 32 * 1024 ;
60- constexpr float kInitArcLength = 1 .5F ;
6158// constexpr int kMaxVizRollouts = 200; // rollout viz disabled
6259constexpr char kLoggerName [] = " first_order_dubins_mppi" ;
6360
@@ -125,20 +122,6 @@ void fromHostState(DYN::state_array & x, const FirstOrderDubinsMppiState & state
125122 x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::VEL_X )) = state.vel_x ;
126123}
127124
128- mppi::path::Path2D trajectoryToPath2D (const Trajectory & trajectory)
129- {
130- std::vector<std::pair<float , float >> control_xy;
131- control_xy.reserve (trajectory.points .size ());
132- for (const auto & point : trajectory.points ) {
133- control_xy.emplace_back (
134- static_cast <float >(point.pose .position .x ), static_cast <float >(point.pose .position .y ));
135- }
136- if (control_xy.size () < 2U ) {
137- throw std::runtime_error (" Trajectory must contain at least two points for MPPI tracking" );
138- }
139- return mppi::path::Path2D::catmullRom (control_xy, false , 8 );
140- }
141-
142125float yawFromOdometry (const Odometry & odometry)
143126{
144127 return static_cast <float >(tf2::getYaw (odometry.pose .pose .orientation ));
@@ -194,25 +177,15 @@ std::vector<mppi::path::PathReferenceSample> buildDiffusionReferenceHorizon(
194177 return ref;
195178 }
196179
197- float accum_s = 0 .0F ;
198- float prev_x = static_cast <float >(trajectory.points .front ().pose .position .x );
199- float prev_y = static_cast <float >(trajectory.points .front ().pose .position .y );
200180 for (size_t k = 0 ; k < ref.size (); ++k) {
201181 const size_t idx = std::min (k, trajectory.points .size () - 1U );
202182 const auto & point = trajectory.points [idx];
203- const float x = static_cast <float >(point.pose .position .x );
204- const float y = static_cast <float >(point.pose .position .y );
205- if (k > 0U ) {
206- accum_s += std::hypot (x - prev_x, y - prev_y);
207- }
208183 ref[k].t = static_cast <float >(k + 1U ) * kDt ;
209- ref[k].x = x ;
210- ref[k].y = y ;
184+ ref[k].x = static_cast < float >(point. pose . position . x ) ;
185+ ref[k].y = static_cast < float >(point. pose . position . y ) ;
211186 ref[k].yaw = static_cast <float >(tf2::getYaw (point.pose .orientation ));
212187 ref[k].v = point.longitudinal_velocity_mps ;
213- ref[k].arc_length_s = accum_s;
214- prev_x = x;
215- prev_y = y;
188+ ref[k].arc_length_s = 0 .0F ;
216189 }
217190
218191 return ref;
@@ -394,7 +367,6 @@ struct FirstOrderDubinsMppiInterface::Impl
394367{
395368 Trajectory diffusion_reference;
396369 TrackedObjects tracked_objects;
397- mppi::path::Path2D path;
398370 std::vector<mppi::cost::MovingCarObstacle> obstacles;
399371
400372 DYN model;
@@ -420,7 +392,6 @@ struct FirstOrderDubinsMppiInterface::Impl
420392 bool initialized{false };
421393 int step_count{0 };
422394 size_t tracking_start_idx{0U };
423- float arc_length{kInitArcLength };
424395 float sim_time{0 .0F };
425396 bool ignore_obstacles{false };
426397 bool ignore_drivable_area{false };
@@ -513,7 +484,6 @@ struct FirstOrderDubinsMppiInterface::Impl
513484 initialized = true ;
514485 step_count = 0 ;
515486 tracking_start_idx = 0U ;
516- arc_length = kInitArcLength ;
517487 sim_time = 0 .0F ;
518488
519489 RCLCPP_INFO (
@@ -534,7 +504,6 @@ struct FirstOrderDubinsMppiInterface::Impl
534504 {
535505 step_count = 0 ;
536506 u_opt.setZero ();
537- arc_length = kInitArcLength ;
538507 sim_time = 0 .0F ;
539508 }
540509
@@ -600,7 +569,6 @@ struct FirstOrderDubinsMppiInterface::Impl
600569
601570 diffusion_reference = reference;
602571 tracked_objects = ignore_obstacles ? TrackedObjects{} : tracked_objects_in;
603- path = trajectoryToPath2D (reference);
604572 obstacles.clear ();
605573 // Boundary crash is disabled on this stack (isEgoOutsideDrivableArea always false).
606574 // ignore_drivable_area remains an ablation API flag; it does not reintroduce road borders.
@@ -631,11 +599,6 @@ struct FirstOrderDubinsMppiInterface::Impl
631599 steeringTireAngleRad (steering_status), -vehicle_params.max_steer_angle ,
632600 vehicle_params.max_steer_angle );
633601 x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::STEER_ANGLE )) = ego_steer;
634-
635- const mppi::path::PathProjection proj = mppi::path::projectPoseOntoPath (
636- path, x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::POS_X )),
637- x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::POS_Y )), arc_length);
638- arc_length = proj.arc_length_s ;
639602 }
640603
641604 FirstOrderDubinsMppiControl runStep ()
@@ -689,11 +652,6 @@ struct FirstOrderDubinsMppiInterface::Impl
689652 model.step (x, x_next, xdot, u_apply, y, static_cast <float >(step_count), kDt );
690653 x = x_next;
691654
692- const mppi::path::PathProjection proj = mppi::path::projectPoseOntoPath (
693- path, x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::POS_X )),
694- x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::POS_Y )), arc_length);
695- arc_length = proj.arc_length_s ;
696-
697655 ++step_count;
698656 sim_time += kDt ;
699657
@@ -705,11 +663,10 @@ struct FirstOrderDubinsMppiInterface::Impl
705663
706664 RCLCPP_DEBUG (
707665 mppiLogger (),
708- " MPPI track step %d: start_idx=%zu arc_s=%.2f ref_v0=%.2f u_accel=%.3f u_steer=%.3f "
666+ " MPPI track step %d: start_idx=%zu ref_v0=%.2f u_accel=%.3f u_steer=%.3f "
709667 " ego_v=%.2f baseline_cost=%.2f" ,
710- step_count, tracking_start_idx, arc_length, ref.empty () ? 0 .0F : ref.front ().v ,
711- control.accel_cmd , control.steer_cmd ,
712- x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::VEL_X )),
668+ step_count, tracking_start_idx, ref.empty () ? 0 .0F : ref.front ().v , control.accel_cmd ,
669+ control.steer_cmd , x (static_cast <int >(FirstOrderDubinsBicycleParams::StateIndex::VEL_X )),
713670 controller->getBaselineCost ());
714671
715672 return control;
@@ -846,19 +803,17 @@ bool FirstOrderDubinsMppiInterface::copySampleCostDistribution(
846803}
847804
848805FirstOrderDubinsMppiControl FirstOrderDubinsMppiInterface::computeStep (
849- FirstOrderDubinsMppiState & state, float & arc_length, float sim_time)
806+ FirstOrderDubinsMppiState & state, float sim_time)
850807{
851808 if (!impl_ || !impl_->initialized ) {
852809 throw std::runtime_error (
853810 " FirstOrderDubinsMppiInterface must be initialized before computeStep" );
854811 }
855812
856813 fromHostState (impl_->x , state);
857- impl_->arc_length = arc_length;
858814 impl_->sim_time = sim_time;
859815 const FirstOrderDubinsMppiControl control = impl_->runStep ();
860816 state = toHostState (impl_->x );
861- arc_length = impl_->arc_length ;
862817 return control;
863818}
864819
0 commit comments