feathersdk.robot.robstride_neck_platform Module¶
- class feathersdk.robot.robstride_neck_platform.RobstrideNeckPlatform(motors_manager: MotorsManager, power: BatterySystem = None, config: dict = {})¶
Bases:
NeckPlatformPlatform for controlling Robstride neck motors (pitch and yaw).
This class manages the neck platform with two motors: pitch (NpC) and yaw (NwC). It handles initialization, calibration, movement control, and power management. The platform supports position control with configurable velocity and acceleration limits.
- PITCH_MOTOR_NAME = 'NpC'¶
- YAW_MOTOR_NAME = 'NwC'¶
- __init__(motors_manager: MotorsManager, power: BatterySystem = None, config: dict = {})¶
Initialize the Robstride neck platform.
- Parameters:
motors_manager (MotorsManager) – The motors manager instance for controlling motors.
power (BatterySystem, optional) – Battery system for power event handling. If provided, the platform will check if recalibration is needed after power cycles.
config (dict) – Configuration dictionary containing motor settings. Must include a “motors” key with motor configurations including: - id: Motor ID in hexadecimal string format - motor_config: Motor configuration dictionary - default_velocity_max: Default maximum velocity in rad/s - default_acceleration_max: Default maximum acceleration in rad/s^2 - default_loc_kp: Default location proportional gain
- disable_motors()¶
Disable all neck motors.
- enable_motors()¶
Enable all neck motors in position control mode.
- async get_position(force_update: bool = False) Dict[str, float]¶
Get the current mechanical positions of all neck motors.
- Parameters:
force_update (bool) – Currently unused, reserved for future implementation.
- Returns:
- Dictionary mapping motor names to their mechanical positions in radians.
Keys are motor names (e.g., “NpC”, “NwC”).
- Return type:
Dict[str, float]
- async get_state_async() dict¶
Get the current state of all neck motors.
- Returns:
- Dictionary containing motor state with keys:
”temp”: Temperature (TimestampedValue)
”torque”: Torque (TimestampedValue)
”angle”: Angle (TimestampedValue)
”velocity”: Velocity (TimestampedValue)
- Return type:
dict
- get_state_sync() dict¶
Get the current state of all neck motors.
- Returns:
- Dictionary mapping motor names to their state dict containing:
’temp’: current temperature in degrees Celsius
’torque’: current torque in newton meters
’angle’: current angle in radians
’velocity’: current velocity in radians per second
- Return type:
Dict[str, Dict[str, float]]
- get_system_state()¶
Get the current system state of all neck motors.
- Returns:
- Dictionary mapping motor names to their calibrated angles.
Keys are in the format “{motor_name}_angle” (e.g., “NpC_angle”, “NwC_angle”). Values are the calibrated angle in radians.
- Return type:
Dict[str, float]
- go_to(pitch_in_degrees: float = None, yaw_in_degrees: float = None)¶
Set target position for neck movement.
- Parameters:
pitch_in_degrees (float, optional) – Target pitch angle in degrees. None to keep current target. Must be between -120 and 0 degrees.
yaw_in_degrees (float, optional) – Target yaw angle in degrees. None to keep current target. Must be between -90 and 90 degrees.
- Raises:
Exception – If neck is not enabled, not healthy, or currently recalibrating.
ValueError – If pitch or yaw values are outside their valid ranges.
- async health_check() Dict[str, Dict[str, float]]¶
Perform a comprehensive health check on all neck motors.
- Returns:
- Nested dictionary mapping motor names to their health parameters.
Each motor’s dictionary contains: - “mech_pos”: Mechanical position in radians - “loc_ref”: Location reference (target position) in radians - “velocity”: Mechanical velocity in rad/s - “iqf”: Quadrature current feedback in amperes - “vel_max”: Maximum velocity setting in rad/s - “acc_set”: Acceleration setting in rad/s^2 - “loc_kp”: Location proportional gain
- Return type:
Dict[str, Dict[str, float]]
- look_up()¶
Move the neck to look straight forward.
Sets pitch to -90 degrees and yaw to 0 degrees (center position). This is typically used as a safe homing position.
- on_abort()¶
Handle system abort event.
- recalibrate(verbose: bool = False)¶
Recalibrate neck motors.
- Parameters:
verbose (bool) – If True, passes verbose mode through to motor calibration (see motors manager).
- Raises:
Exception – If neck is already recalibrating, or if calibration fails. On failure, healthy_state is set to False and enabled is set to True.
- set_movement_profile(motor_name: str, max_velocity: float, max_acceleration: float, max_jerk=None)¶
Set the movement profile parameters for a specific motor.
- Parameters:
motor_name (str) – Name of the motor to configure (e.g., “NpC” or “NwC”).
max_velocity (float) – Maximum velocity in rad/s. Must be between 0.1 and MAX_POSITION_VELOCITY (20 rad/s).
max_acceleration (float) – Maximum acceleration in rad/s^2. Must be between 0.1 and MAX_POSITION_ACCELERATION (30 rad/s^2).
max_jerk (float, optional) – Maximum jerk (not supported, must be None).
- Raises:
ValueError – If max_velocity or max_acceleration are out of valid range, if max_jerk is not None, or if motor_name is not a valid neck motor.
- sleep_and_disable()¶
Put motors to sleep position and disable them safely.
- Raises:
Exception – Re-raises any exceptions that occur during the sleep process, but ensures motors are disabled in the finally block.