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 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
39
40private:
41 can::deviceserial_t serial_id;
42 std::optional<can::motor::motormode_t> motor_mode;
43 double positive_scale;
44 double negative_scale;
45 void ensureMotorMode(robot::types::motorid_t motor, can::motor::motormode_t mode);
46}; // class can_motor
47} // 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:30
can::deviceserial_t getMotorSerial()
Returns the motor's serial id.
Definition can_motor.cpp:39
void setMotorPower(double power) override
Set the PWM command of the motor.
Definition can_motor.cpp:9
void setMotorVel(int32_t targetVel) override
Sets the velocity of the motor.
Definition can_motor.cpp:34
void setMotorPos(int32_t targetPos) override
Set the target position of the motor.
Definition can_motor.cpp:21
can_motor(robot::types::motorid_t motor, bool hasPosSensor, can::deviceserial_t serial, double pos_pwm_scale, double neg_pwm_scale)
Constructor for can motor.
Definition can_motor.cpp:4
Represents data measured using a sensor at a given time.
Definition data.h:136
motormode_t
The possible motor modes.
Definition CANMotor.h:19
uint8_t deviceserial_t
The type of the device serial number.
Definition CANUtils.h:64
::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