Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
robot::can_motor Class Reference
Inheritance diagram for robot::can_motor:
Collaboration diagram for robot::can_motor:

Public Member Functions

 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.
 
void setMotorPower (double power) override
 Set the PWM command of the motor.
 
void setMotorPos (int32_t targetPos) override
 Set the target position of the motor.
 
types::DataPoint< int32_tgetMotorPos () const override
 Get the last reported position of the specified motor.
 
void setMotorVel (int32_t targetVel) override
 Sets the velocity of the motor.
 
void setServoPos (uint8_t servo, int32_t position) override
 
void setStepperTurnAngle (uint8_t stepper, int16_t angle) override
 
can::deviceserial_t getMotorSerial ()
 Returns the motor's serial id.
 
- Public Member Functions inherited from robot::base_motor
 base_motor (robot::types::motorid_t motor, bool hasPosSensor)
 Constructor for base motor.
 
bool hasPositionSensor () const
 Returns the status of the motor position sensor.
 
 base_motor (const base_motor &)=delete
 Delete the copy constructor.
 
base_motoroperator= (const base_motor &)=delete
 Delete the copy operator.
 

Additional Inherited Members

- Protected Member Functions inherited from robot::base_motor
void constructVelController ()
 Constructs a Jacobian Vel Controller.
 
void unscheduleVelocityEvent ()
 Unschedules the velocity event if it exists.
 
- Protected Attributes inherited from robot::base_motor
robot::types::motorid_t motor_id
 
bool posSensor
 
std::optional< util::PeriodicScheduler< std::chrono::steady_clock >::eventid_t > velEventID
 
std::optional< JacobianVelController< 1, 1 > > velController
 
- Static Protected Attributes inherited from robot::base_motor
static std::optional< util::PeriodicScheduler< std::chrono::steady_clock > > pSched
 
static std::mutex schedulerMutex
 

Constructor & Destructor Documentation

◆ can_motor()

robot::can_motor::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.

Parameters
motorThe motor id to manipulate.
hasPosSensorBoolean to indicate if the motor has a position sensor.
serialThe serial number of the motor board.
pos_pwm_scaleThe positive pwm scale for the motor power.
neg_pwm_scaleThe positive pwm scale for the motor power.

Member Function Documentation

◆ getMotorPos()

types::DataPoint< int32_t > robot::can_motor::getMotorPos ( ) const
overridevirtual

Get the last reported position of the specified motor.

Returns
types::DataPoint<int32_t> The last reported position of the motor, if it exists. If the motor has not reported a position (because it hasn't been received yet or if it doesn't have an encoder) then an empty data point is returned.

Implements robot::base_motor.

◆ setMotorPos()

void robot::can_motor::setMotorPos ( int32_t targetPos)
overridevirtual

Set the target position of the motor.

This will have no effect if the motor does not support PID.

Parameters
targetPosThe target position, in millidegrees. Refer to the specific motor for more information.

Implements robot::base_motor.

◆ setMotorPower()

void robot::can_motor::setMotorPower ( double power)
overridevirtual

Set the PWM command of the motor.

Parameters
powerThe power command, in the range [-1, 1]

Implements robot::base_motor.

◆ setMotorVel()

void robot::can_motor::setMotorVel ( int32_t targetVel)
overridevirtual

Sets the velocity of the motor.

Parameters
targetVelThe target velocity, in millidegrees per second.

Reimplemented from robot::base_motor.

◆ setServoPos()

void robot::can_motor::setServoPos ( uint8_t servo,
int32_t position )
overridevirtual

Implements robot::base_motor.

◆ setStepperTurnAngle()

void robot::can_motor::setStepperTurnAngle ( uint8_t stepper,
int16_t angle )
overridevirtual

Implements robot::base_motor.


The documentation for this class was generated from the following files: