ART v1.0-alpha
A Robot Template that raises the floor for VRC teams
Loading...
Searching...
No Matches
SmartDrive.h
Go to the documentation of this file.
1
15#pragma once
16
17#include "ART/Vec2.h"
18#include "ART/PID.h"
19#include "ART/Units.h"
20#include "ART/TankDrive.h"
21
22#include <memory>
23#include <cmath>
24
25namespace art
26{
27
47 class SmartDrive : public TankDrive
48 {
49 public:
61 SmartDrive(TankDrive drive, vex::inertial inert);
62
91
113 SmartDrive &withGearRatio(double ratio);
114
141 SmartDrive &withHorizontalTracker(vex::rotation rotation, Length wheelSize, double gearRatio);
142
171 SmartDrive &withHorizontalTracker(vex::rotation rotation, Length wheelSize, double gearRatio, Length wheelOffset);
172
188 int track();
189
216 void driveFor(Length target, double speed);
217
232 void driveForPID(Length target);
233
247
267
296 void turnFor(Angle target, double speed);
297
312 void turnForPID(Angle target);
313
327
347
382 void turnTo(Angle target, double speed);
383
398 void turnToPID(Angle target);
399
413
433
444
445 private:
463 {
476
487 HorizontalTracker(vex::rotation rotation, Length wheelSize, double gearRatio);
500 HorizontalTracker(vex::rotation rotation, Length wheelSize, double gearRatio, Length wheelOffset);
501
516
529 std::shared_ptr<vex::rotation> m_rotation{nullptr};
555 double m_gearRatio{1.0};
556
577
584 };
585
593
622
631 vex::inertial m_inert;
632
658 double m_gearRatio{1.0};
659
669
676
686
693
694 };
695
696} // namespace art
Header containing a general use PID class.
Header containing the TankDrive class.
Header containing several Unit classes.
Header containing the 2d Vector class.
A Utility Unit class for Angles.
Definition Units.h:275
A Utility Unit class for Length.
Definition Units.h:37
A general use PID class.
Definition PID.h:59
A Smarter Drive Class.
Definition SmartDrive.h:48
void turnForPID(Angle target)
Turns for a specified angle (and stops)
void turnToPID(Angle target)
Turns tp a specified angle (and stops)
SmartDrive & withTurnForPID(PID pid)
Sets the PID object for the turnForPID Method.
Angle m_LastLeftPos
The last angle read from the Left motors.
Definition SmartDrive.h:675
Angle m_dir
Stores the current heading of the robot.
Definition SmartDrive.h:621
PID m_driveForPID
The PID object for the driveFor Method.
Definition SmartDrive.h:246
HorizontalTracker m_tracker
Stores the Horizontal Tracker.
Definition SmartDrive.h:592
Angle getRightTravel()
Gets the Angle traveled by the left motors.
SmartDrive & withTurnToPID(PID pid)
Sets the PID object for the turnToPID Method.
Vec2 m_pos
Stores the Position of the robot.
Definition SmartDrive.h:602
double m_gearRatio
A double representing the gear ratio of the drivetrain.
Definition SmartDrive.h:658
SmartDrive(TankDrive drive, vex::inertial inert)
Construct a new Smart Drive object.
Angle getLeftTravel()
Gets the Angle traveled by the left motors.
Angle m_LastRightPos
The last angle read from the Right motors.
Definition SmartDrive.h:692
Length getWheelTravel()
Get the Travel of the wheels for one revolution of the motor.
SmartDrive & withGearRatio(double ratio)
Sets the gear ratio of the drivetrain.
SmartDrive & withWheelSize(Length size)
Sets the wheel size of the Smart Drive.
int track()
Continuously tracks and updates the position of the SmartDrive.
vex::inertial m_inert
Stores the inertial sensor object.
Definition SmartDrive.h:631
Length m_wheelSize
A Length representing the diameter of the wheel.
Definition SmartDrive.h:645
PID m_turnForPID
The PID object for the turnForPID Method.
Definition SmartDrive.h:326
SmartDrive & withHorizontalTracker(vex::rotation rotation, Length wheelSize, double gearRatio)
Add Horizontal Tracker to the SmartDrive.
Vec2 m_centerPos
Stores the Center Position of the robot.
Definition SmartDrive.h:610
void turnFor(Angle target, double speed)
Turns for a specified Angle.
SmartDrive & withDriveForPID(PID pid)
Sets the PID object for the driveForPID Method.
PID m_turnToPID
The PID object for the turnToPID Method.
Definition SmartDrive.h:412
void turnTo(Angle target, double speed)
Turns to a specified field-centric Angle.
void driveFor(Length target, double speed)
Drives for a specified distance.
void driveForPID(Length target)
Drives for a specified distance (and stops)
A Simple TankDrive class.
Definition TankDrive.h:55
Definition PID.h:20
Length Inches(double inches)
Constructs a Length from Inches.
Definition Units.cpp:78
A struct for tracking the robot's lateral displacement.
Definition SmartDrive.h:463
Length m_wheelSize
A Length representing the diameter of the wheel.
Definition SmartDrive.h:542
Angle m_travelAngle
Stores the change in angle since the last call of getTravel()
Definition SmartDrive.h:569
HorizontalTracker()
Construct an empty Horizontal Tracker object.
Angle m_lastAngle
Stores the last angle recorded from the encoder.
Definition SmartDrive.h:563
double m_gearRatio
A double representing the gear ratio of the tracker.
Definition SmartDrive.h:555
Length getTravel()
Get the distance traveled by the Horizontal Tracker.
Length m_offset
Stores a Length representing the vertical distance from horizontal tracker to the tracking center (po...
Definition SmartDrive.h:583
Length m_travelDistance
Stores the distance traveled.
Definition SmartDrive.h:576
std::shared_ptr< vex::rotation > m_rotation
A Pointer to a rotation sensor object.
Definition SmartDrive.h:529
A Utility 2D Vector class.
Definition Vec2.h:39