RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
SkidSteerChassis.hpp
1#pragma once
2#include <utility>
3
4#include "RaidZeroLib/api/Hardware/Motor.hpp"
5#include "RaidZeroLib/api/Units/Units.hpp"
6
7namespace rz {
8
23 public:
24 SkidSteerChassis(Motor& left, Motor& right) : left(left), right(right) {}
25
28
34
42 class [[nodiscard]] Lease {
43 public:
44 Lease(Lease&& other) noexcept : chassis(std::exchange(other.chassis, nullptr)) {}
45 Lease(const Lease&) = delete;
46 Lease& operator=(const Lease&) = delete;
47 Lease& operator=(Lease&&) = delete;
49
52 void apply(WheelVoltages command);
53
54 private:
55 friend class SkidSteerChassis;
56 explicit Lease(SkidSteerChassis& chassis) : chassis(&chassis) {}
57
58 SkidSteerChassis* chassis;
59 };
60
63 [[nodiscard]] Lease take();
64
65 private:
66 void apply(WheelVoltages command);
67
68 Motor& left;
69 Motor& right;
70 bool taken = false;
71};
72
73} // namespace rz
Something that turns a voltage into motion: a V5 motor, a motor group, a simulated motor,...
Definition Motor.hpp:13
The exclusive right to drive the chassis, held by whatever is driving it right now.
Definition SkidSteerChassis.hpp:42
Lease(const Lease &)=delete
Lease & operator=(const Lease &)=delete
Lease(Lease &&other) noexcept
Definition SkidSteerChassis.hpp:44
void apply(WheelVoltages command)
Commands both sides. If either exceeds 12 V, both are scaled down together so the robot keeps its cur...
Lease & operator=(Lease &&)=delete
friend class SkidSteerChassis
Definition SkidSteerChassis.hpp:55
SkidSteerChassis(const SkidSteerChassis &)=delete
Lease take()
Takes the exclusive right to drive.
SkidSteerChassis & operator=(const SkidSteerChassis &)=delete
SkidSteerChassis(Motor &left, Motor &right)
Definition SkidSteerChassis.hpp:24
au::QuantityD< au::Volts > Voltage
Definition Units.hpp:15
Definition DriverControl.hpp:11
One tick's command: a voltage for each side. Positive drives forward.
Definition SkidSteerChassis.hpp:30
Voltage left
Definition SkidSteerChassis.hpp:31
Voltage right
Definition SkidSteerChassis.hpp:32