VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex_smartdrive.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* */
3/* Copyright (c) Innovation First 2019, All rights reserved. */
4/* */
5/* Module: vex_smartdrive.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_DRIVETRAIN_EXT_CLASS_H
15#define VEX_DRIVETRAIN_EXT_CLASS_H
16
17/*-----------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace vex {
23
24 class smartdrive : public drivetrain {
25 public:
26 smartdrive( motor_group &l, motor_group &r, vex::gyro &g, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio = 1.0 );
27 smartdrive( vex::motor &l, vex::motor &r, vex::gyro &g, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio = 1.0 );
28
30
31 void setTurnThreshold( double t );
32 void setTurnConstant( double kp );
33
34 smartdrive & setTurnDirectionReverse( bool value );
35
43 bool turnToHeading( double angle, rotationUnits units, bool waitForCompletion=true );
44
54 bool turnToHeading( double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
55
63 bool turnToRotation( double angle, rotationUnits units, bool waitForCompletion=true );
64
74 bool turnToRotation( double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
75
84 virtual bool turnFor( turnType dir, double angle, rotationUnits units, bool waitForCompletion=true );
85
86 virtual bool turnFor( double angle, rotationUnits units, bool waitForCompletion=true );
87
98 virtual bool turnFor( turnType dir, double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
99
100 virtual bool turnFor( double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true );
101
107 void setHeading( double value, rotationUnits units );
108
114 double heading( rotationUnits units = rotationUnits::deg );
115
121 double rotation( rotationUnits units = rotationUnits::deg );
122
128 void setRotation( double value, rotationUnits units );
129
130
135 bool isTurning();
136
137 virtual bool isMoving();
138
139 private:
140 vex::gyro *g;
141 double _targetAngle;
142 turnType _targetDir;
143 int32_t _timeout;
144 bool _turning;
145 bool _blocked;
146 bool _abortCheck;
147 bool _eventsInitialized;
148 double _turnThreshold;
149 double _turnKp;
150 double _turningVelocity;
151 velocityUnits _turningVelocityUnits;
152
153 turnType _turnPositive;
154 turnType _turnNegative;
155
156 static void _gyropoll( void *arg );
157 void _initevents();
158 bool _testForCompletionGyro();
159 bool _waitForCompletionGyro();
160
161 enum class tEventType {
162 EVENT_GYRO_POLL = 4
163 };
164 };
165}
166
167#endif // VEX_DRIVETRAIN_EXT_CLASS_H
double velocity(velocityUnits units)
Gets the average velocity of the drivetrain;.
Use the motor class to control motor devices.
Definition vex_motor.h:34
bool turnToHeading(double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turn on the motors and rotate to a heading at a specified velocity.
virtual bool turnFor(double angle, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and rotate an angle at the default velocity.
virtual bool turnFor(turnType dir, double angle, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and rotate an angle at the default velocity.
bool turnToRotation(double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turn on the motors and rotate to an angle at a specified velocity.
virtual bool turnFor(double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turn on the motors and rotate an angle at a specified velocity.
double heading(rotationUnits units=rotationUnits::deg)
Gets the heading (angle) of the gyro sensor.
bool isTurning()
Checks to see if the turnToHeading, turnToRotation or turnFor function is still running.
void setHeading(double value, rotationUnits units)
set the gyro sensor heading to angle
double rotation(rotationUnits units=rotationUnits::deg)
Gets the rotation (absolute angle) of the gyro sensor.
bool turnToHeading(double angle, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and rotate to a heading at the default velocity.
bool turnToRotation(double angle, rotationUnits units, bool waitForCompletion=true)
Turn on the motors and rotate to an angle at the default velocity.
virtual bool turnFor(turnType dir, double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
Turn on the motors and rotate an angle at a specified velocity.
virtual bool isMoving()
Checks to see if any of the motors are rotating to a specific target.
void setRotation(double value, rotationUnits units)
set the gyro sensor rotation to angle
Bumper switch device class
Definition vex_brain.h:24