A Mechanism class that uses PID to control a motor group. Contains functions for moving to a relative or absolute angle both synchronously and asynchronously.
More...
#include <Mechanism.h>
|
| Mechanism (vex::motor_group motors, float gear_ratio, std::string mech_id) |
| Construct a new Mechanism object.
|
|
| Mechanism (vex::motor_group motors, float gear_ratio) |
|
void | spin (int velocity) |
| Spins the motor group at the specified velocity. Negative values will spin the motors backwards.
|
|
void | stop () |
| stops the motors using the default brake mode.
|
|
void | waitUntilSettled () |
| Waits for the mechanism to finish motion.
|
|
void | moveRelative (float position, float max_speed) |
| Move the mechanism to a relative angle.
|
|
void | moveRelativeAsync (float position, float max_speed) |
| Move the mechanism to a relative angle asynchronously.
|
|
void | moveAbsolute (float position, float max_speed) |
| Move the mechanism to an absolute angle.
|
|
void | moveAbsoluteAsync (float position, float max_speed) |
| Move the mechanism to an absolute angle asynchronously.
|
|
float | getPosition (vex::rotationUnits units) |
| Get the position of the first motor in the group with the specified units.
|
|
void | resetPosition () |
| Resets the encoders in the group to 0.
|
|
void | setBrakeType (vex::brakeType type) |
| Sets the brake type of the chassis.
|
|
void | setPID (PID pid) |
| Set a PID object to the mechanism.
|
|
void | setOffset (float offset) |
| Set the offset of the mechanism to add or subtract a constant angle.
|
|
void | setMaxAcceleration (float max_accel) |
| Set the max acceleration of the mechanism. Every time the PID loop executes, it increments the speed of the mechanism by this value until the mechanism reaches it's maximum speed. Increase the value if the robot is ramping too slow, or decrease if it causes too much jerk.
|
|
void | setBounds (float lower_bound, float upper_bound) |
| Set the bounds of the mechanism, such that it is unable to spin past these points. This check is only done during driver control and does not affect PID motion.
|
|
A Mechanism class that uses PID to control a motor group. Contains functions for moving to a relative or absolute angle both synchronously and asynchronously.
◆ Mechanism()
wpid::Mechanism::Mechanism |
( |
vex::motor_group |
motors, |
|
|
float |
gear_ratio, |
|
|
std::string |
mech_id |
|
) |
| |
Construct a new Mechanism object.
- Parameters
-
motors | the motors used on the mechanism |
gear_ratio | the external gear ratio |
mech_id | a string identifier for the mechanism to use during logging |
◆ getPosition()
float Mechanism::getPosition |
( |
vex::rotationUnits |
units | ) |
|
Get the position of the first motor in the group with the specified units.
- Parameters
-
units | the rotation units to return |
- Returns
- float the position of the motor
◆ moveAbsolute()
void Mechanism::moveAbsolute |
( |
float |
position, |
|
|
float |
max_speed |
|
) |
| |
Move the mechanism to an absolute angle.
- Parameters
-
position | the absolute angle to move to in degrees |
max_speed | the max speed of the motors in velocityUnits::pct |
◆ moveAbsoluteAsync()
void Mechanism::moveAbsoluteAsync |
( |
float |
position, |
|
|
float |
max_speed |
|
) |
| |
Move the mechanism to an absolute angle asynchronously.
- Parameters
-
position | the absolute angle to move to in degrees |
max_speed | the max speed of the motors in velocityUnits::pct |
◆ moveRelative()
void Mechanism::moveRelative |
( |
float |
position, |
|
|
float |
max_speed |
|
) |
| |
Move the mechanism to a relative angle.
- Parameters
-
position | the relative angle to move to in degrees |
max_speed | the max speed of the motors in velocityUnits::pct |
◆ moveRelativeAsync()
void Mechanism::moveRelativeAsync |
( |
float |
position, |
|
|
float |
max_speed |
|
) |
| |
Move the mechanism to a relative angle asynchronously.
- Parameters
-
position | the relative angle to move to in degrees |
max_speed | the max speed of the motors in velocityUnits::pct |
◆ setBounds()
void Mechanism::setBounds |
( |
float |
lower_bound, |
|
|
float |
upper_bound |
|
) |
| |
Set the bounds of the mechanism, such that it is unable to spin past these points. This check is only done during driver control and does not affect PID motion.
- Parameters
-
lower_bound | the lowest encoder value the mechanism may move to in degrees |
upper_bound | the highest encoder value the mechanism may move to in degrees |
◆ setBrakeType()
void Mechanism::setBrakeType |
( |
vex::brakeType |
type | ) |
|
Sets the brake type of the chassis.
- Parameters
-
type | The brake type can be set to coast, brake, or hold |
◆ setMaxAcceleration()
void Mechanism::setMaxAcceleration |
( |
float |
max_accel | ) |
|
Set the max acceleration of the mechanism. Every time the PID loop executes, it increments the speed of the mechanism by this value until the mechanism reaches it's maximum speed. Increase the value if the robot is ramping too slow, or decrease if it causes too much jerk.
- Parameters
-
max_accel | a value to increment to ramp the speed up in velocityUnits::pct |
◆ setOffset()
void Mechanism::setOffset |
( |
float |
offset | ) |
|
Set the offset of the mechanism to add or subtract a constant angle.
- Parameters
-
offset | the offset in degrees |
◆ setPID()
void Mechanism::setPID |
( |
PID |
pid | ) |
|
Set a PID object to the mechanism.
- Parameters
-
◆ spin()
void Mechanism::spin |
( |
int |
velocity | ) |
|
Spins the motor group at the specified velocity. Negative values will spin the motors backwards.
- Parameters
-
velocity | the velocity of the mechanism in velocityUnits::pct |
The documentation for this class was generated from the following files:
- include/WPID/Mechanism/Mechanism.h
- src/WPID/Mechanism/Mechanism.cpp