Actuation

Example Usage

from epicallypowerful.actuation import ActuatorGroup, TMotor, CyberGear

LEFT = 0x01
RIGHT = 0x02

### Instantiation ---
actuators = ActuatorGroup([
    TMotor(LEFT, 'AK80-9', invert=True),
    CyberGear(RIGHT)
])
# OR
actuators = ActuatorGroup.from_dict({
    LEFT: 'AK80-9',
    RIGHT: 'CyberGear'
}, invert=[LEFT])

### Control ---
actuators.set_torque(LEFT, 0.5)
actuators.set_position(RIGHT, 0, 0.5, 0.1, 0.1, degrees=True)

### Data ---
print(actuators.get_torque(LEFT))
print(actuators.get_position(RIGHT))
print(actuators.get_temperature(RIGHT))

Actuator Group

class epicallypowerful.actuation.ActuatorGroup(actuators: list[Actuator], can_args: dict | None = None, enable_on_startup: bool = True, exit_manually: bool = False, torque_limit_mode: Literal['warn', 'throttle', 'saturate', 'disable', 'silent'] = 'warn', torque_rms_window: float = 20.0)

Controls a group of actuators, which can all have different types (CubeMars, Robstride, Cybergear, etc.). You can mix and match different AK Series actuators, as well as Robstride actuators in the same group.

To control the actuators, you can use the set_torque(), set_position(), and set_velocity() methods by bracket indexing the ActuatorGroup object witht he CAN ID as the key, or you can use the AcutorGroups corresponding method with the motor id as the first argument.

To get data from the actuators, a similar approach can be used. In this case the get_data(), get_torque(), get_position(), and get_velocity() methods are available. A get_temperature() method is also available for the Robstrides, and will always return 0 for the CubeMars.

Please see the CubeMars and Robstride classes for more information on the methods available for each actuator and specific relevant details.

You can also create an ActuatorGroup from a dictionary, where the key is the CAN ID and the value is the actuator type, using the from_dict().

For a list of all supported actuator types, you can import and use the epicallypowerful.actuation.available_actuator_types() function.

Example

from epicallypowerful.actuation import ActuatorGroup, CubeMars, Robstride

### Instantiation ---
actuators = ActuatorGroup([CubeMars(1, 'AK80-9'), Robstride(2, 'Cybergear'), Robstride(3, 'RS02')])
# OR
actuators = ActuatorGroup.from_dict({
    1: 'AK80-9',
    2: 'CyberGear',
    3: 'RS02'
})

### Control ---
actuators.set_torque(1, 0.5)
actuators.set_position(2, 0, 0.05, 0.1, degrees=True)

### Data ---
print(actuators.get_torque(1))
print(actuators.get_position(2))
print(actuators.get_temperature(3))
Parameters:
  • actuators (list[Actuator]) – A list of the actuators to control

  • can_args (Optional[dict], optional) – A dictionary of arguments to be passed to the can.Bus object. This is only needed if your system does not use SocketCAN as described in the tutorials. Defaults to None.

  • enable_on_startup (bool, optional) – Whether to attempt to enable the actuators when the object is created. If set False, enable_actuators() needs to be called before any other commands. Defaults to True.

  • exit_manually (bool, optional) – Whether to handle graceful exit manually. If set to False, the program will attempt to disable the actuators and shutdown the CAN bus on SIGINT or SIGTERM (ex. Ctrl+C). Defaults to False.

  • torque_limit_mode (Literal['warn', 'throttle', 'saturate', 'disable', 'silent'], optional) – The mode to use when a motor exceeds its torque limits. ‘warn’ prints a warning to the terminal. ‘throttle’ drops commanded torque to zero. ‘saturate’ saturates the torque at the rated torque for the motor type. ‘disable’ shuts down the motors and will not reinitialize them. Defaults to ‘warn’.

  • torque_rms_window (float, optional) – The window size in seconds to use for torque RMS monitoring. Defaults to 20.0 seconds.

enable_actuators() None

Enables control of the actuators. This will send the appropriate enable command and set torques to zero.

disable_actuators() None

Disables control of the actuators. This will set the torque to 0 and disable the motors.

set_control(can_id: int, pos: float, vel: float, torque: float, kp: float, kd: float, degrees: bool = False)

Sets the control of the motor using full MIT control mode. This uses the built in capability to simultaneously use torque, as well as position and velocity control.

Parameters:
  • can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

  • pos (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • vel (float) – Velocity to set the actuator to in radians or degrees depending on the degrees argument.

  • torque (float) – Torque to set the actuator to in Newton-meters.

  • kp (float) – Proportional gain to set the actuator to in Newton-meters per radian or Newton-meters per degree depending on the degrees argument.

  • kd (float) – Derivative gain to set the actuator to in Newton-meters per radian per second or Newton-meters per degree per second depending on the degrees argument.

  • degrees (bool, optional) – Whether the position and velocity are in degrees or radians. Defaults to False.

set_torque(can_id: int, torque: float) int

Sets the torque of the actuator with the given CAN ID.

Parameters:
  • can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

  • torque (float) – Torque to set the actuator to in Newton-meters.

set_position(can_id: int, position: float, kp: float, kd: float, degrees: bool = False) int

Sets the position of the actuator with the given CAN ID.

Parameters:
  • can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

  • position (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • kp (float) – Set the proportional gain (stiffness) of the actuator in Newton-meters per radian.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the position is in degrees or radians.

set_velocity(can_id: int, velocity: float, kd: float, degrees: bool = False) int

Sets the velocity of the actuator with the given CAN ID.

Parameters:
  • can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

  • velocity (float) – Velocity to set the actuator to in radians per second or degrees per second depending on the degrees argument.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the velocity is in degrees per second or radians per second.

is_connected(can_id: int) bool
zero_encoder(can_id: int) None

Zeros the encoder of the actuator with the given CAN ID.

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

get_data(can_id: int) MotorData

Returns the data from the actuator with the given CAN ID

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

Returns:

Data from the actuator. Contains most up-to-date information from the actuator.

Return type:

MotorData

get_torque(can_id: int) float

Returns the torque from the actuator with the given CAN ID. Functionally equivalent to get_data(can_id).current_torque.

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

Returns:

Torque from the actuator in Newton-meters.

Return type:

float

get_position(can_id: int, degrees: bool = False) float

Returns the position from the actuator with the given CAN ID. Functionally equivalent to actuators.get_data(can_id).current_position.

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

Returns:

Position from the actuator in radians.

Return type:

float

get_velocity(can_id: int, degrees: bool = False) float

Returns the velocity from the actuator with the given CAN ID. Functionally equivalent to actuators.get_data(can_id).current_velocity.

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

Returns:

Position from the actuator in radians.

Return type:

float

get_temperature(can_id: int) float

Returns the temperature from the actuator with the given CAN ID. Functionally equivalent to actuators.get_data(can_id).temperature.

Parameters:

can_id (int) – CAN ID of the actuator. This should be set by the appropriate manufacturer software.

Returns:

Temperature from the actuator in degrees Celsius.

Return type:

float

classmethod from_dict(actuators: dict[int, str], invert: list = [], enable_on_startup: bool = True, can_args: dict[str, str] = None, exit_manually: bool = False, torque_limit_mode: Literal['warn', 'throttle', 'saturate', 'disable', 'silent'] = 'warn', torque_rms_window: float = 20.0) Self

Creates an ActuatorGroup from a dictionary where the key is the CAN ID and the value is the actuator type. For CubeMars, you can append “-servo” to the actuator type to create a CubeMarsServo instead of a CubeMars. This controls the device in “servo mode” which can allow for higher output torques as direct current control can be used. Please see the CubeMarsServo class for more information. Make sure to match the actuator type exactly, including the version if applicable (e.g. “AK10-9-V2.0” is different from “AK10-9-V3”).

Available strings for the actuator types are
  • ‘AK10-9-V2.0’

  • ‘AK60-6-V1.1’

  • ‘AK70-10’

  • ‘AK80-6’

  • ‘AK80-8’

  • ‘AK80-9’

  • ‘AK80-64’

  • ‘AK80-9-V3’

  • ‘AK70-9-V3’

  • ‘AK60-6-V3’

  • ‘AK10-9-V3’

  • ‘CyberGear’

  • ‘RS00’

  • ‘RS01’

  • ‘RS02’

  • ‘RS03’

  • ‘RS04’

  • ‘RS05’

  • ‘RS06’

Example

actuators = ActuatorGroup.from_dict({ 1: 'AK80-9', 2: 'AK70-10', 3: 'CyberGear', 4: 'AK10-9-V3', '5': 'RS02' }, invert=[2,4])
Parameters:
  • actuators (dict[int, str]) – A dictionary where the key is the CAN ID and the value is the actuator type.

  • can_args (dict[str,str], optional) – Arguments to provide to the can.Bus object. Defaults to None.

  • invert (list, optional) – A list of CAN IDs to invert the direction of. Defaults to [].

  • enable_on_startup (bool, optional) – Whether to attempt to enable the actuators when the object is created. If set False, enable_actuators() needs to be called before any other commands. Defaults to True.

  • exit_manually (bool, optional) – Whether to handle graceful exit manually. If set to False, the program will attempt to disable the actuators and shutdown the CAN bus on SIGINT or SIGTERM (ex. Ctrl+C). Defaults to False.

  • torque_limit_mode (Literal['warn', 'throttle', 'saturate', 'disable', 'silent'], optional) – The mode to use when a motor exceeds its torque limits. Defaults to ‘warn’.

  • torque_rms_window (float, optional) – The window size in seconds to use for torque RMS monitoring. Defaults to 20.0 seconds.

Raises:

ValueError – If the actuator type is not recognized or supported.

Returns:

An ActuatorGroup object with the actuators from the dictionary.

Return type:

ActuatorGroup

__getitem__(idx: int) Actuator

Returns the actuator with the given CAN ID. This method is better used for bracket indexing the ActuatorGroup object.

Example

# ... Create the ActuatorGroup object ...
actuators[0x1].set_torque(0.5)

actuator_one = actuators[0x1]

print(actuators[0x1].get_torque())
Parameters:

idx (int) – CAN ID of the actuator

Returns:

The actuator with the given CAN ID

Return type:

Actuator

CubeMars Actuators

class epicallypowerful.actuation.cubemars.CubeMars(can_id: int, motor_type: str, invert: bool = False)

Bases: Listener, Actuator

Class for controlling an individual CubeMars actuator. This class should always be initialized as part of an ActuatorGroup so that the can bus is appropriately shared between all motors. Alternatively, the bus can be set manually after initialization, however this is not recommended. If you want to implement it this way, please consult the python-can documentation.

This class supports all motors from the AK series. Before use with this package, please follow the tutorial for using RLink to properly configure the motor and CAN IDs.

The CubeMars actuators can be intialized to be inverted by default, which will reverse the default Clockwise/Counter-Clockwise direction of the motor.

Availabe motor_type strings are:
  • ‘AK10-9-V2.0’

  • ‘AK60-6-V1.1’

  • ‘AK70-10’

  • ‘AK80-6’

  • ‘AK80-8’

  • ‘AK80-9’

  • ‘AK80-64’

Example

from epicallypowerful.actuation import CubeMars, ActuatorGroup
motor = CubeMars(1, 'AK80-9')
group = ActuatorGroup([motor])

group.set_torque(1, 0.5)
Parameters:
  • can_id (int) – CAN ID of the motor. This should be unique for each motor in the system, and can be set up with the RLink software.

  • motor_type (str) – A string representing the type of motor. This is used to set the appropriate limits for the motor. Options include: * ‘AK80-9’ * ‘AK80-64’ * Et cetera et cetera

  • invert (bool, optional) – Whether to invert the motor direction. Defaults to False.

data

Data from the actuator. Contains up-to-date information from the actuator as of the last time a message was sent to the actuator.

Type:

MotorData

call_response_latency() float
set_control(pos: float, vel: float, torque: float, kp: float, kd: float, degrees: bool = False) None

Sets the control of the motor using full MIT control mode. This uses the built in capability to simultaneously use torque, as well as position and velocity control. It is highly recommended you consult

Parameters:
  • pos (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • vel (float) – Velocity to set the actuator to in radians or degrees depending on the degrees argument.

  • torque (float) – Torque to set the actuator to in Newton-meters.

  • kp (float) – Proportional gain to set the actuator to in Newton-meters per radian or Newton-meters per degree depending on the degrees argument.

  • kd (float) – Derivative gain to set the actuator to in Newton-meters per radian per second or Newton-meters per degree per second depending on the degrees argument.

  • degrees (bool, optional) – Whether the position and velocity are in degrees or radians. Defaults to False.

set_torque(torque: float) None

Sets the torque of the motor in Newton-meters. This will saturate if the torque is outside the limits of the motor. Positive and negative torques will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at intialization.

Parameters:

torque (float) – The torque to set the motor to in Newton-meters.

set_position(position: float, kp: float, kd: float, degrees: bool = False) None

Sets the position of the motor in radians. Positive and negative positions will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at intialization.

Parameters:
  • position (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • kp (float) – Set the proportional gain (stiffness) of the actuator in Newton-meters per radian.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the position is in degrees or radians.

set_velocity(velocity: float, kd: float, degrees: bool = False) None

Sets the velocity of the motor in radians per second. Positive and negative velocities will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at intialization.

Parameters:
  • velocity (float) – Velocity to set the actuator to in radians per second or degrees per second depending on the degrees argument.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the velocity is in degrees per second or radians per second.

get_data() MotorData

Returns the current data of the motor

Returns:

Data from the actuator. Contains up-to-date information from the actuator as of the last time a message was sent to the actuator.

Return type:

MotorData

get_torque() float

Returns the current torque of the motor in Newton-meters. Functionally equivalent to or get_data().current_torque.

Returns:

The current torque of the motor in Newton-meters.

Return type:

float

get_position(degrees: bool = False) float

Returns the current position of the motor in radians. Functionally equivalent to or get_data().current_position.

Parameters:

degrees (bool, optional) – Whether to return the position in degrees or radians. Defaults to False.

Returns:

The current position of the motor in radians or degrees.

Return type:

float

get_velocity(degrees: bool = False) float

Returns the current velocity of the motor in radians per second. Functionally equivalent to get_data().current_velocity.

Parameters:

degrees (bool, optional) – Whether to return the velocity in degrees. Defaults to False.

Returns:

The current velocity of the motor in radians per second or degrees per second.

Return type:

float

get_temperature() float

Returns the current temperature of the motor in degrees Celsius. This is not currently implemented and will ALWAYS return 0 for T Motors.

Returns:

A dummy value of Zero. This does NOT refelect the actual temperature of the motor.

Return type:

float

zero_encoder()

Zeros the encoder of the motor. This will set the current position of the motor to zero.

class epicallypowerful.actuation.cubemars.CubeMarsServo(can_id: int, motor_type: str, invert: bool = False)

Bases: Listener, Actuator

Class for controlling an individual CubeMars actuator in servo mode. This class should always be initialized as part of an ActuatorGroup so that the can bus is appropriately shared between all motors. Alternatively, the bus can be set manually after initialization, however this is not recommended. If you want to implement it this way, please consult the python-can documentation.

Servo mode provides alternate control loops, namely direct control over current is available, allowing for more torque to be drawn from the motor than the MIT mode would allow.

It is important to note that in servo mode, the reply current values are signed in a “braking/assisting” convention, and do not indicate the actual clockwise/counterclockwise direction of torque. Commanded values however are in the standard convention. Please refer to the motor datasheet for more information.

Additionally, values read using the “get_torque” method actually return current values in Amperes.

This class supports all motors from the AK series. Before use with this package, please follow the tutorial for using RLink to properly configure the motor and CAN IDs.

The CubeMars Servo actuators can be intialized to be inverted by default, which will reverse the default Clockwise/Counter-Clockwise direction of the motor.

Availabe motor_type strings are:
  • ‘AK10-9-V2.0’

  • ‘AK60-6-V1.1’

  • ‘AK70-10’

  • ‘AK80-6’

  • ‘AK80-8’

  • ‘AK80-9’

  • ‘AK80-64’

  • ‘AK80-9-V3’

  • ‘AK70-9-V3’

  • ‘AK60-6-V3’

  • ‘AK10-9-V3’

Example

from epicallypowerful.actuation import CubeMars, ActuatorGroup
motor = CubeMarsServo(1, 'AK80-9')
group = ActuatorGroup([motor])

group.set_torque(1, 0.5)
Parameters:
  • can_id (int) – CAN ID of the motor. This should be unique for each motor in the system, and can be set up with the RLink software.

  • motor_type (str) – A string representing the type of motor. This is used to set the appropriate limits for the motor. These will always end with -V3 for these actuators. Options include: * ‘AK80-9-V3’ * ‘AK80-64-V3’ * Et cetera et cetera

  • invert (bool, optional) – Whether to invert the motor direction. Defaults to False.

data

Data from the actuator. Contains up-to-date information from the actuator as of the last time a message was sent to the actuator.

Type:

MotorData

call_response_latency()
set_control(pos, vel, torque, kp, kd, degrees=False)
set_torque(torque: float)

Sets the torque of the motor as a direct current value. Range is -60A to 60A.

Parameters:

torque (float) – The current to set the motor to in Amperes.

set_position(position, kp: float, kd: float, degrees=False)

Sets the position of the motor in position control mode. Range is -36000 to 36000 degrees.

Parameters:
  • position (float) – The position to set the motor to (defaults to radians).

  • kp (float) – Dummy variable for compatibility, not used in servo mode. To adjust these gains, use the RLink software.

  • kd (float) – Dummy variable for compatibility, not used in servo mode. To adjust these gains, use the RLink software.

  • degrees (bool, optional) – Whether the position is in degrees. Defaults to False.

set_velocity(velocity, kp: float, degrees=False)

Sets the velocity of the motor in velocity control mode. Range varies per motor.

Parameters:
  • velocity (float) – The velocity to set the motor to (defaults to radians/second).

  • kp (float) – Dummy variable for compatibility, not used in servo mode. To adjust these gains, use the RLink software.

  • degrees (bool, optional) – Whether the velocity is in degrees per second. Defaults to False.

get_data() MotorData

Returns the current motor data.

Returns:

The current data of the motor.

Return type:

MotorData

get_torque()

Returns the measured current value of the motor. In servo mode, this value is signed in “braking/assisting” convention, and does not indicate the actual clockwise/counterclockwise direction of torque.

Returns:

The measured current of the motor (Amps).

Return type:

float

get_position(degrees=False)

Returns the current position of the motor.

Parameters:

degrees (bool, optional) – Whether to return the position in degrees. Defaults to False.

Returns:

The current position of the motor.

Return type:

float

get_velocity(degrees=False)

Returns the current velocity of the motor.

Parameters:

degrees (bool, optional) – Whether to return the velocity in degrees per second. Defaults to False.

Returns:

The current velocity of the motor.

Return type:

float

get_temperature()

Returns the current temperature of the motor.

Returns:

The current temperature of the motor in degrees Celsius.

Return type:

float

zero_encoder()

Zeros the encoder position to the current position.

class epicallypowerful.actuation.cubemars.CubeMarsV3(can_id: int, motor_type: str, invert: bool = False)

Bases: Listener, Actuator

Class for controlling an individual V3 CubeMars actuator. This class should always be initialized as part of an ActuatorGroup so that the can bus is appropriately shared between all motors. Alternatively, the bus can be set manually after initialization, however this is not recommended. If you want to implement it this way, please consult the python-can documentation.

This class supports all V3 motors from the AK series. Before use with this package, please follow the tutorial for using RLink to properly configure the motor and CAN IDs.

It is important to note that for V3 actuators , the reply current values are signed in a “braking/assisting” convention, and do not indicate the actual clockwise/counterclockwise direction of torque. Commanded values however are in the standard convention. Please refer to the motor datasheet for more information.

Additionally, values read using the “get_torque” method actually return current values in Amperes.

The CubeMars V3 actuators can be intialized to be inverted by default, which will reverse the default Clockwise/Counter-Clockwise direction of the motor.

Availabe motor_type strings are:
  • ‘AK80-9-V3’

  • ‘AK70-9-V3’

  • ‘AK60-6-V3’

  • ‘AK10-9-V3’

Example

from epicallypowerful.actuation import CubeMars, ActuatorGroup
motor = CubeMarsV3(1, 'AK80-9-V3')
group = ActuatorGroup([motor])

group.set_torque(1, 0.5)
Parameters:
  • can_id (int) – CAN ID of the motor. This should be unique for each motor in the system, and can be set up with the RLink software.

  • motor_type (str) – A string representing the type of motor. This is used to set the appropriate limits for the motor. These will always end with -V3 for these actuators.

  • invert (bool, optional) – Whether to invert the motor direction. Defaults to False.

data

Data from the actuator. Contains up-to-date information from the actuator as of the last time a message was sent to the actuator.

Type:

MotorData

on_message_received(msg: Message) None

This method is called to handle the given message.

Parameters:

msg – the delivered message

call_response_latency()
set_control(pos, vel, torque, kp, kd, degrees=False)
set_torque(torque: float) None
set_position(position: float, kp: float, kd: float, degrees: bool = False) None
set_velocity(velocity: float, kd: float, degrees: bool = False) None
get_data() MotorData
get_torque() float
get_position(degrees=False) float
get_velocity(degrees=False) float
get_temperature() float
zero_encoder()

RobStride Motors

class epicallypowerful.actuation.robstride.Robstride(can_id: int, motor_type: str, invert: bool = False)

Bases: Listener, Actuator

Class for controlling an individual Robstride acutator. This class should always be initialized as part of an ActuatorGroup so that the can bus is appropriately shared between all motors. Alternatively, the bus can be set manually after initialization, however this is not recommended.

The Robstrides can be intialized to be inverted by default, which will reverse the default Clockwise/Counter-Clockwise direction of the motor.

Availabe motor_type strings are:
  • ‘CyberGear’

  • ‘RS00’

  • ‘RS01’

  • ‘RS02’

  • ‘RS03’

  • ‘RS04’

  • ‘RS05’

  • ‘RS06’

Example

from epicallypowerful.actuation import Robstride, ActuatorGroup
motor = Robstride(1, 'RS02')
group = ActuatorGroup([motor])

group.set_torque(1, 0.5)
Parameters:
  • can_id (int) – CAN ID of the motor. This should be unique for each motor in the system, and can be set up with the RLink software.

  • motor_type (str, optional) – A string representing the type of motor.

  • invert (bool, optional) – Whether to invert the motor direction. Defaults to False.

call_response_latency() float
set_control(pos: float, vel: float, torque: float, kp: float, kd: float, degrees: bool = False) None

Sets the control of the motor using full MIT control mode. This uses the built in capability to simultaneously use torque, as well as position and velocity control.

Parameters:
  • pos (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • vel (float) – Velocity to set the actuator to in radians or degrees depending on the degrees argument.

  • torque (float) – Torque to set the actuator to in Newton-meters.

  • kp (float) – Proportional gain to set the actuator to in Newton-meters per radian or Newton-meters per degree depending on the degrees argument.

  • kd (float) – Derivative gain to set the actuator to in Newton-meters per radian per second or Newton-meters per degree per second depending on the degrees argument.

  • degrees (bool, optional) – Whether the position and velocity are in degrees or radians. Defaults to False.

set_torque(torque: float) None

Sets the torque of the motor in Newton-meters. This will saturate if the torque is outside the limits of the motor. Positive and negative torques will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at initialization.

Parameters:

torque (float) – The torque to set the motor to in Newton-meters.

set_position(position: float, kp: float, kd: float, degrees: bool = False) None

Sets the position of the motor in radians. Positive and negative positions will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at initialization.

Parameters:
  • position (float) – Position to set the actuator to in radians or degrees depending on the degrees argument.

  • kp (float) – Set the proportional gain (stiffness) of the actuator in Newton-meters per radian.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the position is in degrees or radians.

set_velocity(velocity: float, kd: float, degrees: bool = False) None

Sets the velocity of the motor in radians per second. Positive and negative velocities will spin the motor in opposite directions, and this direction will be reversed if the motor is inverted at initialization.

Parameters:
  • velocity (float) – Velocity to set the actuator to in radians per second or degrees per second depending on the degrees argument.

  • kd (float) – Set the derivative gain (damping) of the actuator in Newton-meters per radian per second.

  • degrees (bool) – Whether the velocity is in degrees per second or radians per second.

zero_encoder()
get_data() MotorData

Returns the current data of the motor

Returns:

Data from the actuator. Contains up-to-date information from the actuator as of the last time a message was sent to the actuator.

Return type:

MotorData

get_torque() float

Returns the current torque of the motor in Newton-meters. Functionally equivalent to the property torque or get_data().current_torque.

Returns:

The current torque of the motor in Newton-meters.

Return type:

float

get_position(degrees: bool = False) float

Returns the current position of the motor in radians. Functionally equivalent to the property position or get_data().current_position.

Parameters:

degrees (bool, optional) – Whether to return the position in degrees or radians. Defaults to False.

Returns:

The current position of the motor in radians or degrees.

Return type:

float

get_velocity(degrees: bool = False) float

Returns the current velocity of the motor in radians per second. Functionally equivalent to the property velocity or get_data().current_velocity.

Parameters:

degrees (bool, optional) – Whether to return the velocity in degrees. Defaults to False.

Returns:

The current velocity of the motor in radians per second or degrees per second.

Return type:

float

get_temperature() float

Returns the current temperature of the motor in degrees Celsius.

Returns:

The current temperature of the motor in degrees Celsius.

Return type:

float

CyberGear Motors

class epicallypowerful.actuation.cybergear.CyberGear(can_id: int, motor_type: str = 'CyberGear', invert: bool = False)

Bases: Robstride

Class for controlling an individual CyberGear Micromotor. This class should always be initialized as part of an ActuatorGroup so that the can bus is appropriately shared between all motors. Alternatively, the bus can be set manually after initialization, however this is not recommended.

**NOTE: The CyberGear class is simply an inherited version of the Robstride class, which automatically passes the motor_type argument as “CyberGear”. In general, this is provided as a convenience function and will potentially be deprecated to ensure consistency between the CyberGear and other Robstride motors. The CyberGears can be initialized to be inverted by default, which will reverse the default Clockwise/Counter-Clockwise direction of the motor.

Example

from epicpower.actuation2 import CyberGear, ActuatorGroup

motor = Cybergear(0x01)
group = ActuatorGroup([motor])

motor.set_torque(0.5)
# OR
group[0x01].set_torque(0.5)
# OR
group.set_torque(0x01, 0.5)
Parameters:
  • can_id (int) – CAN ID of the motor. This should be unique for each motor in the system, and can be set up with the RLink software.

  • motor_type (str, optional) – A string representing the type of motor. This is not necessary as there is only one type of motor. Defaults to “CyberGear”.

  • invert (bool, optional) – Whether to invert the motor direction. Defaults to False.

Motor Data

class epicallypowerful.actuation.MotorData(motor_id: int, motor_type: str, current_position: float = 0.0, current_velocity: float = 0.0, current_torque: float = 0.0, current_temperature: float = 0.0, commanded_position: float = 0, commanded_velocity: float = 0, commanded_torque: float = 0, kp: float = 0, kd: float = 0, torque_limits: tuple = (0, 0), rated_torque_limits: tuple = (0, 0), velocity_limits: tuple = (0, 0), position_limits: tuple = (0, 0), kp_limits: tuple = (0, 0), kd_limits: tuple = (0, 0), timestamp: float = -1, last_command_time: float = -1, initialized: bool = False, responding: bool = False, unique_hardware_id: int = -1, running_torque: list = None, rms_torque: float = 0, rms_time_prev: float = 0, motor_mode: float = 0, erpm_to_rpm: float = None)

Stores the most recent state of the current motor. This data is typically updated by a CAN Listener class.

This contains the parameters relevant for control, (i.e. commanded and current position, velocity, torque, etc.), as well as the motor limits. The same data structure is used for all motors, but the limits are specific to the motor type. Additionally, some fields are not used for all motor types, and thus it is advised to use the getter methods for each motor instead of the dataclass directly.

motor_id: int
motor_type: str
current_position: float = 0.0
current_velocity: float = 0.0
current_torque: float = 0.0
current_temperature: float = 0.0
commanded_position: float = 0
commanded_velocity: float = 0
commanded_torque: float = 0
kp: float = 0
kd: float = 0
torque_limits: tuple = (0, 0)
rated_torque_limits: tuple = (0, 0)
velocity_limits: tuple = (0, 0)
position_limits: tuple = (0, 0)
kp_limits: tuple = (0, 0)
kd_limits: tuple = (0, 0)
timestamp: float = -1
last_command_time: float = -1
initialized: bool = False
responding: bool = False
unique_hardware_id: int = -1
running_torque: list = None
rms_torque: float = 0
rms_time_prev: float = 0
motor_mode: float = 0
internal_params = {}
erpm_to_rpm: float = None
__post_init__()

Initializes the motor limits based on the motor type

Raises:

ValueError – Raised if the motor type is not specified

Abstract Classes

These classes are the base classes which many of the classes in this section inherit from. This class is not intended for direct usage, and its inclusion here is for documentation completeness.

class epicallypowerful.actuation.actuator_abc.Actuator
abstractmethod call_response_latency() float
abstractmethod get_data() MotorData
abstractmethod get_position(degrees: bool = False) float
abstractmethod get_temperature() float
abstractmethod get_torque() float
abstractmethod get_velocity(degrees: bool = False) float
abstractmethod set_control(pos: float, vel: float, torque: float, kp: float, kd: float, degrees: bool = False)
abstractmethod set_position(position: float, kp: float, kd: float, degrees: bool = False)
abstractmethod set_torque(torque: float)
abstractmethod set_velocity(velocity: float, kd: float, degrees: bool = False)
abstractmethod zero_encoder()