libstp
Robotics library for Botball
Loading...
Searching...
No Matches
motion_config.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "foundation/pid.hpp"
4
5namespace libstp::motion
6{
13 inline constexpr double kMotionEpsilon = 1e-6;
14
32
41 {
42 // Distance/Position PID (used for forward/backward distance, lateral distance)
43 foundation::PidConfig distance{2.0, 0.0, 0.5, 10.0, 0.01, 0.3};
44
45 // Heading/Angular PID (used for maintaining heading in drive/strafe, and for turning)
46 foundation::PidConfig heading{2.0, 0.0, 0.3, 10.0, 0.01, 0.3};
47
48 // Profiled PID velocity feedforward gain.
49 // 1.0 = full feedforward from profile velocity (recommended for velocity-commanding systems).
50 // 0.0 = pure PID on position error (WPILib-style, needs larger kP).
51 double velocity_ff{1.0};
52
53 // Saturation handling (speed-independent derating factors)
57
58 // Heading-specific saturation handling
60 double heading_min_scale{0.25};
62
63 // Hysteresis parameters to prevent oscillation
66
67 // Tolerances
68 // 2 mm: the motion must actually reach the goal. A looser band let the
69 // profiled PID declare "done" ~1 cm short, hard-stop, and leave the
70 // robot parked short of the target (the strafe-reversal stall). Kept in
71 // lockstep with the executor's DISTANCE_TOL_M / progress eps (2 mm).
72 double distance_tolerance_m{0.002};
73 double angle_tolerance_rad{0.035};
74
75 // Saturation heading thresholds
78
79 // Max rate-of-change of the internal heading-hold omega output in
80 // LinearMotion (rad/s^2). Prevents a motion that starts with an
81 // inherited heading error from snapping to a saturated omega in its
82 // first tick (visible yaw jerk + overshoot on high-inertia chassis).
83 // 0 disables the limit (legacy behaviour). Does not affect the line
84 // follow omega override, which runs its own controller.
85 double heading_omega_slew{0.0};
86
87 // Per-axis motion profile constraints, typically populated from
88 // characterization data such as characterize_drive().
92 };
93
101}
constexpr double kMotionEpsilon
UnifiedMotionPidConfig defaultUnifiedMotionPidConfig()
AxisConstraints(double max_velocity, double acceleration, double deceleration)