Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
robot::base_motor Class Referenceabstract

An abstract motor class. More...

#include <base_motor.h>

Inheritance diagram for robot::base_motor:
Collaboration diagram for robot::base_motor:

Public Member Functions

 base_motor (robot::types::motorid_t motor, bool hasPosSensor)
 Constructor for base motor.
 
bool hasPositionSensor () const
 Returns the status of the motor position sensor.
 
virtual void setMotorPower (double power)=0
 Set the PWM command of the motor.
 
virtual void setMotorPos (int32_t targetPos)=0
 Set the target position of the motor.
 
virtual types::DataPoint< int32_tgetMotorPos () const =0
 Get the last reported position of the specified motor.
 
virtual void setMotorVel (int32_t targetVel)
 Sets the velocity of the motor.
 
 base_motor (const base_motor &)=delete
 Delete the copy constructor.
 
base_motoroperator= (const base_motor &)=delete
 Delete the copy operator.
 

Protected Member Functions

void constructVelController ()
 Constructs a Jacobian Vel Controller.
 
void unscheduleVelocityEvent ()
 Unschedules the velocity event if it exists.
 

Protected Attributes

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

static std::optional< util::PeriodicScheduler< std::chrono::steady_clock > > pSched
 
static std::mutex schedulerMutex
 

Detailed Description

An abstract motor class.

Constructor & Destructor Documentation

◆ base_motor() [1/2]

robot::base_motor::base_motor ( robot::types::motorid_t motor,
bool hasPosSensor )

Constructor for base motor.

Parameters
motorThe motor id to manipulate.
hasPosSensorBoolean to indicate if the motor has a position sensor.

◆ base_motor() [2/2]

robot::base_motor::base_motor ( const base_motor & )
delete

Delete the copy constructor.

Parameters
base_motorThe motor to copy

Member Function Documentation

◆ getMotorPos()

virtual types::DataPoint< int32_t > robot::base_motor::getMotorPos ( ) const
pure virtual

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.

Implemented in robot::can_motor, and robot::sim_motor.

◆ hasPositionSensor()

bool robot::base_motor::hasPositionSensor ( ) const

Returns the status of the motor position sensor.

Returns
True if the motor has a position sensor and false if not

◆ operator=()

base_motor & robot::base_motor::operator= ( const base_motor & )
delete

Delete the copy operator.

Parameters
base_motorThe motor to copy

◆ setMotorPos()

virtual void robot::base_motor::setMotorPos ( int32_t targetPos)
pure virtual

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.

Implemented in robot::can_motor, and robot::sim_motor.

◆ setMotorPower()

virtual void robot::base_motor::setMotorPower ( double power)
pure virtual

Set the PWM command of the motor.

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

Implemented in robot::can_motor, and robot::sim_motor.

◆ setMotorVel()

void robot::base_motor::setMotorVel ( int32_t targetVel)
virtual

Sets the velocity of the motor.

Parameters
targetVelThe target velocity, in millidegrees per second.

Reimplemented in robot::can_motor.


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