Module Expr Str Import alias Import alias ImportFrom alias alias Import alias Import alias Assign NameStore Call AttributeLoad NameLoad attr Str ImportFrom alias ClassDef bases NameLoad body Pass decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Pass decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Pass decorator_list decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Assign AttributeStore NameLoad attr SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Str If Call NameLoad NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad handlers ExceptHandler body Expr Call AttributeLoad NameLoad attr Str Raise Call NameLoad If UnaryOpNot Call NameLoad NameLoad Str body Expr Call AttributeLoad NameLoad attr Str Raise Call NameLoad TryExcept body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad If Call NameLoad AttributeLoad NameLoad attr Str body Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr handlers ExceptHandler body Expr Call AttributeLoad NameLoad attr Str Raise Call NameLoad Expr Call AttributeLoad NameLoad attr Str orelse Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Return Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad orelse Assign NameStore BinOpSub NameLoad NameLoad If CompareGt NameLoad Num body Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return CompareIsNot AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign SubscriptStore SubscriptLoad NameLoad Index Str Index NameLoad Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot AttributeLoad NameLoad attr body Return Assign NameStore BinOpMult NameLoad NameLoad Assign NameStore BinOpMult NameLoad NameLoad Assign NameStore BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot AttributeLoad NameLoad attr body Return Assign NameStore BinOpMult NameLoad NameLoad Assign NameStore BinOpMult NameLoad NameLoad Assign NameStore BinOpMult NameLoad NameLoad Assign NameStore BinOpAdd BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body With AttributeLoad NameLoad attr body AugAssignAdd AttributeStore NameLoad attr NameLoad AugAssignAdd AttributeStore NameLoad attr NameLoad AugAssignAdd AttributeStore NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AugAssignAdd AttributeStore NameLoad attr BinOpSub BinOpMult NameLoad NameLoad BinOpMult NameLoad NameLoad AugAssignAdd AttributeStore NameLoad attr BinOpAdd BinOpMult NameLoad NameLoad BinOpMult NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad For NameStore AttributeLoad NameLoad attr body AugAssignAdd SubscriptStore SubscriptLoad AttributeLoad NameLoad attr Index Str Index NameLoad NameLoad Assign NameStore BinOpDiv NameLoad Num For NameStore AttributeLoad NameLoad attr body AugAssignAdd SubscriptStore SubscriptLoad SubscriptLoad AttributeLoad NameLoad attr Index Str Index NameLoad Index Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str With AttributeLoad NameLoad attr body Return TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A 
    pyfrc supports simplistic custom physics model implementations for
    simulation and testing support. It can be as simple or complex as you want
    to make it. We will continue to add helper functions (such as the 
    :mod:`pyfrc.physics.drivetrains` module) to make this a lot easier
    to do. General purpose physics implementations are welcome also!

    The idea is you provide a :class:`PhysicsEngine` object that overrides specific
    pieces of WPILib, and modifies motors/sensors accordingly depending on the
    state of the simulation. An example of this would be measuring a motor
    moving for a set period of time, and then changing a limit switch to turn 
    on after that period of time. This can help you do more complex simulations
    of your robot code without too much extra effort.

    .. note::

       One limitation to be aware of is that the physics implementation
       currently assumes that you are only calling :func:`wpilib.Timer.delay`
       once per main loop iteration. If you do it more than that, you may get
       some rather funky results.

    By default, pyfrc doesn't modify any of your inputs/outputs without being
    told to do so by your code or the simulation GUI.
    
    See the physics sample for more details.

    Enabling physics support
    ------------------------

    You must create a python module called ``physics.py`` next to your 
    ``robot.py``. A physics module must have a class called
    :class:`PhysicsEngine` which must have a function called ``update_sim``.
    When initialized, it will be passed an instance of this object.
    
    You must also create a 'sim' directory, and place a ``config.json``
    file there, with the following JSON information::
    
        {
          "pyfrc": {
            "robot": {
              "w": 2,
              "h": 3,
              "starting_x": 2,
              "starting_y": 20,
              "starting_angle": 0
            },
            "field": {
              "w": 25,
              "h": 27,
              "px_per_ft": 10
            }
          }
        }
    
 N/A imp N/A math os.path exists join N/A threading N/A logging N/A logger N/A N/A logging getLogger pyfrc.physics hal_impl.data hal_data PhysicsInitException N/A Exception N/A N/A N/A PhysicsEngine N/A N/A N/A 
        Your physics module must contain a class called ``PhysicsEngine``, 
        and it must implement the same functions as this class.
        
        Alternatively, you can inherit from this object. However, that is
        not required.
     __init__ N/A N/A self physics_controller N/A N/A N/A 
            The constructor must take the following arguments:
            
            :param physics_controller: The physics controller interface
            :type  physics_controller: :class:`.PhysicsInterface`
         N/A N/A self physics_controller physics_controller N/A initialize N/A N/A self hal_data N/A N/A N/A 
            Called with the hal_data dictionary before the robot has started
            running. Some values may be overwritten when devices are
            initialized... it's not consistent yet, sorry.
         N/A N/A update_sim N/A N/A self hal_data now tm_diff N/A N/A N/A 
            Called when the simulation parameters for the program need to be
            updated. This is mostly when ``wpilib.Timer.delay()`` is called.
            
            :param hal_data: A giant dictionary that has all data about the robot. See
                             ``hal-sim/hal_impl/data.py`` in robotpy-wpilib's repository
                             for more information on the contents of this dictionary.
            :param now: The current time
            :type  now: float
            :param tm_diff: The amount of time that has passed since the last
                            time that this function was called
            :type  tm_diff: float
         N/A N/A N/A PhysicsInterface N/A N/A N/A 
        An instance of this is passed to the constructor of your
        :class:`PhysicsEngine` object. This instance is used to communicate
        information to the simulation, such as moving the robot on the
        field displayed to the user.
     __init__ N/A N/A self robot_path fake_time config_obj N/A N/A N/A N/A self last_tm None N/A N/A self _lock N/A N/A threading Lock N/A N/A self x N/A N/A N/A config_obj N/A pyfrc N/A robot N/A starting_x N/A N/A self y N/A N/A N/A config_obj N/A pyfrc N/A robot N/A starting_y N/A N/A self angle N/A N/A math radians N/A N/A N/A config_obj N/A pyfrc N/A robot N/A starting_angle N/A N/A self vx 0 N/A N/A self vy 0 N/A N/A self fake_time fake_time N/A N/A self robot_enabled False N/A N/A self config_obj config_obj N/A N/A self engine None N/A N/A self analog_gyro_channels N/A N/A N/A self device_gyro_channels N/A N/A N/A self hal_data hal_data N/A physics_module_path N/A join robot_path physics.py N/A N/A exists physics_module_path N/A N/A N/A N/A physics_module N/A N/A imp load_source physics physics_module_path N/A N/A N/A N/A N/A N/A logger exception Error loading user physics module N/A N/A PhysicsInitException N/A N/A N/A hasattr physics_module PhysicsEngine N/A N/A N/A N/A logger error User physics module does not have a PhysicsEngine object N/A N/A PhysicsInitException N/A N/A N/A N/A self engine N/A N/A physics_module PhysicsEngine self N/A N/A hasattr N/A self engine initialize N/A N/A N/A N/A N/A self engine initialize N/A self hal_data N/A N/A N/A N/A N/A N/A logger exception Error creating user's PhysicsEngine object N/A N/A PhysicsInitException N/A N/A N/A logger info Physics support successfully enabled N/A N/A N/A N/A logger warning Cannot enable physics support, %s not found physics_module_path N/A setup_main_thread N/A N/A self N/A N/A N/A N/A N/A self engine None N/A N/A N/A N/A N/A self fake_time set_physics_fn N/A self _on_increment_time N/A __repr__ N/A N/A self N/A N/A N/A Physics N/A _on_increment_time N/A N/A self now N/A N/A N/A last_tm N/A self last_tm N/A N/A last_tm None N/A N/A N/A self last_tm now N/A N/A tm_diff N/A now last_tm N/A N/A tm_diff 0.01 N/A N/A N/A N/A N/A self engine update_sim N/A self hal_data now tm_diff N/A N/A self last_tm now N/A _set_robot_enabled N/A N/A self enabled N/A N/A N/A N/A self robot_enabled enabled N/A _has_engine N/A N/A self N/A N/A N/A N/A N/A self engine None N/A add_analog_gyro_channel N/A N/A self ch N/A N/A N/A 
            If you want to enable a wpilib :class:`.AnalogGyro` object to
            be updated when the robot rotates, add the channel number via
            this function.
            
            :param ch: Analog input channel that the gyro is on
            :type  ch: int
         N/A N/A N/A N/A self analog_gyro_channels append ch N/A N/A add_gyro_channel add_analog_gyro_channel add_device_gyro_channel N/A N/A self angle_key N/A N/A N/A 
            :param angle_key: The name of the angle key in ``hal_data['robot']``
         N/A N/A N/A hal_data N/A robot N/A angle_key 0 N/A N/A N/A N/A self device_gyro_channels append angle_key N/A drive N/A N/A self speed rotation_speed tm_diff N/A N/A N/A Call this from your :func:`PhysicsEngine.update_sim` function.
           Will update the robot's position on the simulation field.

           You can either calculate the speed & rotation manually, or you
           can use the predefined functions in :mod:`pyfrc.physics.drivetrains`.
           
           The outputs of the `drivetrains.*` functions should be passed
           to this function.

           .. note:: The simulator currently only allows 2D motion
           
           :param speed:           Speed of robot in ft/s
           :param rotation_speed:  Clockwise rotational speed in radians/s
           :param tm_diff:         Amount of time speed was traveled (this is the 
                                   same value that was passed to update_sim)
         N/A N/A N/A self robot_enabled N/A N/A N/A distance N/A speed tm_diff N/A angle N/A rotation_speed tm_diff N/A x N/A distance N/A N/A math cos angle N/A y N/A distance N/A N/A math sin angle N/A N/A N/A self _move x y angle N/A vector_drive N/A N/A self vx vy vw tm_diff N/A N/A N/A Call this from your :func:`PhysicsEngine.update_sim` function.
           Will update the robot's position on the simulation field.
           
           This moves the robot using a vector relative to the robot
           instead of by speed/rotation speed.
           
           :param vx: Speed in x direction relative to robot in ft/s
           :param vy: Speed in y direction relative to robot in ft/s
           :param vw: Clockwise rotational speed in rad/s
           :param tm_diff:         Amount of time speed was traveled
         N/A N/A N/A self robot_enabled N/A N/A N/A angle N/A vw tm_diff N/A vx N/A vx tm_diff N/A vy N/A vy tm_diff N/A x N/A N/A vx N/A N/A math sin angle N/A vy N/A N/A math cos angle N/A y N/A N/A vx N/A N/A math cos angle N/A vy N/A N/A math sin angle N/A N/A N/A self _move x y angle N/A _move N/A N/A self x y angle N/A N/A N/A N/A self _lock N/A N/A N/A self vx x N/A N/A self vy y N/A N/A self angle angle N/A c N/A N/A math cos N/A self angle N/A s N/A N/A math sin N/A self angle N/A N/A self x N/A N/A x c N/A y s N/A N/A self y N/A N/A x s N/A y c N/A N/A N/A self _update_gyros angle N/A _update_gyros N/A N/A self angle N/A N/A N/A angle N/A N/A math degrees angle N/A k N/A self device_gyro_channels N/A N/A N/A N/A N/A self hal_data N/A robot N/A k angle N/A gyro_value N/A angle 2.79017857143e-12 N/A gyro_ch N/A self analog_gyro_channels N/A N/A N/A N/A N/A N/A self hal_data N/A analog_in N/A gyro_ch N/A accumulator_value gyro_value N/A get_position N/A N/A self N/A N/A N/A 
            :returns: Robot's current position on the field as `(x,y,angle)`.
                      `x` and `y` are specified in feet, `angle` is in radians
         N/A N/A self _lock N/A N/A N/A N/A self x N/A self y N/A self angle N/A _get_vector N/A N/A self N/A N/A N/A 
            :returns: The sum of all movement vectors, not very useful
                      except for getting the difference of them
         N/A N/A N/A self vx N/A self vy N/A self angle N/A N/A