@@ -75,7 +75,7 @@ float FTMotion::tau = 0.0f; // (s) Time since start of b
7575TrapezoidalTrajectoryGenerator FTMotion::trapezoidalGenerator;
7676Poly5TrajectoryGenerator FTMotion::poly5Generator;
7777Poly6TrajectoryGenerator FTMotion::poly6Generator;
78- TrajectoryGenerator& FTMotion::currentGenerator = FTMotion::trapezoidalGenerator;
78+ TrajectoryGenerator* FTMotion::currentGenerator = & FTMotion::trapezoidalGenerator;
7979TrajectoryType FTMotion::trajectoryType = TrajectoryType::FTM_TRAJECTORY_TYPE;
8080
8181// Make vector variables.
@@ -496,7 +496,7 @@ void FTMotion::runoutBlock() {
496496 const float total_duration = max_intervals * FTM_TS + reminder_from_last_block;
497497
498498 // Plan a zero-motion trajectory for runout
499- currentGenerator. planRunout (total_duration);
499+ currentGenerator-> planRunout (total_duration);
500500
501501 blockProcRdy = true ; // since ratio is 0, the trajectory positions won't advance in any axis
502502}
@@ -511,7 +511,7 @@ int32_t FTMotion::stepperCmdBuffItems() {
511511void FTMotion::init () {
512512 update_shaping_params ();
513513 TERN_ (FTM_SMOOTHING, update_smoothing_params ());
514- setTrajectoryType (TrajectoryType::FTM_TRAJECTORY_TYPE );
514+ setTrajectoryType (cfg. trajectory_type );
515515 reset (); // Precautionary.
516516}
517517
@@ -520,11 +520,11 @@ void FTMotion::setTrajectoryType(const TrajectoryType type) {
520520 cfg.trajectory_type = trajectoryType = type;
521521 switch (type) {
522522 default : cfg.trajectory_type = trajectoryType = TrajectoryType::FTM_TRAJECTORY_TYPE;
523- case TrajectoryType::TRAPEZOIDAL: currentGenerator = trapezoidalGenerator; break ;
524- case TrajectoryType::POLY5: currentGenerator = poly5Generator; break ;
525- case TrajectoryType::POLY6: currentGenerator = poly6Generator; break ;
523+ case TrajectoryType::TRAPEZOIDAL: currentGenerator = & trapezoidalGenerator; break ;
524+ case TrajectoryType::POLY5: currentGenerator = & poly5Generator; break ;
525+ case TrajectoryType::POLY6: currentGenerator = & poly6Generator; break ;
526526 }
527- currentGenerator. reset (); // Reset the selected generator
527+ currentGenerator-> reset (); // Reset the selected generator
528528}
529529
530530// Load / convert block data from planner to fixed-time control variables.
@@ -545,7 +545,7 @@ void FTMotion::loadBlockData(block_t * const current_block) {
545545 const float final_speed = mmps * current_block->final_rate ; // (mm/s) End feedrate
546546
547547 // Plan the trajectory using the trajectory generator
548- currentGenerator. plan (initial_speed, final_speed, current_block->acceleration , current_block->nominal_speed , totalLength);
548+ currentGenerator-> plan (initial_speed, final_speed, current_block->acceleration , current_block->nominal_speed , totalLength);
549549
550550 // Accel + Coasting + Decel + datapoints
551551 const float reminder_from_last_block = - tau;
@@ -555,7 +555,7 @@ void FTMotion::loadBlockData(block_t * const current_block) {
555555 TERN_ (FTM_HAS_LIN_ADVANCE, use_advance_lead = current_block->use_advance_lead );
556556
557557 // Watch endstops until the move ends
558- const float total_duration = currentGenerator. getTotalDuration ();
558+ const float total_duration = currentGenerator-> getTotalDuration ();
559559 uint32_t max_intervals = ceil ((total_duration + reminder_from_last_block) * FTM_FS);
560560 const millis_t move_end_ti = millis () + SEC_TO_MS ((FTM_TS) * float (max_intervals + num_samples_shaper_settle () + ((PROP_BATCHES) + 1 ) * (FTM_BATCH_SIZE)) + (float (FTM_STEPPERCMD_BUFF_SIZE) / float (FTM_STEPPER_FS)));
561561
@@ -572,7 +572,7 @@ void FTMotion::loadBlockData(block_t * const current_block) {
572572// Generate data points of the trajectory.
573573// Called from FTMotion::loop() at the fetch of a new planner block, after loadBlockData.
574574void FTMotion::generateTrajectoryPointsFromBlock () {
575- const float total_duration = currentGenerator. getTotalDuration ();
575+ const float total_duration = currentGenerator-> getTotalDuration ();
576576 if (tau + FTM_TS > total_duration) {
577577 // TODO: refactor code so this thing is not twice.
578578 // the reason of it being in the beginning, is that a block can be so short that it has
@@ -589,7 +589,7 @@ void FTMotion::generateTrajectoryPointsFromBlock() {
589589 // tau can start negative, but it always holds that `tau > -FTM_TS`
590590
591591 // Get distance from trajectory generator
592- const float dist = currentGenerator. getDistanceAtTime (tau);
592+ const float dist = currentGenerator-> getDistanceAtTime (tau);
593593
594594 #define _SET_TRAJ (q ) traj.q[traj_idx_set] = startPos.q + ratio.q * dist;
595595 LOGICAL_AXIS_MAP_LC (_SET_TRAJ);
0 commit comments