LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
xDriveModel.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
12
13namespace okapi {
14class XDriveModel : public ChassisModel {
15 public:
27 XDriveModel(std::shared_ptr<AbstractMotor> itopLeftMotor,
28 std::shared_ptr<AbstractMotor> itopRightMotor,
29 std::shared_ptr<AbstractMotor> ibottomRightMotor,
30 std::shared_ptr<AbstractMotor> ibottomLeftMotor,
31 std::shared_ptr<ContinuousRotarySensor> ileftEnc,
32 std::shared_ptr<ContinuousRotarySensor> irightEnc,
33 double imaxVelocity,
34 double imaxVoltage);
35
41 void forward(double ipower) override;
42
52 void driveVector(double iforwardSpeed, double iyaw) override;
53
63 void driveVectorVoltage(double iforwardSpeed, double iyaw) override;
64
70 void rotate(double ipower) override;
71
78 void strafe(double ipower);
79
92 void strafeVector(double istrafeSpeed, double iyaw);
93
97 void stop() override;
98
106 void tank(double ileftSpeed, double irightSpeed, double ithreshold = 0) override;
107
115 void arcade(double iforwardSpeed, double iyaw, double ithreshold = 0) override;
116
127 void curvature(double iforwardSpeed, double icurvature, double ithreshold = 0) override;
128
137 virtual void
138 xArcade(double irightSpeed, double iforwardSpeed, double iyaw, double ithreshold = 0);
139
155 virtual void fieldOrientedXArcade(double ixSpeed,
156 double iySpeed,
157 double iyaw,
158 QAngle iangle,
159 double ithreshold = 0);
160
166 void left(double ispeed) override;
167
173 void right(double ispeed) override;
174
180 std::valarray<std::int32_t> getSensorVals() const override;
181
185 void resetSensors() override;
186
193
200
206 void setGearing(AbstractMotor::gearset gearset) override;
207
216 void setMaxVelocity(double imaxVelocity) override;
217
221 double getMaxVelocity() const override;
222
228 void setMaxVoltage(double imaxVoltage) override;
229
233 double getMaxVoltage() const override;
234
240 std::shared_ptr<AbstractMotor> getTopLeftMotor() const;
241
247 std::shared_ptr<AbstractMotor> getTopRightMotor() const;
248
254 std::shared_ptr<AbstractMotor> getBottomRightMotor() const;
255
261 std::shared_ptr<AbstractMotor> getBottomLeftMotor() const;
262
263 protected:
266 std::shared_ptr<AbstractMotor> topLeftMotor;
267 std::shared_ptr<AbstractMotor> topRightMotor;
268 std::shared_ptr<AbstractMotor> bottomRightMotor;
269 std::shared_ptr<AbstractMotor> bottomLeftMotor;
270 std::shared_ptr<ContinuousRotarySensor> leftSensor;
271 std::shared_ptr<ContinuousRotarySensor> rightSensor;
272};
273} // namespace okapi
brakeMode
Indicates the 'brake mode' of a motor.
gearset
Indicates the internal gear ratio of a motor.
encoderUnits
Indicates the units used by the motor encoders.
A version of the ReadOnlyChassisModel that also supports write methods, such as setting motor speed.
XDriveModel(std::shared_ptr< AbstractMotor > itopLeftMotor, std::shared_ptr< AbstractMotor > itopRightMotor, std::shared_ptr< AbstractMotor > ibottomRightMotor, std::shared_ptr< AbstractMotor > ibottomLeftMotor, std::shared_ptr< ContinuousRotarySensor > ileftEnc, std::shared_ptr< ContinuousRotarySensor > irightEnc, double imaxVelocity, double imaxVoltage)
Model for an x drive (wheels at 45 deg from a skid steer drive).
void arcade(double iforwardSpeed, double iyaw, double ithreshold=0) override
Drive the robot with an arcade drive layout.
void strafe(double ipower)
Drive the robot side-ways (using open-loop control) where positive ipower is to the right and negativ...
std::shared_ptr< ContinuousRotarySensor > leftSensor
virtual void fieldOrientedXArcade(double ixSpeed, double iySpeed, double iyaw, QAngle iangle, double ithreshold=0)
Drive the robot with a field-oriented arcade drive layout.
void setBrakeMode(AbstractMotor::brakeMode mode) override
Set the brake mode for each motor.
void driveVectorVoltage(double iforwardSpeed, double iyaw) override
Drive the robot in an arc.
void forward(double ipower) override
Drive the robot forwards (using open-loop control).
void tank(double ileftSpeed, double irightSpeed, double ithreshold=0) override
Drive the robot with a tank drive layout.
void stop() override
Stop the robot (set all the motors to 0).
std::valarray< std::int32_t > getSensorVals() const override
Read the sensors.
double getMaxVoltage() const override
std::shared_ptr< AbstractMotor > bottomRightMotor
void setEncoderUnits(AbstractMotor::encoderUnits units) override
Set the encoder units for each motor.
void curvature(double iforwardSpeed, double icurvature, double ithreshold=0) override
Drive the robot with a curvature drive layout.
void setMaxVoltage(double imaxVoltage) override
Sets a new maximum voltage in mV in the range [0-12000].
std::shared_ptr< AbstractMotor > getTopLeftMotor() const
Returns the top left motor.
std::shared_ptr< AbstractMotor > topLeftMotor
void right(double ispeed) override
Power the right side motors.
std::shared_ptr< AbstractMotor > getBottomLeftMotor() const
Returns the bottom left motor.
double getMaxVelocity() const override
std::shared_ptr< AbstractMotor > getBottomRightMotor() const
Returns the bottom right motor.
void driveVector(double iforwardSpeed, double iyaw) override
Drive the robot in an arc (using open-loop control).
std::shared_ptr< ContinuousRotarySensor > rightSensor
void strafeVector(double istrafeSpeed, double iyaw)
Strafe the robot in an arc (using open-loop control) where positive istrafeSpeed is to the right and ...
void rotate(double ipower) override
Turn the robot clockwise (using open-loop control).
std::shared_ptr< AbstractMotor > getTopRightMotor() const
Returns the top right motor.
std::shared_ptr< AbstractMotor > topRightMotor
std::shared_ptr< AbstractMotor > bottomLeftMotor
virtual void xArcade(double irightSpeed, double iforwardSpeed, double iyaw, double ithreshold=0)
Drive the robot with an arcade drive layout.
void left(double ispeed) override
Power the left side motors.
void resetSensors() override
Reset the sensors to their zero point.
void setGearing(AbstractMotor::gearset gearset) override
Set the gearset for each motor.
void setMaxVelocity(double imaxVelocity) override
Sets a new maximum velocity in RPM.