|
ART v1.0-alpha
A Robot Template that raises the floor for VRC teams
|
A Simple Motor_Group Wrapper Class. More...
#include <SimpleMotorGroup.h>
Public Member Functions | |
| SimpleMotorGroup (vex::motor_group mot) | |
| Construct a new Simple Motor_Group object. | |
| SimpleMotorGroup & | withSpeedMode (bool speedMode) |
| Returns a SimpleMotorGroup refrence with the specified speedMode. | |
| void | setSpeedMode (bool speedMode) |
| Set the SpeedMode of the SimpleMotorGroup. | |
| bool | getSpeedMode () |
| Get the SpeedMode of the SimpleMotorGroup. | |
| void | set (double cmd) |
| Sets the motor to spin at the specified command. | |
| double | get () |
| Returns the command the motor-group was last commanded to. | |
Private Attributes | |
| double | m_cmd {0} |
| The command the motor-group is set to, as a percentage of the max. | |
| bool | m_speedMode {false} |
| Whether or not the motor-group should use speed, rather than voltage. | |
A Simple Motor_Group Wrapper Class.
The Simple Motor_Group class aims to provide a simpler and more efficient way to command groups of motors. The class inherits the vex::motor_group class and retains all the same functionality, but gains quality of life functions, allowing the motor group's use to be as simple as get() and set().
For more complex motor controls, such as position or velocity, use the SmartMotor class (planned for a later version)
Definition at line 36 of file SimpleMotorGroup.h.
| art::SimpleMotorGroup::SimpleMotorGroup | ( | vex::motor_group | mot | ) |
Construct a new Simple Motor_Group object.
Uses a vex::motor_group (a normal v5 motor-group) to construct a Simple Motor_Group object
| mot | A vex::motor_group, which is a normal v5 motor_group |
Example:
Definition at line 20 of file SimpleMotorGroup.cpp.
| double art::SimpleMotorGroup::get | ( | ) |
Returns the command the motor-group was last commanded to.
This method returns the command of the SimpleMotor. The command defaults to 0 and is changed whenever SimpleMotorGroup::set(double cmd) is called. If the motor is stopped using vex::motor_group::stop() without using SimpleMotorGroup::set(0), the command will continue to be whatever it last was, although the motor-group will continue to spin.
Definition at line 50 of file SimpleMotorGroup.cpp.
| bool art::SimpleMotorGroup::getSpeedMode | ( | ) |
Get the SpeedMode of the SimpleMotorGroup.
This method just returns whether the SimpleMotorGroup is using SpeedMode. Nothing special here.
Definition at line 33 of file SimpleMotorGroup.cpp.
| void art::SimpleMotorGroup::set | ( | double | cmd | ) |
Sets the motor to spin at the specified command.
This method sets the motor-group's command and makes it spin according to that. The command should be a percentage with 100 being the max in the positive direction and -100 being the max in the negative direction. Commanding the motor-group to 0 will make it stop, but if you wish to control the kind of stop (coast, brake, hold), I'd recommend using the .stop() method from the vex::motor_group class;
Aditionally, if the SimpleMotorGroup currently has SpeedMode set to true, the motor-group will spin at a percent of the max speed, otherwise, it will simply command a percentage of the maximum of 12 volts. In some scenarios, SpeedMode will allow the motor-group to maintain approximately constant speed even once a load is applied.
| cmd | The command to set the motor-group to, as a percentage of the max |
Example:
Definition at line 38 of file SimpleMotorGroup.cpp.
| void art::SimpleMotorGroup::setSpeedMode | ( | bool | speedMode | ) |
Set the SpeedMode of the SimpleMotorGroup.
This method simply sets the SpeedMode of the SimpleMotorGroup. It doesn't return anything, so additional methods cannot be chained to it.
| speedMode | Whether or not the motor-group should use speed, rather than voltage |
Example:
Definition at line 28 of file SimpleMotorGroup.cpp.
| SimpleMotorGroup & art::SimpleMotorGroup::withSpeedMode | ( | bool | speedMode | ) |
Returns a SimpleMotorGroup refrence with the specified speedMode.
Modifies the SimpleMotorGroup object so that it has the speedMode specified by the parameter. A refrence to the SimpleMotor is returned, allowing more methods to be chained to it. This also means that it can be used directly as an extension to the contructor.
| speedMode | Whether or not the motor-group should use speed, rather than voltage |
Example:
Chained Methods Example:
Because a refrence to the object is returned, that refrence can be used to call other methods.
Chained Methods Example:
Keep in mind, methods that don't return a refrence to a SimpleMotor Object can't be used to create a new Object. Even though you could chain .set(double cmd) onto the end, it doesn't return an object refrence, so it couldn't be used to construct testMotor.
Definition at line 22 of file SimpleMotorGroup.cpp.
|
private |
The command the motor-group is set to, as a percentage of the max.
The command represents a percentage of the maximum voltage, 12 volts, or a percentage of the motor-group's max speed, depending on whether m_speedMode is set to true of false. The command is a percentage with 100 being the max in the positive direction and -100 being the max in the negative direction.
Because this member variable is private, it can only be accessed within the class. In order to modify or access this member, use the "get" and "set" methods provided.
Definition at line 192 of file SimpleMotorGroup.h.
|
private |
Whether or not the motor-group should use speed, rather than voltage.
The SpeedMode simple stores whether the motor-group interprets the command as a percentage of the max speed, or the precentage of the max voltage, 12 volts. Using speed rather than voltage should allow the motor-group to perform similarly whether or not load is applied, although this can lead to some unexpected behavior if something gets jammed. In most applications, using either is acceptable and safe.
Because this member variable is private, it can only be accessed within the class. In order to modify or access this member, use the "get" and "set" methods provided.
Definition at line 208 of file SimpleMotorGroup.h.