1 / 40

Introduction to Java programming for the first robotics competition

Introduction to Java programming for the first robotics competition. Jonathan Daniel Head programmer Fernbank links. Disclaimers. This session WILL NOT teach you all of Java. This session WILL teach you how to use your knowledge of Java with the FRC Java Libraries. What is programming?.

Download Presentation

Introduction to Java programming for the first robotics competition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Java programmingfor the first robotics competition Jonathan Daniel Head programmer Fernbank links

  2. Disclaimers • This session WILL NOT teach you all of Java. • This session WILL teach you how to use your knowledge of Java with the FRC Java Libraries.

  3. What is programming?

  4. Programming is… • Computer programming is the craft of writing useful, maintainable, and extensible source code which can be interpreted or compiled by a computing system to perform a meaningful task. • FRC Programming Languages • C++ • Java • Python • LabVIEW

  5. Review of java • Java is an object-oriented programming language. • Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. • A Java program can be separated into different classes, which are templates for creating objects with different behaviors.

  6. What’s in a class? • Java classes contain methods and variables. • A method is a function that can be executed by a class. Sometimes, you will have a method that returns some form of data to the robot. • One method could be to ask the robot how much battery power it has. • A variable is a container for data. • Variable X = 9 • Variable Y = “These three words” • All Java class files end with the extension .java . • In order for a class to read another class, you have to use an import statement. • When you use an import statement, all of the public methods in that class will be absorbed into your new class. • For example, you might import class1 into class2, so you can use class1’s methods!

  7. Important java keywords • A keyword is a special word/phrase that is used to define some aspect of a class, method or variable. • Public • All other classes can see this method/variable. • Private • This method/variable will only be seen in its current class. • Protected • This method/variable can only be seen by subclasses of the current class. • Extends • This is when the class becomes a subclass of another class. • Public class Dog extends Animal • Import • When you load all of another class’s public methods/variables into your own class. • New • Creates a new object of a certain class.

  8. Types of objects • Objects are digital items that can be referenced by computers. • There are many types of objects, but these are the most common ones. • Integer • Any number that doesn’t contain a decimal point. • Double • Any number that does contain a decimal point. • Boolean • A binary variable that can be interpreted as true or false. • String • Any text that is surrounded by double quotation marks. • Void • This will only be used with methods, and it means that the method returns nothing. • Static • No matter how many objects of this type are created, there will only be one of this method OR variable.

  9. Let’s do a quick quiz!

  10. What type of object is 9.0 ? • Integer • String • Double • Boolean

  11. What type of object is “true”? • Double • String • Boolean • Integer

  12. THE MOST IMPORTANT ASPECT OF JAVA! • Semicolons are one of the most important symbols in Java! • Unless you are creating a method or loop, you have to use a semicolon to end the a line of code. • This lets the program know that it has reached the end of a line and it needs to move to the next one. ;

  13. What do I use to program my robot?

  14. Introduce the eclipse ide

  15. Package explorer • The package explorer is a file explorer for all of your Eclipse Projects. • Eclipse Project = Java Program • Packages are folders that can be used to contain java classes • When you create a robot project using the iterative template, Eclipse will create a default package and a default class. • Org.usfirst.frc.team0000.robot • Robot.java. • Depending on your robot’s functions, you may want to create different packages for each function.

  16. Console • Will document the deployment of your code to the robot, so you will know if it was successful.

  17. The Programmable electronics

  18. roborio • Main Robot Controller • RIO to PC Communication • Ethernet • USB Cable • Wireless (if Radio is configured) • 10 Pulse Width Modulation Ports (0-9) • Controls the Motors • 10 Digital Ports (0-9) • Communicates with digital sensors • 4 Analog Ports (0-3) • Communicates with analog sensors Digital PWM Analog

  19. Joysticks

  20. Motor controller • PWM - Pulse Width Modulation • To control the speed of the motor, the speed controller switches the full input voltage on and off very quickly. • There are ten PWM ports on the RoboRIO, and each port controls one motor. • Most PWM classes use set(speed) methods to determine the speed of the motor. • The parameter is a double value that ranges from -1.0 to +1.0, with 1.0 being full forward and -1.0 being full reverse. • Inversion of Motors • Typically, you will need to set one of your motors to interpret +1.0 as -1.0 by using setInverted(). • CAN – Controller Area Network • More advanced form of control that allows for feedback.

  21. Let’s Program a robot to drive around!

  22. Controlling pneumatics

  23. The main electronics

  24. Overview of pneumatics

  25. Pneumatics overview – pneumatics control module • The Pneumatics Control Module is the mechanism that is responsible for the management of the compressors and solenoids on the robot. • 8 Solenoid Ports • 8 Single Solenoids • 4 Double Solenoids • 1 Compressor Port • Pressure Relief Valve Port

  26. Why use pneumatics?

  27. Let’s program a shifting drivetrain!

  28. Sensors

  29. Why use a sensor?

  30. System.out.println(‘Message’)System.out.print(‘Message’)System.out.println(‘Message’)System.out.print(‘Message’)

  31. The Sensor family tree

  32. Analog vs. digital

  33. Let’s have our Robot tell us about our gyro!

  34. Cameras in FRC!

  35. Cameras

  36. Let’s Program our robot to stream video!

  37. NEtworking • If you are using an IP Camera, you will have to assign it an IP Address. • 10.TE.AM.11 • A good static address should be safe from other internet devices. • 10.08.00 for Team 800 • Subnet 255.255.255.0 • 10.44.68.11 • The FMS allows each team to use a bandwidth of 7 megabits/second. • 6 Mbps after driver station packets. • If you plan on streaming your camera to the driver station, you will probably need to use compression.

  38. Resources – FRC Stack • WPILib ScreenSteps Tutorials • https://wpilib.screenstepslive.com/s/4485 • API Documentation • http://first.wpi.edu/FRC/roborio/release/docs/java/ • Chief Delphi • https://www.chiefdelphi.com/ • GitHub • GitHub Student Developer Pack: https://education.github.com/pack • Fernbank LINKS GitHub: https://www.github.com/fernbanklinksrobotics • Team GitHub List • http://bit.ly/TeamGithubs

  39. Resources – Learning Java • Codecademy • www.codecademy.com • Start:Code • Classes in the Decatur Area • www.startcode.net • AP Computer Science • Teaches CS with Java

  40. Questions? Email: jonathandaniel@fernbanklinks.com

More Related