|
LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
|
4-motor holonomic drive — supports X-Drive and Mecanum configurations. More...
#include <holo_drive.hpp>
Public Types | |
| enum class | Type { XDRIVE , MECANUM } |
| Wheel layout option. More... | |
Public Member Functions | |
| HoloDrive (int fl_port, int fr_port, int bl_port, int br_port, int imu_port, double wheel_diameter, double gear_ratio=1.0, Type type=Type::MECANUM) | |
| Construct a 4-motor holonomic drive. | |
Opcontrol | |
| void | opcontrol (int throttle, int strafe, int turn) |
| Drive from joystick inputs. | |
Autonomous moves | |
Straight drive / strafe hold heading via IMU throughout. | |
| void | drive (double inches, int max_speed=100, int timeout_ms=3000) |
Drive forward inches (negative = reverse). | |
| void | strafe (double inches, int max_speed=100, int timeout_ms=3000) |
Strafe right inches (negative = left). | |
| void | turn_to (double heading_deg, int max_speed=80, int timeout_ms=2000) |
| Turn to absolute heading 0–360°. | |
| void | turn_relative (double degrees, int max_speed=80, int timeout_ms=2000) |
Turn degrees CW (positive) or CCW (negative). | |
PID constants | |
| void | set_drive_pid (double kP, double kI=0, double kD=0) |
| Set the linear-drive PID gains. | |
| void | set_strafe_pid (double kP, double kI=0, double kD=0) |
| Set the strafe PID gains. | |
| void | set_turn_pid (double kP, double kI=0, double kD=0) |
| Set the turn-in-place PID gains. | |
| void | set_heading_pid (double kP, double kI=0, double kD=0) |
| Set the heading-correction PID used during straight drive / strafe. | |
Misc | |
| void | calibrate (bool wait=true) |
| Calibrate the IMU. | |
| void | reset_sensors () |
| Tare motor encoders. | |
| void | set_brake_mode (pros::motor_brake_mode_e_t mode) |
| Set brake mode for all four motors. | |
| double | get_heading () const |
4-motor holonomic drive — supports X-Drive and Mecanum configurations.
Both wheel styles use the same control math; pick the type that matches your hardware.
set_*_pid() for each axis. Call calibrate() once inside initialize() if no other code calibrates the IMU. Definition at line 133 of file holo_drive.hpp.
|
strong |
Wheel layout option.
| Enumerator | |
|---|---|
| XDRIVE | Omni wheels mounted at 45°. |
| MECANUM | |
Definition at line 136 of file holo_drive.hpp.
| light::HoloDrive::HoloDrive | ( | int | fl_port, |
| int | fr_port, | ||
| int | bl_port, | ||
| int | br_port, | ||
| int | imu_port, | ||
| double | wheel_diameter, | ||
| double | gear_ratio = 1.0, |
||
| Type | type = Type::MECANUM |
||
| ) |
Construct a 4-motor holonomic drive.
| fl_port | front-left motor port (negative = reversed) |
| fr_port | front-right motor port (negative = reversed) |
| bl_port | back-left motor port (negative = reversed) |
| br_port | back-right motor port (negative = reversed) |
| imu_port | inertial sensor port |
| wheel_diameter | wheel diameter in inches |
| gear_ratio | output_rpm / motor_rpm (1.0 = direct drive) |
| type | wheel layout |
| void light::HoloDrive::calibrate | ( | bool | wait = true | ) |
Calibrate the IMU.
| wait | if true, blocks until settled. |
| void light::HoloDrive::drive | ( | double | inches, |
| int | max_speed = 100, |
||
| int | timeout_ms = 3000 |
||
| ) |
Drive forward inches (negative = reverse).
| double light::HoloDrive::get_heading | ( | ) | const |
| void light::HoloDrive::opcontrol | ( | int | throttle, |
| int | strafe, | ||
| int | turn | ||
| ) |
Drive from joystick inputs.
Pass raw joystick values −127..127.
| throttle | forward / back |
| strafe | left / right |
| turn | CW / CCW |
| void light::HoloDrive::reset_sensors | ( | ) |
Tare motor encoders.
| void light::HoloDrive::set_brake_mode | ( | pros::motor_brake_mode_e_t | mode | ) |
Set brake mode for all four motors.
| void light::HoloDrive::set_drive_pid | ( | double | kP, |
| double | kI = 0, |
||
| double | kD = 0 |
||
| ) |
Set the linear-drive PID gains.
| void light::HoloDrive::set_heading_pid | ( | double | kP, |
| double | kI = 0, |
||
| double | kD = 0 |
||
| ) |
Set the heading-correction PID used during straight drive / strafe.
| void light::HoloDrive::set_strafe_pid | ( | double | kP, |
| double | kI = 0, |
||
| double | kD = 0 |
||
| ) |
Set the strafe PID gains.
| void light::HoloDrive::set_turn_pid | ( | double | kP, |
| double | kI = 0, |
||
| double | kD = 0 |
||
| ) |
Set the turn-in-place PID gains.
| void light::HoloDrive::strafe | ( | double | inches, |
| int | max_speed = 100, |
||
| int | timeout_ms = 3000 |
||
| ) |
Strafe right inches (negative = left).
| void light::HoloDrive::turn_relative | ( | double | degrees, |
| int | max_speed = 80, |
||
| int | timeout_ms = 2000 |
||
| ) |
Turn degrees CW (positive) or CCW (negative).
| void light::HoloDrive::turn_to | ( | double | heading_deg, |
| int | max_speed = 80, |
||
| int | timeout_ms = 2000 |
||
| ) |
Turn to absolute heading 0–360°.