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

Public Member Functions

 sim_motor (robot::types::motorid_t motor, bool hasPosSensor, const std::string &name, const std::string &path)
 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.
 
- 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.
 
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.
 

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

◆ sim_motor()

robot::sim_motor::sim_motor ( robot::types::motorid_t motor,
bool hasPosSensor,
const std::string & name,
const std::string & path )

Constructor for can motor.

Parameters
motorThe motor id to manipulate.
hasPosSensorBoolean to indicate if the motor has a position sensor.
nameThe name of the motor.
protocol_pathWebsocket protocol path.

Member Function Documentation

◆ getMotorPos()

types::DataPoint< int32_t > robot::sim_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::sim_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::sim_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.


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