LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
hDriveModel.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
11
12namespace okapi {
13class HDriveModel : public ChassisModel {
14 public:
28 HDriveModel(std::shared_ptr<AbstractMotor> ileftSideMotor,
29 std::shared_ptr<AbstractMotor> irightSideMotor,
30 std::shared_ptr<AbstractMotor> imiddleMotor,
31 std::shared_ptr<ContinuousRotarySensor> ileftEnc,
32 std::shared_ptr<ContinuousRotarySensor> irightEnc,
33 std::shared_ptr<ContinuousRotarySensor> imiddleEnc,
34 double imaxVelocity,
35 double imaxVoltage);
36
43 void forward(double ispeed) override;
44
56 void driveVector(double iySpeed, double izRotation) override;
57
68 void driveVectorVoltage(double iforwardSpeed, double iyaw) override;
69
76 void rotate(double ispeed) override;
77
81 void stop() override;
82
91 void tank(double ileftSpeed, double irightSpeed, double ithreshold = 0) override;
92
101 void arcade(double iforwardSpeed, double iyaw, double ithreshold = 0) override;
102
113 void curvature(double iforwardSpeed, double icurvature, double ithreshold = 0) override;
114
123 virtual void
124 hArcade(double irightSpeed, double iforwardSpeed, double iyaw, double ithreshold = 0);
125
134 virtual void
135 hCurvature(double irightSpeed, double iforwardSpeed, double icurvature, double ithreshold = 0);
136
142 void left(double ispeed) override;
143
149 void right(double ispeed) override;
150
156 virtual void middle(double ispeed);
157
163 std::valarray<std::int32_t> getSensorVals() const override;
164
168 void resetSensors() override;
169
176
183
189 void setGearing(AbstractMotor::gearset gearset) override;
190
199 void setMaxVelocity(double imaxVelocity) override;
200
204 double getMaxVelocity() const override;
205
211 void setMaxVoltage(double imaxVoltage) override;
212
216 double getMaxVoltage() const override;
217
223 std::shared_ptr<AbstractMotor> getLeftSideMotor() const;
224
230 std::shared_ptr<AbstractMotor> getRightSideMotor() const;
231
235 std::shared_ptr<AbstractMotor> getMiddleMotor() const;
236
237 protected:
240 std::shared_ptr<AbstractMotor> leftSideMotor;
241 std::shared_ptr<AbstractMotor> rightSideMotor;
242 std::shared_ptr<AbstractMotor> middleMotor;
243 std::shared_ptr<ContinuousRotarySensor> leftSensor;
244 std::shared_ptr<ContinuousRotarySensor> rightSensor;
245 std::shared_ptr<ContinuousRotarySensor> middleSensor;
246};
247} // 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.
void rotate(double ispeed) override
Turn the robot clockwise (using open-loop control).
double getMaxVoltage() const override
void setBrakeMode(AbstractMotor::brakeMode mode) override
Set the brake mode for each motor.
std::shared_ptr< AbstractMotor > getMiddleMotor() const
void forward(double ispeed) override
Drive the robot forwards (using open-loop control).
void resetSensors() override
Reset the sensors to their zero point.
std::shared_ptr< AbstractMotor > getRightSideMotor() const
Returns the left side motor.
void right(double ispeed) override
Power the right side motors.
void setGearing(AbstractMotor::gearset gearset) override
Set the gearset for each motor.
void stop() override
Stop the robot (set all the motors to 0).
void arcade(double iforwardSpeed, double iyaw, double ithreshold=0) override
Drive the robot with an arcade drive layout.
double getMaxVelocity() const override
std::shared_ptr< ContinuousRotarySensor > leftSensor
std::shared_ptr< ContinuousRotarySensor > middleSensor
virtual void hCurvature(double irightSpeed, double iforwardSpeed, double icurvature, double ithreshold=0)
Drive the robot with an curvature drive layout.
void tank(double ileftSpeed, double irightSpeed, double ithreshold=0) override
Drive the robot with a tank drive layout.
void left(double ispeed) override
Power the left side motors.
void setMaxVoltage(double imaxVoltage) override
Sets a new maximum voltage in mV in the range [0-12000].
std::shared_ptr< AbstractMotor > getLeftSideMotor() const
Returns the left side motor.
virtual void hArcade(double irightSpeed, double iforwardSpeed, double iyaw, double ithreshold=0)
Drive the robot with an arcade drive layout.
void driveVector(double iySpeed, double izRotation) override
Drive the robot in an arc (using open-loop control).
std::shared_ptr< AbstractMotor > rightSideMotor
HDriveModel(std::shared_ptr< AbstractMotor > ileftSideMotor, std::shared_ptr< AbstractMotor > irightSideMotor, std::shared_ptr< AbstractMotor > imiddleMotor, std::shared_ptr< ContinuousRotarySensor > ileftEnc, std::shared_ptr< ContinuousRotarySensor > irightEnc, std::shared_ptr< ContinuousRotarySensor > imiddleEnc, double imaxVelocity, double imaxVoltage)
Model for an h-drive (wheels parallel with robot's direction of motion, with an additional wheel perp...
virtual void middle(double ispeed)
Power the middle motors.
void setEncoderUnits(AbstractMotor::encoderUnits units) override
Set the encoder units for each motor.
void setMaxVelocity(double imaxVelocity) override
Sets a new maximum velocity in RPM.
void curvature(double iforwardSpeed, double icurvature, double ithreshold=0) override
Drive the robot with a curvature drive layout.
std::shared_ptr< ContinuousRotarySensor > rightSensor
std::valarray< std::int32_t > getSensorVals() const override
Read the sensors.
void driveVectorVoltage(double iforwardSpeed, double iyaw) override
Drive the robot in an arc.
std::shared_ptr< AbstractMotor > leftSideMotor
std::shared_ptr< AbstractMotor > middleMotor