1# Lint as: python3 2"""The configuration parameters for our robots.""" 3from __future__ import absolute_import 4from __future__ import division 5from __future__ import print_function 6 7import enum 8from typing import Sequence, Union 9import dataclasses 10import gin 11import numpy as np 12 13 14@gin.constants_from_enum 15class MotorControlMode(enum.Enum): 16 """The supported motor control modes.""" 17 POSITION = 1, 18 19 # Apply motor torques directly. 20 TORQUE = 2, 21 22 # Apply a tuple (q, qdot, kp, kd, tau) for each motor. Here q, qdot are motor 23 # position and velocities. kp and kd are PD gains. tau is the additional 24 # motor torque. This is the most flexible control mode. 25 HYBRID = 3, 26 27 # PWM mode is only availalbe for Minitaur 28 PWM = 4 29 30 31# TODO(b/127675924): Group other parameters in the named attrib class. 32 33# Each hybrid action is a tuple (position, position_gain, velocity, 34# velocity_gain, torque) 35HYBRID_ACTION_DIMENSION = 5 36 37 38class HybridActionIndex(enum.Enum): 39 # The index of each component within the hybrid action tuple. 40 POSITION = 0 41 POSITION_GAIN = 1 42 VELOCITY = 2 43 VELOCITY_GAIN = 3 44 TORQUE = 4 45 46 47@gin.configurable 48class MotorLimits(object): 49 """The data class for motor limits.""" 50 51 def __init__( 52 self, 53 angle_lower_limits: Union[float, Sequence[float]] = float('-inf'), 54 angle_upper_limits: Union[float, Sequence[float]] = float('inf'), 55 velocity_lower_limits: Union[float, Sequence[float]] = float('-inf'), 56 velocity_upper_limits: Union[float, Sequence[float]] = float('inf'), 57 torque_lower_limits: Union[float, Sequence[float]] = float('-inf'), 58 torque_upper_limits: Union[float, Sequence[float]] = float('inf'), 59 ): 60 """Initializes the class.""" 61 self.angle_lower_limits = angle_lower_limits 62 self.angle_upper_limits = angle_upper_limits 63 self.velocity_lower_limits = velocity_lower_limits 64 self.velocity_upper_limits = velocity_upper_limits 65 self.torque_lower_limits = torque_lower_limits 66 self.torque_upper_limits = torque_upper_limits 67 68 69@gin.constants_from_enum 70class WheeledRobotControlMode(enum.Enum): 71 """The control mode for wheeled robots.""" 72 # Controls the base of the robot (i.e. in kinematic mode.) or the base wheels 73 # using motor commands. 74 BASE = 1 75 # Controls arm only 76 ARM = 2 77 # Controls both base and arm 78 BASE_AND_ARM = 3 79 # Controls both base and head 80 BASE_AND_HEAD = 4 81 # Controls the non-wheel motors. This include arms and heads. 82 BODY = 5 83 # Controls all degrees of freedom, i.e. the base and arm/head simultaneously. 84 ALL = 6 85 # High-level navigation target. 86 NAVIGATION_TARGET = 7 87 # Individually addressable actions for body joints, with nested dict actions. 88 ADDRESSABLE = 8 89 90 91@dataclasses.dataclass 92class TwistActionLimits: 93 """The data class for twist action limits. 94 95 Common abbreviations used in variable names suffix: 96 mps = Meters per Second 97 rps = Radians per Second 98 """ 99 max_linear_mps: float 100 min_linear_mps: float 101 max_angular_rps: float 102 min_angular_rps: float 103 104 105 106