Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaWorkshop Part 3. Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP.

Similar presentations


Presentation on theme: "JavaWorkshop Part 3. Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP."— Presentation transcript:

1 JavaWorkshop Part 3

2 Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP 101

3 ObjectOriented Programming CLASS! A class is just a blueprint of the object will create that we

4 It can impor t another methods from class Name of the class Also tells you what related to itis It can have member variables It MUST have constructor, a sometimes more than one It can have member functions

5 Extends: is-a relationship. A joystick is a GenericHID A joystick can do everythingaGenericHID can. Implements: has relationship A joystick has all the functions interface of IInputOutput

6 Privatefunctions Public functions

7 Publicvs.Private Public keyword means it can be accessed with dot operator outside of the class Private keyword means it can only be accessed WITHIN the class. Cannot be accessed with dot operator

8 Constants Constants are often declared with public static final in some cases just static final

9 Instantiation To create an instant of an object using blueprint. the class You must ask the program to create an object with the keyword “new” Once it’s instantiated, you will refer to your object by its name, not the name of the blueprint

10 O Howtoinstantiateanobject SchoollowellHighSchool = newSchool(697); Typeofobject MAGIC WORD T MAKENEW THINGS!! Nameof object Constructorwith argument

11 Make a new project and name it 2014Team4159Recode Name the class Main

12 Outline of what physical componentswehave Drive Train 6 Talons, 2 sides Pneumatics Shifting solenoid Pickup soleniods Pickup 1 Talon Sensors Gyro 2 Encoders Joysticks 2 driving 1 secondary

13 Outline of desired functions Autonomous Roborealm interface to allow the “cheat” Multiple modes for autoinsmartdashboard drive straight dump ball Teleop Tank drive, shifting Pickup, both the motor andraise/lower

14 Since this program is relatively big, it’s best to keep everything organized and as modularized as possible. So we will create an IO class to store all of our connections to the physical world.

15 Just a bit more gardening to make it look even more organized

16 Now fill the stuff in with the pinout sheet. I’ll leave that to you guys However, you must use public static final as type since you don’t want these things to change under any circumstances

17 Now we need to call the IO class at the beginning of the main code so we can instantiate the physical components. DO NOT INSTANTIATE THE IO CLASS

18 Now time for some classes for our individual components of the robot Drive we will write our own custom drive functions to incorporate the gyro Pickup

19 Drive

20 Pickup

21 Teleop Since teleop is simpler, lets write what we want to do in teleop first the codefor Drive(shifting) Pickup control(motor spin + raise/lower)

22 Button actions DriveStick: 2/3 => low/high gear ShooterStick:4/5 => lower/raisepickup ShooterStick:3/Trigger => spinspickup Set refresh rateat 20ms

23

24 Autonomous We have to use SmartDashboard to select the specific type of autonomous mode we’re doing Make another class, name it DashboardManager Assume Roborealm gives a number of how many “signals” it sees. When it sees more than 0, it will return the boolean “shootReady” to true Variable named BLOB_COUNT

25 AutonomousModeActions To prevent Main.java from getting messy and unreadable, we will create another class named AutonomousModeActions This class will store all the actions of the robot for each cases during autonomous

26 DashboardManager We have 4 predefined actionswecantake Low goal blind auto = 1 Low goal detection auto= 2= 2 Drive only auto = 3 No Drive auto = 4

27 Add those 4 variables as constants into the AutonomousModeActions class Now write those 4 methods

28

29 DashboardManager Now we can setup a radio button list in SmartDashboard for each mode. Assign the int associated with each mode to the radio button.

30

31 Autonomous Now going back to Main.java, we need to tell robot what do to during Autonomous mode the First need to stop all the motors just to make sure we’re not moving use “getAutonomousMode” function you just wrote to get which mode of autonomous the driver selected

32 Since the mode selected will be returned as an int, use a switch to determine which mode you’re in and call the appropriate function in AutonomousModeActions class

33

34 We are DONE!!!! Now clean and build the program to make sure there’s no bug.


Download ppt "JavaWorkshop Part 3. Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP."

Similar presentations


Ads by Google