Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Toggle main menu visibility
Loading...
Searching...
No Matches
src
world_interface
motor
base_motor.h
1
#pragma once
2
#include "../../control/JacobianVelController.h"
3
#include "../../utils/scheduler.h"
4
#include "../data.h"
5
10
namespace
robot
{
15
class
base_motor
{
16
public
:
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
55
virtual
types::DataPoint<int32_t>
getMotorPos
()
const
= 0;
56
62
virtual
void
setMotorVel
(
int32_t
targetVel);
63
64
virtual
void
setServoPos(
uint8_t
servo,
int32_t
position) = 0;
65
66
virtual
void
setStepperTurnAngle(
uint8_t
stepper,
int16_t
angle) = 0;
67
73
base_motor
(
const
base_motor
&) =
delete
;
74
80
base_motor
&
operator=
(
const
base_motor
&) =
delete
;
81
82
protected
:
83
robot::types::motorid_t
motor_id;
84
bool
posSensor;
85
std::optional<util::PeriodicScheduler<std::chrono::steady_clock>::eventid_t> velEventID;
86
std::optional<JacobianVelController<1, 1>> velController;
87
88
inline
static
std::optional<util::PeriodicScheduler<std::chrono::steady_clock>> pSched;
89
inline
static
std::mutex
schedulerMutex;
90
94
void
constructVelController
();
95
99
void
unscheduleVelocityEvent
();
100
};
// abstract class base_motor
101
}
// namespace robot
power
_Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
std::mutex
robot::base_motor::getMotorPos
virtual types::DataPoint< int32_t > getMotorPos() const =0
Get the last reported position of the specified motor.
robot::base_motor::base_motor
base_motor(robot::types::motorid_t motor, bool hasPosSensor)
Constructor for base motor.
Definition
base_motor.cpp:6
robot::base_motor::operator=
base_motor & operator=(const base_motor &)=delete
Delete the copy operator.
robot::base_motor::unscheduleVelocityEvent
void unscheduleVelocityEvent()
Unschedules the velocity event if it exists.
Definition
base_motor.cpp:71
robot::base_motor::hasPositionSensor
bool hasPositionSensor() const
Returns the status of the motor position sensor.
Definition
base_motor.cpp:15
robot::base_motor::setMotorVel
virtual void setMotorVel(int32_t targetVel)
Sets the velocity of the motor.
Definition
base_motor.cpp:19
robot::base_motor::setMotorPower
virtual void setMotorPower(double power)=0
Set the PWM command of the motor.
robot::base_motor::constructVelController
void constructVelController()
Constructs a Jacobian Vel Controller.
Definition
base_motor.cpp:45
robot::base_motor::setMotorPos
virtual void setMotorPos(int32_t targetPos)=0
Set the target position of the motor.
robot::base_motor::base_motor
base_motor(const base_motor &)=delete
Delete the copy constructor.
robot::types::DataPoint
Represents data measured using a sensor at a given time.
Definition
data.h:182
uint8_t
::uint8_t uint8_t
int32_t
::int32_t int32_t
int16_t
::int16_t int16_t
robot::types::motorid_t
motorid_t
The motors on the robot.
Definition
data.h:57
robot
Collection of functions for manipulating a motor.
Definition
ArduPilotInterface.cpp:27
Generated by
1.17.0