Learner

Deploying Code over WiFi or Bluetooth

So far we have been deploying code to the EV3 over a USB cable connecting the EV3 to the development PC. This works fine but is tedious, time consuming and may mean moving the robot closer to the PC. A much better way to do development is to connect the EV3 and PC over WiFi (wireless network) or Bluetooth (wireless peer-to-peer).

Exercise: Using Logging

We are now going to take a look at logging (also called tracing) as a tool to debug our robot programs. Logging is recording useful information from our robot program to a disk file on the EV3 controller. We can then download that file to the development PC and examine it. It can be very useful to record information while your robot is running during a match so you can look at it afterwards and see what took place.

Multi-Threading

An executing Java program is called a Process. That process executes your instructions (program) sequentially following the path you created when you wrote your program. This single path is called a thread. As such, your program is only doing one activity (Java statement) at a time and working on one task (your programs list of statements) at a time. For most situations, this works fine. But there are times when you would like to have your program doing more than one thing at time.

Files and File Input/output

Writing data to and reading data from disk files is a common activity for Java programs in many situations. However, file input/output (I/O) is rarely used in the programs created for robots on the platforms we are working with. As such, and given that file I/O is a large and complex topic, it is not going to be covered here. For those who are interested, here are some resources where you can learn more:

Data Conversion (Casting)

Java provides the ability to convert from one data type to another within a set of rules. Some conversions are made automatically and some you have to explicitly request.

Here is a discussion of converting between primitive data types.

Here is a discussion of converting between reference (object) data types.

Deploying Code over WiFi

If you are using OnBot, you can skip this lesson. AS users, read on!

As you have no doubt learned, deploying code with a USB cable is time consuming and means taking the controller phone off the robot. When you are developing actual robot code, you will be doing this a lot. There is a better way.

You can deploy your code over a WiFi network instead of using a cable. This is much quicker and leaves the controller phone on the robot. Here are the instructions on how to do it using WiFi Direct.

Exercise: Using a Range Sensor

Modern Robotics has a range sensor designed for use with the Tetrix control system. This sensor can read the distance to a surface when the surface is between 5 and 255 centimeters of the sensor. The FTC SDK has a sample program you can use to experiment with the range sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRRangeSensor. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK.

Exercise: Using a Gyro

Modern Robotics has an gyroscopic sensor designed for use with the Tetrix control system. This sensor can return heading and rate of rotation information. Here is a detailed discussion of the Gyro sensor on the Modern Robotics website. There are links on the page to programming information. This is recommended viewing. Note that the REV hub has a built-in gyro as part of its IMU discussed in the next lesson.

Exercise: Using a Compass

Modern Robotics has an Compass sensor designed for use with the Tetrix control system. This sensor can read the magnetic heading of the sensor, acceleration and tilt. The FTC SDK has a sample program you can use to experiment with the Optical Distance sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRCompass. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK. You can copy the class in the teamcode area so any changes you make will be retained.

Exercise: Using an Optical Distance Sensor

Modern Robotics has an Optical Distance sensor designed for use with the Tetrix control system. This sensor can read the distance to a surface when the surface is within 15 centimeters of the sensor. The FTC SDK has a sample program you can use to experiment with the Optical Distance sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMROpticalDistance. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK.

Pages