Git Product home page Git Product logo

rbe2002_code's Introduction

RBE2002_template

Template code for the RBE 2002 final project

Libraries

Search and install:

ESP32Servo

ESP32Encoder

Adafruit_BNO055

Adafruit Unified Sensor

Esp32SimplePacketComs

SimplePacketComs

DFRobotIRPosition

Code Documentation Doxygen

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.

Base Bot CAD

(Bowler Studio) files for BaseBot modules are located in the RBELabCustomParts repository. STL files are located under the release tab.

Hardware Electrical Documentation

Hardware Documentation: https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard

Wiring Diagram

A note about the level shifter

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!

Where Is My Code?

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.

Development of your code

First install Arduino IDE and Github Desktop

Compile your code in Arduino IDE before moving on to Eclipse. If compilation is not working, do not yet move on.

Install Eclipse And Setup Eclipse on Personal Machine

See Eclipse install instructions in InstallEclipse.md

Open Projects in Eclipse using the Eclipse instructions

Code theory, structure and what to edit

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):

include graphs

Function call graphs (what function calls other functions):

function call graphs

and collaboration graphs (what data structures contain other data structures):

collaboration graphs

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

PIDMotor

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

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.

Alternate WiFi connections using Android Phone or Home WIfi

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.

Field controller app

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.

FAQ and Troubleshooting

See https://github.com/WPIRoboticsEngineering/RobotInterfaceBoard#faq-and-troubleshooting

rbe2002_code's People

Contributors

acamilo avatar keionbis avatar luketrujillo avatar madhephaestus avatar wardbenjamin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.