LemLib  0.4.7
An easy to use and feature-rich PROS template
Loading...
Searching...
No Matches
chassis.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include "pros/motors.hpp"
15#include "pros/imu.hpp"
17#include "lemlib/pose.hpp"
18
19namespace lemlib {
33typedef struct {
34 TrackingWheel* vertical1;
35 TrackingWheel* vertical2;
36 TrackingWheel* horizontal1;
37 TrackingWheel* horizontal2;
38 pros::Imu* imu;
40
55typedef struct {
56 float kP;
57 float kD;
58 float smallError;
59 float smallErrorTimeout;
60 float largeError;
61 float largeErrorTimeout;
62 float slew;
64
77typedef struct {
78 pros::Motor_Group* leftMotors;
79 pros::Motor_Group* rightMotors;
80 float trackWidth;
81 float wheelDiameter;
82 float rpm;
84
89class Chassis {
90 public:
99 Chassis(Drivetrain_t drivetrain, ChassisController_t lateralSettings, ChassisController_t angularSettings,
100 OdomSensors_t sensors);
105 void calibrate();
114 void setPose(double x, double y, double theta, bool radians = false);
121 void setPose(Pose pose, bool radians = false);
128 Pose getPose(bool radians = false);
141 void turnTo(float x, float y, int timeout, bool reversed = false, float maxSpeed = 127, bool log = false);
153 void moveTo(float x, float y, int timeout, float maxSpeed = 200, bool log = false);
165 void follow(const char* filePath, int timeout, float lookahead, bool reverse = false, float maxSpeed = 127,
166 bool log = false);
167 private:
168 ChassisController_t lateralSettings;
169 ChassisController_t angularSettings;
170 Drivetrain_t drivetrain;
171 OdomSensors_t odomSensors;
172};
173} // namespace lemlib
Chassis class.
Definition: chassis.hpp:89
void moveTo(float x, float y, int timeout, float maxSpeed=200, bool log=false)
Move the chassis towards the target point.
Pose getPose(bool radians=false)
Get the pose of the chassis.
Chassis(Drivetrain_t drivetrain, ChassisController_t lateralSettings, ChassisController_t angularSettings, OdomSensors_t sensors)
Construct a new Chassis.
void follow(const char *filePath, int timeout, float lookahead, bool reverse=false, float maxSpeed=127, bool log=false)
Move the chassis along a path.
void calibrate()
Calibrate the chassis sensors.
void setPose(Pose pose, bool radians=false)
Set the pose of the chassis.
void setPose(double x, double y, double theta, bool radians=false)
Set the pose of the chassis.
void turnTo(float x, float y, int timeout, bool reversed=false, float maxSpeed=127, bool log=false)
Turn the chassis so it is facing the target point.
Definition: pose.hpp:14
Definition: trackingWheel.hpp:19
Pose class declarations.
Struct containing constants for a chassis controller.
Definition: chassis.hpp:55
Struct containing constants for a drivetrain.
Definition: chassis.hpp:77
Struct containing all the sensors used for odometry.
Definition: chassis.hpp:33
tracking wheel class declarations
float slew(float target, float current, float maxChange)
Slew rate limiter.