VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex_motorgroup.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* */
3/* Copyright (c) Innovation First 2019, All rights reserved. */
4/* */
5/* Module: vex_motorgroup.h */
6/* Author: James Pearman */
7/* Created: 7 April 2019 */
8/* */
9/* Revisions: */
10/* V1.00 TBD - Initial release */
11/* */
12/*----------------------------------------------------------------------------*/
13
14#ifndef VEX_MOTOR_GROUP_CLASS_H
15#define VEX_MOTOR_GROUP_CLASS_H
16
17/*-----------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace vex {
23
25 private:
26 class motor_group_impl;
27 class motor_group_motors {
28 friend class vex::motor_group;
29 private:
30 #define STATIC_MEMORY 8 // do not change
31 uintptr_t _memory[STATIC_MEMORY];
32 motor_group_impl *pimpl;
33 public:
34 motor_group_motors();
35 motor_group_motors(const motor_group_motors&);
36 ~motor_group_motors();
37 };
38
39 int32_t _timeout;
40 motor_group_motors _motors;
41
42 void _addMotor();
43 void _addMotor( vex::motor &m );
44
45 template <typename... Args>
46 void _addMotor( vex::motor &m1, Args &... m2 ) {
47 _addMotor( m1 );
48 _addMotor( m2... );
49 }
50
51 bool waitForCompletionAll();
52
53 public:
56
57 template <typename... Args>
58 motor_group( vex::motor &m1, Args &... m2 ) : motor_group() {
59 _addMotor( m1 );
60 _addMotor( m2... );
61 }
62
63 template <typename... Args>
64 void operator()( vex::motor &m1, Args &... m2 ) {
65 _addMotor( m1 );
66 _addMotor( m2... );
67 }
68
73 int32_t count(void);
74
80 void setVelocity( double velocity, velocityUnits units );
81
82 void setVelocity( double velocity, percentUnits units ){
83 setVelocity( velocity, static_cast<velocityUnits>(units) );
84 };
85
90 void setStopping( brakeType mode );
91
95 void resetPosition( void );
96
102 void setPosition( double value, rotationUnits units );
103
109 void setTimeout( int32_t time, timeUnits units );
110
115 void spin( directionType dir );
116
123 void spin( directionType dir, double velocity, velocityUnits units );
124
125 void spin( directionType dir, double velocity, percentUnits units ){
126 spin( dir, velocity, static_cast<velocityUnits>(units) );
127 };
128
135 void spin( directionType dir, double voltage, voltageUnits units );
136
146 bool spinTo( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
147 bool spinToPosition( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
148
156 bool spinTo( double rotation, rotationUnits units, bool waitForCompletion=true );
157 bool spinToPosition( double rotation, rotationUnits units, bool waitForCompletion=true );
158
159
169 bool spinFor( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
170
171 bool spinFor( directionType dir, double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
172
180 bool spinFor( double rotation, rotationUnits units, bool waitForCompletion=true );
181
182 bool spinFor( directionType dir, double rotation, rotationUnits units, bool waitForCompletion=true );
183
191 void spinFor( double time, timeUnits units, double velocity, velocityUnits units_v );
192
193 void spinFor( directionType dir, double time, timeUnits units, double velocity, velocityUnits units_v );
194
200 void spinFor( double time, timeUnits units );
201
202 void spinFor( directionType dir, double time, timeUnits units );
203
208 bool isSpinning( void );
209
214 bool isDone( void );
215
216 bool isSpinningMode( void );
217
221 void stop( void );
222
227 void stop( brakeType mode );
228
234 void setMaxTorque( double value, percentUnits units );
235
241 void setMaxTorque( double value, torqueUnits units );
242
248 void setMaxTorque( double value, currentUnits units );
249
254 directionType direction( void );
255
261 double position( rotationUnits units );
262
268 double velocity( velocityUnits units );
269
270 double velocity( percentUnits units ) {
271 return velocity( static_cast<velocityUnits>(units) );
272 };
273
279 double current( currentUnits units = currentUnits::amp );
280
286 double current( percentUnits units );
287
288 // these are all V5 compatibility functions and do not return any valid values
289 // data from the motor for these is not available on IQ
290
296 double voltage( voltageUnits units = voltageUnits::volt );
297
303 double power( powerUnits units = powerUnits::watt );
304
310 double torque( torqueUnits units = torqueUnits::Nm );
311
317 double efficiency( percentUnits units = percentUnits::pct );
318
324 double temperature( percentUnits units = percentUnits::pct );
325
331 double temperature( temperatureUnits units );
332
333 };
334}
335
336#endif // VEX_MOTOR_GROUP_CLASS_H
double position(rotationUnits units)
Gets the current position of the first motor in the group's encoder.
double velocity(velocityUnits units)
Gets the current velocity of the first motor in the group.
double efficiency(percentUnits units=percentUnits::pct)
Gets the efficiency of the first motor in the group.
void spinFor(double time, timeUnits units, double velocity, velocityUnits units_v)
Turn on the motors and spin them to a relative target time value at a specified velocity.
void setMaxTorque(double value, currentUnits units)
Sets the max torque of the motors.
void stop(void)
Stops all motors using the default brake mode.
double current(percentUnits units)
Gets the electrical current of the motors in percentage of maximum.
void spinFor(double time, timeUnits units)
Turn on the motors and spin them to a relative target time value.
double power(powerUnits units=powerUnits::watt)
Gets the power of the first motor in the group.
bool spinFor(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turn on the motors and spin them to a relative target rotation value at a specified velocity.
void setMaxTorque(double value, percentUnits units)
Sets the max torque of the motors.
void setMaxTorque(double value, torqueUnits units)
Sets the max torque of the motors.
void setStopping(brakeType mode)
Sets the stopping mode of the motor group by passing a brake mode as a parameter.
double current(currentUnits units=currentUnits::amp)
Gets the sum electrical current for all motors in the group.
void setTimeout(int32_t time, timeUnits units)
Sets the timeout for the motor group. If the motor group does not reach its' commanded position prior...
double temperature(temperatureUnits units)
Gets the temperature of the motor.
void resetPosition(void)
Resets the motor's encoder to the value of zero.
void setVelocity(double velocity, velocityUnits units)
Sets the velocity of the motor group based on the parameters set in the command. This command will no...
bool isSpinning(void)
Checks to see if any of the motors are rotating to a specific target.
directionType direction(void)
Gets which direction the first motor in the group is spinning.
int32_t count(void)
return the number of motors in the motor group
bool isDone(void)
Checks to see if all the motor are done rotating to a specific target.
double voltage(voltageUnits units=voltageUnits::volt)
Gets the voltage of the first motor in the group.
void spin(directionType dir)
Turns the motors on, and spins them in the specified direction.
bool spinFor(double rotation, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and spin them to a relative target rotation value.
void spin(directionType dir, double voltage, voltageUnits units)
Turn on the motors and spins them in the specified direction and a specified voltage.
void spin(directionType dir, double velocity, velocityUnits units)
Turn on the motors and spins them in the specified direction and a specified velocity.
void stop(brakeType mode)
Stops all motors using a specified brake mode.
void setPosition(double value, rotationUnits units)
Sets the value of all motor encoders to the value specified in the parameter.
double torque(torqueUnits units=torqueUnits::Nm)
Gets the torque of the first motor in the group.
double temperature(percentUnits units=percentUnits::pct)
Gets the temperature of the first motor in the group.
bool spinTo(double rotation, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and spin them to an absolute target rotation value.
bool spinTo(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turns on the motors and spin them to an absolute target rotation value at a specified velocity.
Use the motor class to control motor devices.
Definition vex_motor.h:34
Bumper switch device class
Definition vex_brain.h:24