How to use the pyfrc.physics.units.units.volts function in pyfrc

To help you get started, we’ve selected a few pyfrc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robotpy / pyfrc / pyfrc / physics / motor_cfgs.py View on Github external
.. note:: The motor configurations that come with pyfrc are defined using the
              pint units library. See :ref:`units`
    
"""
MotorModelConfig.name.__doc__ = "Descriptive name of motor"
MotorModelConfig.nominalVoltage.__doc__ = "Nominal voltage for the motor"
MotorModelConfig.freeSpeed.__doc__ = "No-load motor speed (``1 / [time]``)"
MotorModelConfig.freeCurrent.__doc__ = "No-load motor current"
MotorModelConfig.stallTorque.__doc__ = (
    "Stall torque (``[length]**2 * [mass] / [time]**2``)"
)
MotorModelConfig.stallCurrent.__doc__ = "Stall current"

from .units import units

NOMINAL_VOLTAGE = 12 * units.volts

#: Motor configuration for CIM
MOTOR_CFG_CIM = MotorModelConfig(
    "CIM",
    NOMINAL_VOLTAGE,
    5310 * units.cpm,
    2.7 * units.amps,
    2.42 * units.N_m,
    133 * units.amps,
)

#: Motor configuration for Mini CIM
MOTOR_CFG_MINI_CIM = MotorModelConfig(
    "MiniCIM",
    NOMINAL_VOLTAGE,
    5840 * units.cpm,
github wpilibsuite / frc-characterization / arm_characterization / robot / robot-python-talonsrx / physics.py View on Github external
self.drivetrain = tankmodel.TankModel.theory(
                motor_cfg,
                robot_mass,
                drivetrain_gear_ratio,
                motors_per_side,
                robot_wheelbase,
                robot_width,
                robot_length,
                wheel_diameter,
            )
        else:
            # These are the parameters for kv/ka that you computed for your robot
            # -> this example uses the values from the paper
            l_kv = 0.81 * units.tm_kv
            l_ka = 0.21 * units.tm_ka
            l_vintercept = 1.26 * units.volts
            r_kv = 0.81 * units.tm_kv
            r_ka = 0.21 * units.tm_ka
            r_vintercept = 1.26 * units.volts

            self.drivetrain = tankmodel.TankModel(
                motor_cfg,
                robot_mass,
                robot_wheelbase,
                robot_width,
                robot_length,
                l_kv,
                l_ka,
                l_vintercept,
                r_kv,
                r_ka,
                r_vintercept,
github robotpy / pyfrc / pyfrc / physics / tankmodel.py View on Github external
def theory(
        cls,
        motor_config: MotorModelConfig,
        robot_mass: units.Quantity,
        gearing: float,
        nmotors: int = 1,
        x_wheelbase: units.Quantity = _kitbot_wheelbase,
        robot_width: units.Quantity = _kitbot_width,
        robot_length: units.Quantity = _kitbot_length,
        wheel_diameter: units.Quantity = 6 * units.inch,
        vintercept: units.volts = 1.3 * units.volts,
        timestep: int = 5 * units.ms,
    ):
        r"""
            Use this to create the drivetrain model when you haven't measured
            ``kv`` and ``ka`` for your robot.
            
            :param motor_config:    Specifications for your motor
            :param robot_mass:      Mass of the robot
            :param gearing:         Gear ratio .. so for a 10.74:1 ratio, you would pass 10.74
            :param nmotors:         Number of motors per side
            :param x_wheelbase:     Wheelbase of the robot
            :param robot_width:     Width of the robot
            :param robot_length:    Length of the robot
            :param wheel_diameter:  Diameter of the wheel
            :param vintercept:      The minimum voltage required to generate enough
                                    torque to overcome steady-state friction (see the
github robotpy / pyfrc / pyfrc / physics / tankmodel.py View on Github external
:param ka: Computed ``ka`` for your robot
            :param vintercept: The minimum voltage required to generate enough
                               torque to overcome steady-state friction (see the
                               paper for more details)
        """

        #: Current computed acceleration (in ft/s^2)
        self.acceleration = 0

        #: Current computed velocity (in ft/s)
        self.velocity = 0

        #: Current computed position (in ft)
        self.position = 0

        self._nominalVoltage = units.volts.m_from(
            motor_config.nominalVoltage,
            strict=False,
            name="motor_config.nominalVoltage",
        )
        self._vintercept = vintercept
        self._kv = kv
        self._ka = ka
github wpilibsuite / frc-characterization / arm_characterization / robot / robot-python-spark / physics.py View on Github external
drivetrain_gear_ratio,
                motors_per_side,
                robot_wheelbase,
                robot_width,
                robot_length,
                wheel_diameter,
            )
        else:
            # These are the parameters for kv/ka that you computed for your robot
            # -> this example uses the values from the paper
            l_kv = 0.81 * units.tm_kv
            l_ka = 0.21 * units.tm_ka
            l_vintercept = 1.26 * units.volts
            r_kv = 0.81 * units.tm_kv
            r_ka = 0.21 * units.tm_ka
            r_vintercept = 1.26 * units.volts

            self.drivetrain = tankmodel.TankModel(
                motor_cfg,
                robot_mass,
                robot_wheelbase,
                robot_width,
                robot_length,
                l_kv,
                l_ka,
                l_vintercept,
                r_kv,
                r_ka,
                r_vintercept,
            )