10#include "pros/distance.hpp"
42 pros::Distance& sensor,
44 int timeout_ms = 10000) {
48 int drive_dir = (speed >= 0) ? 5000 : -5000;
52 while (elapsed < timeout_ms) {
53 int reading = sensor.get();
54 if (reading != PROS_ERR && reading <= target_mm) {
87 pros::Distance& sensor,
91 bool faces_positive =
false,
93 int raw = sensor.get();
94 if (
raw == PROS_ERR)
return;
101 double projected_offset = fix_x
102 ? (offset_fwd * std::sin(heading) + offset_side * std::cos(heading))
103 : (offset_fwd * std::cos(heading) - offset_side * std::sin(heading));
105 double center_to_wall = dist_in + projected_offset;
106 double coord = faces_positive ? (field_size_in - center_to_wall)
155 pros::Distance& front_sensor,
156 pros::Distance& rear_sensor,
158 int front_raw = front_sensor.get();
159 int rear_raw = rear_sensor.get();
160 if (front_raw == PROS_ERR || rear_raw == PROS_ERR)
return;
Pose, sensor specs, and the global odometry / pose-estimation API.
Tank-drive chassis class.
double drive_imu_get()
Returns the current imu rotation value in degrees.
void pid_drive_set(okapi::QLength p_target, int speed)
Sets the robot to move forward using PID with okapi units, only using slew if globally enabled.
void pid_wait_quick_chain()
Lock the code in a while loop until the robot has settled.
void drive_imu_reset(double new_heading=0)
Resets the current imu value.
Tank chassis class — the main user-facing API for autonomous and opcontrol drive motions.
void drive_distance_reset(light::Drive &chassis, double known_coord, bool fix_x)
Re-zero one odom axis from a known field coordinate (e.g.
void drive_until_distance(okapi::QLength target, pros::Distance &sensor, int speed=127, int timeout_ms=10000)
Drive forward (or reverse) until a distance sensor reads at or below target.
void angle_reset(light::Drive &chassis, pros::Distance &front_sensor, pros::Distance &rear_sensor, double separation)
Correct heading from front- and rear-mounted distance sensors looking at the same parallel wall.
void distance_reset(light::Drive &chassis, pros::Distance &sensor, double offset_fwd, double offset_side, bool fix_x, bool faces_positive=false, double field_size_in=light::field::FIELD_SIZE_IN)
Re-zero one odom axis (x or y) using a wall-facing distance sensor.
Fixed-map ray caster used by LightCast's sensor model.
constexpr float FIELD_SIZE_IN
Field side length, inches (12 ft).
constexpr double MM_PER_IN
Millimeters per inch.
constexpr double IN_PER_MM
Inches per millimeter.
constexpr double DEG_PER_RAD
Degrees per radian.
constexpr double RAD_PER_DEG
Radians per degree.
@ raw
Use signed delta as-is (no wrap).
Pose getPose(bool radians=false)
void setPose(Pose pose, bool radians=false)
Overwrite the current pose.
float x
X position, inches.
float y
Y position, inches.
Robot subsystem declarations: motors, sensors, and pistons.
Drive chassis
The drive chassis, configured in main.cpp and used everywhere else.
Shared types, enums, math helpers, and unit conversions used across LightLib.