Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
can_motor.h
1#pragma once
2
3#include "../../CAN/CAN.h"
4#include "../../CAN/CANMotor.h"
5#include "../../CAN/CANUtils.h"
6#include "base_motor.h"
7
12namespace robot {
13class can_motor : public base_motor {
14public:
24 can_motor(robot::types::motorid_t motor, bool hasPosSensor, can::deviceserial_t serial,
25 can::devicegroup_t group, double pos_pwm_scale, double neg_pwm_scale);
26
27 void setMotorPower(double power) override;
28
29 void setMotorPos(int32_t targetPos) override;
30
32
33 void setMotorVel(int32_t targetVel) override;
34
35 void setServoPos(uint8_t servo, int32_t position) override;
36
37 void setStepperTurnAngle(uint8_t stepper, int16_t angle) override;
38
43
44private:
45 can::deviceserial_t serial_id;
46 can::devicegroup_t device_group;
47 std::optional<can::motor::motormode_t> motor_mode;
48 double positive_scale;
49 double negative_scale;
50 void ensureMotorMode(robot::types::motorid_t motor, can::motor::motormode_t mode);
51}; // class can_motor
52} // namespace robot
_Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
base_motor(robot::types::motorid_t motor, bool hasPosSensor)
Constructor for base motor.
Definition base_motor.cpp:6
types::DataPoint< int32_t > getMotorPos() const override
Get the last reported position of the specified motor.
Definition can_motor.cpp:31
can::deviceserial_t getMotorSerial()
Returns the motor's serial id.
Definition can_motor.cpp:50
void setMotorPower(double power) override
Set the PWM command of the motor.
Definition can_motor.cpp:10
can_motor(robot::types::motorid_t motor, bool hasPosSensor, can::deviceserial_t serial, can::devicegroup_t group, double pos_pwm_scale, double neg_pwm_scale)
Constructor for can motor.
Definition can_motor.cpp:4
void setMotorVel(int32_t targetVel) override
Sets the velocity of the motor.
Definition can_motor.cpp:35
void setMotorPos(int32_t targetPos) override
Set the target position of the motor.
Definition can_motor.cpp:22
Represents data measured using a sensor at a given time.
Definition data.h:182
motormode_t
The possible motor modes.
Definition CANMotor.h:19
devicegroup_t
The possible device group codes.
Definition CANUtils.h:20
uint8_t deviceserial_t
The type of the device serial number.
Definition CANUtils.h:67
::uint8_t uint8_t
::int32_t int32_t
::int16_t int16_t
motorid_t
The motors on the robot.
Definition data.h:57
Collection of functions for manipulating a motor.
Definition ArduPilotInterface.cpp:27