48 TrackingWheel(pros::Rotation* sensor,
float wheelDiam,
float offset,
float tpr = 36000.0f)
49 : rotSensor(sensor), motorGroup(nullptr), wheelCircumference(wheelDiam * M_PI), offset(offset), tpr(tpr), powered(false) {}
63 TrackingWheel(pros::MotorGroup* motors,
float wheelDiam,
float offset,
float tpr = 360.0f)
64 : rotSensor(nullptr), motorGroup(motors), wheelCircumference(wheelDiam * M_PI), offset(offset), tpr(tpr), powered(true) {}
68 if (rotSensor)
return (rotSensor->get_position() / tpr) * wheelCircumference;
69 if (motorGroup)
return (motorGroup->get_position() / tpr) * wheelCircumference;
81 if (rotSensor) rotSensor->reset_position();
82 if (motorGroup) motorGroup->tare_position();
86 pros::Rotation* rotSensor;
87 pros::MotorGroup* motorGroup;
88 float wheelCircumference;
106 float (*
raycastFn)(float, float, float, float) =
nullptr;
129 pros::Imu*
imu, pros::Imu*
imu2 =
nullptr)
135 pros::Imu*
imu, pros::Imu*
imu2,
161void moveToPoint(
float targetX,
float targetY,
int timeout,
float maxSpeed,
bool reversed);
Single tracking wheel — works with either a Rotation sensor (preferred) or a powered MotorGroup.
float getDistanceTraveled() const
void reset()
Zero the encoder.
TrackingWheel(pros::Rotation *sensor, float wheelDiam, float offset, float tpr=36000.0f)
Construct from an unpowered Rotation sensor.
TrackingWheel(pros::MotorGroup *motors, float wheelDiam, float offset, float tpr=360.0f)
Construct from a powered MotorGroup (blue-cart default).
Runtime tuning for LightCast (particle filter) and the EKF.
Initialize once via init(); poll getPose/setPose from any task.
void update()
Force one update (normally called by the background task).
Pose getSpeed(bool radians=false)
void init(OdomSensors sensors, MCLConfig cfg={})
Initialize the estimator.
Pose getPoseRad()
Radian-only accessor; trajectory code MUST use this to avoid deg/rad bugs.
void stop()
Stop the background odometry task.
Pose estimatePose(float time, bool radians=false)
Linear extrapolation of pose time seconds ahead at current velocity.
Pose getLocalSpeed(bool radians=false)
void reset()
Reset all internal pose state to (0, 0, 0).
Pose getPose(bool radians=false)
void moveToPoint(float targetX, float targetY, int timeout, float maxSpeed, bool reversed)
Drive to a field-relative point (legacy).
void setPose(Pose pose, bool radians=false)
Overwrite the current pose.
Distance sensor mount for LightCast.
float offsetX
Mount X in robot frame, inches.
float(* raycastFn)(float, float, float, float)
leave null for the generic perimiter raycast (works for any angle).
pros::Distance * sensor
Backing PROS distance sensor (not owned).
float offsetY
Mount Y in robot frame, inches.
float angleRad
Ray direction in robot frame, radians.
Tuning knobs for the LightCast particle filter and the EKF.
Bundle of all sensors used by the LightLib pose estimator.
TrackingWheel * horizontal1
Primary horizontal (lateral) tracking wheel.
TrackingWheel * vertical1
Primary vertical (forward-axis) tracking wheel.
OdomSensors(TrackingWheel *v1, TrackingWheel *v2, TrackingWheel *h1, TrackingWheel *h2, pros::Imu *imu, pros::Imu *imu2=nullptr)
Wheel + IMU only constructor.
pros::Gps * gps
nullptr → EKF skips the GPS update step.
pros::Imu * imu2
Optional second IMU; nullptr if not used.
TrackingWheel * horizontal2
Secondary horizontal tracking wheel (or nullptr).
float gpsOffsetX
meters, robot frame
std::vector< DistanceSensorSpec > distanceSensors
Empty → LightCast inactive; EKF-only mode.
pros::Imu * imu
Primary IMU.
TrackingWheel * vertical2
Secondary vertical tracking wheel (or nullptr).
OdomSensors(TrackingWheel *v1, TrackingWheel *v2, TrackingWheel *h1, TrackingWheel *h2, pros::Imu *imu, pros::Imu *imu2, pros::Gps *gps, float gpsOffsetX, float gpsOffsetY, std::vector< DistanceSensorSpec > distanceSensors)
Full constructor with GPS and distance sensors.
float gpsOffsetY
meters, robot frame
float x
X position, inches.
Pose(float x=0, float y=0, float theta=0)
float y
Y position, inches.
Pose operator*(float scalar) const
Pose operator-(const Pose &o) const
Pose operator+(const Pose &o) const
2D pose: position (in) and heading (deg).