How to use the pyfrc.physics.tankmodel.TankModel.theory 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 / tests / test_tankmodel.py View on Github external
def test_tankdrive_get_distance():
    """Test TankModel.get_distance() by driving in a quarter circle.
    If the turn angle is 90deg, then x should equal y. get_distance() runs in little steps,
    so multiple calls should be equivalent to a single call"""

    # just use the default robot
    tank = tankmodel.TankModel.theory(
        motor_cfgs.MOTOR_CFG_CIM,
        robot_mass=90 * units.lbs,
        gearing=10.71,
        nmotors=2,
        x_wheelbase=2.0 * units.feet,
        wheel_diameter=6 * units.inch,
    )
    # slight turn to the right
    l_motor = 1.0
    r_motor = -0.9

    # get the motors up to speed, so that subsequent calls produce the same result
    tank.calculate(l_motor, r_motor, 2.0)

    # figure out how much time is needed to turn 90 degrees
    angle = 0.0
github wpilibsuite / frc-characterization / arm_characterization / robot / robot-python-talonsrx / physics.py View on Github external
robot_mass = 110 * units.lbs

        bumper_width = 3.25 * units.inch
        robot_wheelbase = 22 * units.inch
        robot_width = 23 * units.inch + bumper_width * 2
        robot_length = 32 * units.inch + bumper_width * 2

        wheel_diameter = 3.8 * units.inch
        drivetrain_gear_ratio = 6.1
        motors_per_side = 3

        # Uses theoretical parameters by default, change this if you've
        # actually measured kv/ka for your robot
        if True:

            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
github wpilibsuite / frc-characterization / arm_characterization / robot / robot-python-spark / physics.py View on Github external
robot_mass = 110 * units.lbs

        bumper_width = 3.25 * units.inch
        robot_wheelbase = 22 * units.inch
        robot_width = 23 * units.inch + bumper_width * 2
        robot_length = 32 * units.inch + bumper_width * 2

        wheel_diameter = 3.8 * units.inch
        drivetrain_gear_ratio = 6.1
        motors_per_side = 3

        # Uses theoretical parameters by default, change this if you've
        # actually measured kv/ka for your robot
        if True:

            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