LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
light::HoloDrive Class Reference

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
 

Detailed Description

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.

Motor layout (viewed from above, robot nose pointing up)
FL FR
BL BR
Use a negative port number to reverse a motor.
Wheel mixing ("X" pattern, standard for VEX)
FL = throttle − strafe + turn
FR = throttle + strafe − turn
BL = throttle + strafe + turn
BR = throttle − strafe − turn
void strafe(double inches, int max_speed=100, int timeout_ms=3000)
Strafe right inches (negative = left).
Positive turn = clockwise (right). Positive strafe = rightward.
Warning
Before running any autonomous method you MUST call 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.

Member Enumeration Documentation

◆ Type

enum class light::HoloDrive::Type
strong

Wheel layout option.

Enumerator
XDRIVE 

Omni wheels mounted at 45°.

MECANUM 

Definition at line 136 of file holo_drive.hpp.

Constructor & Destructor Documentation

◆ HoloDrive()

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.

Parameters
fl_portfront-left motor port (negative = reversed)
fr_portfront-right motor port (negative = reversed)
bl_portback-left motor port (negative = reversed)
br_portback-right motor port (negative = reversed)
imu_portinertial sensor port
wheel_diameterwheel diameter in inches
gear_ratiooutput_rpm / motor_rpm (1.0 = direct drive)
typewheel layout

Member Function Documentation

◆ calibrate()

void light::HoloDrive::calibrate ( bool  wait = true)

Calibrate the IMU.

Parameters
waitif true, blocks until settled.

◆ drive()

void light::HoloDrive::drive ( double  inches,
int  max_speed = 100,
int  timeout_ms = 3000 
)

Drive forward inches (negative = reverse).

◆ get_heading()

double light::HoloDrive::get_heading ( ) const
Returns
Current heading 0–360°, CW-positive.

◆ opcontrol()

void light::HoloDrive::opcontrol ( int  throttle,
int  strafe,
int  turn 
)

Drive from joystick inputs.

Pass raw joystick values −127..127.

Parameters
throttleforward / back
strafeleft / right
turnCW / CCW

◆ reset_sensors()

void light::HoloDrive::reset_sensors ( )

Tare motor encoders.

◆ set_brake_mode()

void light::HoloDrive::set_brake_mode ( pros::motor_brake_mode_e_t  mode)

Set brake mode for all four motors.

◆ set_drive_pid()

void light::HoloDrive::set_drive_pid ( double  kP,
double  kI = 0,
double  kD = 0 
)

Set the linear-drive PID gains.

◆ set_heading_pid()

void light::HoloDrive::set_heading_pid ( double  kP,
double  kI = 0,
double  kD = 0 
)

Set the heading-correction PID used during straight drive / strafe.

◆ set_strafe_pid()

void light::HoloDrive::set_strafe_pid ( double  kP,
double  kI = 0,
double  kD = 0 
)

Set the strafe PID gains.

◆ set_turn_pid()

void light::HoloDrive::set_turn_pid ( double  kP,
double  kI = 0,
double  kD = 0 
)

Set the turn-in-place PID gains.

◆ strafe()

void light::HoloDrive::strafe ( double  inches,
int  max_speed = 100,
int  timeout_ms = 3000 
)

Strafe right inches (negative = left).

◆ turn_relative()

void light::HoloDrive::turn_relative ( double  degrees,
int  max_speed = 80,
int  timeout_ms = 2000 
)

Turn degrees CW (positive) or CCW (negative).

◆ turn_to()

void light::HoloDrive::turn_to ( double  heading_deg,
int  max_speed = 80,
int  timeout_ms = 2000 
)

Turn to absolute heading 0–360°.


The documentation for this class was generated from the following file: