Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
base_motor.h
1#pragma once
2#include "../../control/JacobianVelController.h"
3#include "../../utils/scheduler.h"
4#include "../data.h"
5
10namespace robot {
16public:
23 base_motor(robot::types::motorid_t motor, bool hasPosSensor);
24
30 bool hasPositionSensor() const;
31
37 virtual void setMotorPower(double power) = 0;
38
46 virtual void setMotorPos(int32_t targetPos) = 0;
47
56
62 virtual void setMotorVel(int32_t targetVel);
63
69 base_motor(const base_motor&) = delete;
70
76 base_motor& operator=(const base_motor&) = delete;
77
78protected:
80 bool posSensor;
81 std::optional<util::PeriodicScheduler<std::chrono::steady_clock>::eventid_t> velEventID;
82 std::optional<JacobianVelController<1, 1>> velController;
83
84 inline static std::optional<util::PeriodicScheduler<std::chrono::steady_clock>> pSched;
85 inline static std::mutex schedulerMutex;
86
91
96}; // abstract class base_motor
97} // namespace robot
_Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
virtual types::DataPoint< int32_t > getMotorPos() const =0
Get the last reported position of the specified motor.
base_motor(robot::types::motorid_t motor, bool hasPosSensor)
Constructor for base motor.
Definition base_motor.cpp:6
base_motor & operator=(const base_motor &)=delete
Delete the copy operator.
void unscheduleVelocityEvent()
Unschedules the velocity event if it exists.
Definition base_motor.cpp:71
bool hasPositionSensor() const
Returns the status of the motor position sensor.
Definition base_motor.cpp:15
virtual void setMotorVel(int32_t targetVel)
Sets the velocity of the motor.
Definition base_motor.cpp:19
virtual void setMotorPower(double power)=0
Set the PWM command of the motor.
void constructVelController()
Constructs a Jacobian Vel Controller.
Definition base_motor.cpp:45
virtual void setMotorPos(int32_t targetPos)=0
Set the target position of the motor.
base_motor(const base_motor &)=delete
Delete the copy constructor.
Represents data measured using a sensor at a given time.
Definition data.h:136
::int32_t int32_t
motorid_t
The motors on the robot.
Definition data.h:57
Collection of functions for manipulating a motor.
Definition ArduPilotInterface.cpp:27