Changes between Version 5 and Version 6 of ControlSystems/SoftwareTeam/Training/GettingStarted/Autonomous


Ignore:
Timestamp:
Nov 3, 2019, 8:44:41 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/Autonomous

    v5 v6  
    5656  }}}
    5757  * For CAN motor controllers (Hazelnut) note the use of the [https://www.ctr-electronics.com/downloads/api/java/html/classcom_1_1ctre_1_1phoenix_1_1motorcontrol_1_1can_1_1_base_motor_controller.html#afb934a11682e710df123eec35aba1ba9 getSelectedFeedbackSensor()] method of the motor controller object which returns raw encoder counts. 
    58   Add the following function to the Robot class:
    59   {{{
    60      double raw2inches(int raw_count, int counts_per_rotation, double wheel_diameter) {
    61         return (raw_count / counts_per_rotation) * (3.141492 * wheel_diameter);
    62      }
    63   }}}
    64   Add the following to the robotPeriodic() method:
    65     // Encoders connected to CAN controller return raw counts
    66     double l_raw = leftMotor.getSelectedSensorPosition();
    67     double r_raw = rightMotor.getSelectedSensorPosition();
    68     // display distances on smart dashboard
    69     SmartDashboard.putNumber("Left", raw2inches(l_raw, 360*2, 7.5));
    70     SmartDashboard.putNumber("Right", raw2inches(r_raw, 360*2, 7.5));
    71   }}}
     58     * Add the following function to the Robot class:
     59     {{{
     60        double raw2inches(int raw_count, int counts_per_rotation, double wheel_diameter) {
     61           return (raw_count / counts_per_rotation) * (3.141492 * wheel_diameter);
     62        }
     63     }}}
     64     * Add the following to the robotPeriodic() method:
     65     {{{
     66        // Encoders connected to CAN controller return raw counts
     67        double l_raw = leftMotor.getSelectedSensorPosition();
     68        double r_raw = rightMotor.getSelectedSensorPosition();
     69        // display distances on smart dashboard
     70        SmartDashboard.putNumber("Left", raw2inches(l_raw, 360*2, 7.5));
     71        SmartDashboard.putNumber("Right", raw2inches(r_raw, 360*2, 7.5));
     72     }}}
    7273
    7374* In autonomousInit() reset the encoder counts and start the motors: