Template code for the RBE 2002 final project
Open ArduinoIDE and search for these libraries using Library Manager
ESP32Servo
ESP32Encoder
ESP32WifiManager
Adafruit_BNO055
Adafruit Unified Sensor
Esp32SimplePacketComs
SimplePacketComs
DFRobotIRPosition
In you checked out code, open doc/html/annotated.html to see the Doxygen documentation. The best way to understand this code is to start in the Files section of the documentation, and look at the .ino file. Look at the setup and loop call graphs.
(Bowler Studio) files for BaseBot modules are located in the RBELabCustomParts repository. STL files are located under the release tab.
Hardware Documentation: https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard
It is important to make sure the red connection (3.3v) is attached to the level shifter. Omitting this connection can damage your ESP32. Check Twice!
Your private Repository has been created for you here: https://github.com/RBE200x-lab
You and your team members should find your repository made with the template code in there.
See Eclipse install instructions in InstallEclipse.md
Open Projects in Eclipse using the Eclipse instructions
If find yourself saying:
Geez, thats a lot of code :/ I dont even know where to begin...
then start here.
The first thing to dig into is not the code, but the documentation. The template code that you all got copies of is documented using Doxygen a code auto-documentation tool. It generates a rather nice website of hyperlinked documentation of all the code in this repository. Besides the normal text based documentation, it also will generate very nice graphs such as
Include graphs (what headers include other headers):
Function call graphs (what function calls other functions):
and collaboration graphs (what data structures contain other data structures):
To access the full documentation, after cloning the code to your disk, open the doc/html/annotated.html file to start. Opening any of the .html files will get you into the mini website as well. This web site documents all of the code you will have access to while working on your robot.
There are only 2 classes you need to edit to do all of your labs, StudentsRobot and RBEPID. Use the Doxygen to search for them and navigate the Doxygen pages to learn about what these 2 classes are and how the code uses them.
PIDMotor is a helper class that you will use but not have to modify (unless you want to, then go for it!). This class will use your PID implementation (it is defaulted to a simple p controller). It provides helper functions and structure for your PID controller. This class is also used by the communication layer to view and edit the PID controller from Java. PIDMotor has 3 subclasses
HBridgeEncoderPIDMotor wraps the ESP32Encoder and an h-Bridge control using ESP32PWM and digitalWrite().
ServoEncoderPIDMotor wraps the ESP32Encoder and the ESP32Servo objects.
ServoAnalogPIDMotor wraps the ESP32Encoder and the ADC module.
Both classes can be used interchangeably using the methods in PIDMotor. You can set setpoints using startInterpolationDegrees, or set the motor to run at a velocity using setVelocityDegreesPerSecond. You can read the position of the motor using getAngleDegrees and its velocity using getVelocityDegreesPerSecond. Use the Doxygen pages to look up usage information.
Your robot's program will go in StudentsRobot. This class will get passed the PIDMotor objects to attach. This class will then be passes those same objects again each time the loop is called via the pidLoop method. After each pidLoop, the updateStateMachine is called and the motor objects are passed in.
Your PID code will go in RBEPID. You will implement a PID controller in one of your labs and tune it for your robots motors. By default there is a simple P controller in the compute function. Note that you will need to implement both calc and clearIntegralBuffer.
The 'config.h' file contains all of the pin definitions and the name of the robot. You should not change any of the pin definitions. You can add other pin definitions in header for the Final project, but do not change the pre-defined values. You should change TEAM_NAME to match your team number before using WiFi.
Commands from Java are sent over the WiFi. For the WiFi to work the computer running the Java application and the ESP32 need to have the same subnet. This means out of the 4 number IP address printed by the ESP32's serial port when it connects:
WiFi connected! IP address: 192.168.1.116
the first 3 match the computer that the Java application is running on. The lab ESP32's are pre-configured to connect to the special FI103-Robots WiFi network, putting them on the same subnet as the lab computers and any computer plugged into the spare ethernet cables on the benchtops. NOTE WPI-Wireless is a different subnet and they will not be able to talk to each other.
To search for your device, type the name you set in your .ino file. Use the control application to search for that device. If it finds it, it will open up the controls and you can send commands from the Java application to your robot. Those commands will call the associated method in StudentsRobot object.
Connecting to a hotspot or home wifi can be done with the ESP32 and the serial monitor. Make sure the serial monitor is not using any line endings and open at 115200 and you can see the print statements of the core running. Type the name of the WiFi network you want to connect to into the serial send bar and once ita all there, hit enter. Wait for the WifiManager to prompt you for the password, then type that in as well and hit enter.
Android phones hotspot mode works well. the iPhone hotspot does not work and seems to filter the communication packets out.
The field controller can be found here:
https://github.com/WPIRoboticsEngineering/2001_Field_Controller/releases
It is a runnable .JAR file. Download it and run.
See https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard#faq-and-troubleshooting
https://github.com/WPIRoboticsEngineering/RBE2002_template/raw/master/BOM%20Cost.pdf