ART v1.0-alpha
A Robot Template that raises the floor for VRC teams
Loading...
Searching...
No Matches
art::SimpleMotorGroup Class Reference

A Simple Motor_Group Wrapper Class. More...

#include <SimpleMotorGroup.h>

Inheritance diagram for art::SimpleMotorGroup:

Public Member Functions

 SimpleMotorGroup (vex::motor_group mot)
 Construct a new Simple Motor_Group object.
 
SimpleMotorGroupwithSpeedMode (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.
 

Detailed Description

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)

Todo
make stop() functions withbrakeModes, also set the cmd to 0

Definition at line 36 of file SimpleMotorGroup.h.

Constructor & Destructor Documentation

◆ SimpleMotorGroup()

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

Parameters
motA vex::motor_group, which is a normal v5 motor_group

Example:

SimpleMotor testMotor = SimpleMotor( vex::motor_group(
vex::motor(vex::PORT10 ), vex::motor(vex::PORT11 )
) );
A Simple Motor Wrapper Class.
Definition SimpleMotor.h:37

Definition at line 20 of file SimpleMotorGroup.cpp.

Member Function Documentation

◆ get()

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.

Todo
Fix persisting motor-group command with vex::motor_group::stop();
Returns
The command the motor-group is set to, as a percentage of the max

Definition at line 50 of file SimpleMotorGroup.cpp.

◆ getSpeedMode()

bool art::SimpleMotorGroup::getSpeedMode ( )

Get the SpeedMode of the SimpleMotorGroup.

This method just returns whether the SimpleMotorGroup is using SpeedMode. Nothing special here.

Returns
true the SimpleMotorGroup is using SpeedMode
false the SimpleMotorGroup is not using SpeedMode

Definition at line 33 of file SimpleMotorGroup.cpp.

◆ set()

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.

Parameters
cmdThe command to set the motor-group to, as a percentage of the max

Example:

SimpleMotorGroup testMotorGroup = SimpleMotorGroup( vex::motor_group(
vex::motor( vex::PORT10 ), vex::motor( vex::PORT11 )
) );
testMotorGroup.set( -75 );
A Simple Motor_Group Wrapper Class.
void set(double cmd)
Sets the motor to spin at the specified command.
SimpleMotorGroup(vex::motor_group mot)
Construct a new Simple Motor_Group object.

Definition at line 38 of file SimpleMotorGroup.cpp.

◆ setSpeedMode()

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.

Parameters
speedModeWhether or not the motor-group should use speed, rather than voltage

Example:

SimpleMotorGroup testMotorGroup = SimpleMotorGroup( vex::motor_group(
vex::motor( vex::PORT10 ), vex::motor( vex::PORT11 )
) );
testMotorGroup.setSpeedMode( false );
void setSpeedMode(bool speedMode)
Set the SpeedMode of the SimpleMotorGroup.

Definition at line 28 of file SimpleMotorGroup.cpp.

◆ withSpeedMode()

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.

Parameters
speedModeWhether or not the motor-group should use speed, rather than voltage
Returns
SimpleMotorGroup& (SimpleMotorGroup Refrence)

Example:

SimpleMotorGroup testMotorGroup = SimpleMotorGroup( vex::motor_group(
vex::motor( vex::PORT10 ), vex::motor( vex::PORT11 )
) );
testMotorGroup.withSpeedMode( true );
SimpleMotorGroup & withSpeedMode(bool speedMode)
Returns a SimpleMotorGroup refrence with the specified speedMode.

Chained Methods Example:

Because a refrence to the object is returned, that refrence can be used to call other methods.

SimpleMotor testMotorGroup = SimpleMotorGroup( vex::motor_group(
vex::motor( vex::PORT10 ), vex::motor( vex::PORT11 )
) );
testMotorGroup.withSpeedMode( true ).set( 50 );
void set(double cmd)
Sets the motor to spin at the specified command.
SimpleMotor & withSpeedMode(bool speedMode)
Returns a SimpleMotor refrence with the specified speedMode.

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.

SimpleMotorGroup testMotorGroup = SimpleMotorGroup( vex::motor_group(
vex::motor( vex::PORT10 ), vex::motor( vex::PORT11 )
) ).withSpeedMode( true );

Definition at line 22 of file SimpleMotorGroup.cpp.

Member Data Documentation

◆ m_cmd

double art::SimpleMotorGroup::m_cmd {0}
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.

◆ m_speedMode

bool art::SimpleMotorGroup::m_speedMode {false}
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.


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