LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
odomChassisController.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
17#include <atomic>
18#include <memory>
19#include <valarray>
20
21namespace okapi {
23 public:
41 std::shared_ptr<Odometry> iodometry,
43 const QLength &imoveThreshold = 0_mm,
44 const QAngle &iturnThreshold = 0_deg,
45 std::shared_ptr<Logger> ilogger = Logger::getDefaultLogger());
46
48
53
62 virtual void
63 driveToPoint(const Point &ipoint, bool ibackwards = false, const QLength &ioffset = 0_mm) = 0;
64
70 virtual void turnToPoint(const Point &ipoint) = 0;
71
77 virtual void turnToAngle(const QAngle &iangle) = 0;
78
82 virtual OdomState getState() const;
83
91 virtual void setState(const OdomState &istate);
92
99 void setDefaultStateMode(const StateMode &imode);
100
106 virtual void setMoveThreshold(const QLength &imoveThreshold);
107
113 virtual void setTurnThreshold(const QAngle &iturnTreshold);
114
118 virtual QLength getMoveThreshold() const;
119
123 virtual QAngle getTurnThreshold() const;
124
129
134
138 std::shared_ptr<Odometry> getOdometry();
139
140 protected:
141 std::shared_ptr<Logger> logger;
145 std::shared_ptr<Odometry> odom;
147 std::atomic_bool dtorCalled{false};
149 std::atomic_bool odomTaskRunning{false};
150
151 static void trampoline(void *context);
152 void loop();
153};
154} // namespace okapi
static std::shared_ptr< Logger > getDefaultLogger()
OdomChassisController & operator=(OdomChassisController &&other)=delete
virtual void turnToPoint(const Point &ipoint)=0
Turns the robot to face a point in the odom frame.
void startOdomThread()
Starts the internal odometry thread.
virtual QLength getMoveThreshold() const
CrossplatformThread * getOdomThread() const
void setDefaultStateMode(const StateMode &imode)
Sets a default StateMode that will be used to interpret target points and query the Odometry state.
OdomChassisController(OdomChassisController &&other)=delete
virtual void setMoveThreshold(const QLength &imoveThreshold)
Set a new move threshold.
virtual OdomState getState() const
std::shared_ptr< Odometry > getOdometry()
static void trampoline(void *context)
OdomChassisController & operator=(const OdomChassisController &other)=delete
virtual void driveToPoint(const Point &ipoint, bool ibackwards=false, const QLength &ioffset=0_mm)=0
Drives the robot straight to a point in the odom frame.
virtual void turnToAngle(const QAngle &iangle)=0
Turns the robot to face an angle in the odom frame.
OdomChassisController(const OdomChassisController &)=delete
virtual void setTurnThreshold(const QAngle &iturnTreshold)
Set a new turn threshold.
OdomChassisController(TimeUtil itimeUtil, std::shared_ptr< Odometry > iodometry, const StateMode &imode=StateMode::FRAME_TRANSFORMATION, const QLength &imoveThreshold=0_mm, const QAngle &iturnThreshold=0_deg, std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger())
Odometry based chassis controller.
std::shared_ptr< Odometry > odom
virtual QAngle getTurnThreshold() const
virtual void setState(const OdomState &istate)
Set a new state to be the current state.
Utility class for holding an AbstractTimer, AbstractRate, and SettledUtil together in one class since...
Definition timeUtil.hpp:18
StateMode
The mode for the OdomState calculated by Odometry.
Definition stateMode.hpp:12
@ FRAME_TRANSFORMATION
+x is forward, +y is right, 0 degrees is along +x