pros/motors.h file

Contains prototypes for the V5 Motor-related functions.

This file should not be modified by users, since it gets replaced whenever a kernel upgrade occurs.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Namespaces

namespace pros
LLEMU Conditional Include
namespace pros::c

Functions

uint32_t motor_get_faults(int8_t port)
Gets the faults experienced by the motor.
uint32_t motor_get_flags(int8_t port)
Gets the flags set by the motor's operation.
int32_t motor_get_raw_position(int8_t port, uint32_t*const timestamp)
Gets the raw encoder count of the motor at a given timestamp.
double motor_get_position(int8_t port)
Gets the absolute position of the motor in its encoder units.
double motor_get_power(int8_t port)
Gets the power drawn by the motor in Watts.
double motor_get_temperature(int8_t port)
Gets the temperature of the motor in degrees Celsius.
double motor_get_torque(int8_t port)
Gets the torque generated by the motor in Newton Meters (Nm).
int32_t motor_get_voltage(int8_t port)
Gets the voltage delivered to the motor in millivolts.
int32_t motor_set_zero_position(int8_t port, const double position)
Sets the position for the motor in its encoder units.
int32_t motor_tare_position(int8_t port)
Sets the "absolute" zero position of the motor to its current position.
int32_t motor_set_brake_mode(int8_t port, const motor_brake_mode_e_t mode)
Sets one of motor_brake_mode_e_t to the motor.
int32_t motor_set_current_limit(int8_t port, const int32_t limit)
Sets the current limit for the motor in mA.
int32_t motor_set_encoder_units(int8_t port, const motor_encoder_units_e_t units)
Sets one of motor_encoder_units_e_t for the motor encoder.
int32_t motor_set_gearing(int8_t port, const motor_gearset_e_t gearset)
Sets one of motor_gearset_e_t for the motor.
int32_t motor_set_voltage_limit(int8_t port, const int32_t limit)
Sets the voltage limit for the motor in Volts.
motor_brake_mode_e_t motor_get_brake_mode(int8_t port)
Gets the brake mode that was set for the motor.
int32_t motor_get_current_limit(int8_t port)
Gets the current limit for the motor in mA.
motor_encoder_units_e_t motor_get_encoder_units(int8_t port)
Gets the encoder units that were set for the motor.
motor_gearset_e_t motor_get_gearing(int8_t port)
Gets the gearset that was set for the motor.
int32_t motor_get_voltage_limit(int8_t port)
Gets the voltage limit set by the user.

Motor movement functions

These functions allow programmers to make motors move

int32_t motor_move(int8_t port, int32_t voltage)
Sets the voltage for the motor from -127 to 127.
int32_t motor_brake(int8_t port)
Stops the motor using the currently configured brake mode.
int32_t motor_move_absolute(int8_t port, double position, const int32_t velocity)
Sets the target absolute position for the motor to move to.
int32_t motor_move_relative(int8_t port, double position, const int32_t velocity)
Sets the relative target position for the motor to move to.
int32_t motor_move_velocity(int8_t port, const int32_t velocity)
Sets the velocity for the motor.
int32_t motor_move_voltage(int8_t port, const int32_t voltage)
Sets the output voltage for the motor from -12000 to 12000 in millivolts.
int32_t motor_modify_profiled_velocity(int8_t port, const int32_t velocity)
Changes the output velocity for a profiled movement (motor_move_absolute or motor_move_relative).
double motor_get_target_position(int8_t port)
Gets the target position set for the motor by the user.
int32_t motor_get_target_velocity(int8_t port)
Gets the velocity commanded to the motor by the user.

Motor telemetry functions

These functions allow programmers to collect telemetry from motors

double motor_get_actual_velocity(int8_t port)
Gets the actual velocity of the motor.
int32_t motor_get_current_draw(int8_t port)
Gets the current drawn by the motor in mA.
int32_t motor_get_direction(int8_t port)
Gets the direction of movement for the motor.
double motor_get_efficiency(int8_t port)
Gets the efficiency of the motor in percent.
int32_t motor_is_over_current(int8_t port)
Checks if the motor is drawing over its current limit.
int32_t motor_is_over_temp(int8_t port)
Checks if the motor's temperature is above its limit.

Enums

enum motor_fault_e { E_MOTOR_FAULT_NO_FAULTS = 0x00, E_MOTOR_FAULT_MOTOR_OVER_TEMP = 0x01, E_MOTOR_FAULT_DRIVER_FAULT = 0x02, E_MOTOR_FAULT_OVER_CURRENT = 0x04, E_MOTOR_FAULT_DRV_OVER_CURRENT = 0x08 }
enum motor_flag_e { E_MOTOR_FLAGS_NONE = 0x00, E_MOTOR_FLAGS_BUSY = 0x01, E_MOTOR_FLAGS_ZERO_VELOCITY = 0x02, E_MOTOR_FLAGS_ZERO_POSITION = 0x04 }
enum motor_brake_mode_e { E_MOTOR_BRAKE_COAST = 0, E_MOTOR_BRAKE_BRAKE = 1, E_MOTOR_BRAKE_HOLD = 2, E_MOTOR_BRAKE_INVALID = INT32_MAX }
enum motor_encoder_units_e { E_MOTOR_ENCODER_DEGREES = 0, E_MOTOR_ENCODER_ROTATIONS = 1, E_MOTOR_ENCODER_COUNTS = 2, E_MOTOR_ENCODER_INVALID = INT32_MAX }
enum motor_gearset_e { E_MOTOR_GEARSET_36 = 0, E_MOTOR_GEAR_RED = E_MOTOR_GEARSET_36, E_MOTOR_GEAR_100 = E_MOTOR_GEARSET_36, E_MOTOR_GEARSET_18 = 1, E_MOTOR_GEAR_GREEN = E_MOTOR_GEARSET_18, E_MOTOR_GEAR_200 = E_MOTOR_GEARSET_18, E_MOTOR_GEARSET_06 = 2, E_MOTOR_GEAR_BLUE = E_MOTOR_GEARSET_06, E_MOTOR_GEAR_600 = E_MOTOR_GEARSET_06, E_MOTOR_GEARSET_INVALID = INT32_MAX }