-
Notifications
You must be signed in to change notification settings - Fork 0
WPI Library Simulation
Adrian Patterson edited this page Feb 7, 2021
·
1 revision
- In this workshop, we'll discuss the use of WPI Library simulation and why it's useful
- In short, today we'll cover:
- Discuss why simulating your code is useful
- The download/installation of the WPI Framework
- Creating a simple WPI Project
- Simulating the project and exploring different tools
- Make sure you have the following:
- A computer with Windows 10
- An xbox/ps4 controller (optional)
- Simulating our robot allows us to test the functionality of our code without even touching a robot
- Using the WPI simulator, we can validate that our code can:
- Compile and run without error
- Test the logic of our code -- Does it make sense?
- Apply tele-operated inputs and observe code output
- Overall we get a better sense of what our code is doing and whether it works the way we want it to
- Before we can get started, we need to make sure we have all the necessary dependencies downloaded
- Skip this section if already done
-
Downloading the WPI Installer
- Visit the official WPI Library release page on GitHub
- Scroll to the bottom and download the WPILib_Windows64-2021.2.2.iso
- Find the .iso disc image file where you downloaded it to
- Right click the file and select mount
- Run the installer by clicking on strong text
- Install VS code (if not already installed)
- Leave all boxes checked and finish installation
- Open up 2021 WPILib VS Code by either searching "WPI" or double-clicking the application on your desktop
- On the top right corner of the IDE, you'll see a "W" symbol -- this is used to run features and tools of the WPI framework
- We'll be using this button to:
- Create a project from the given examples
- Simulate a robot
- Explore other WPI tools
- We'll be using this button to:
- From the WPI command line, type "Create a new project" and select the search result
- From here, a page will open prompting us to configure our project
- To start a new project, follow the following steps:
- Select an Select a Project Type
- Click on example
- Select Language as java
- Choose any project you'd like!
- Read the description and keep it in mind as we simulate the robot
- Choose a base folder, i.e. a directory where your project will be stored
- Name your project under Project Name
- Leave Create a new folder? checked
- Enter 296 under Team Number
- Check Enable Desktop Support
- Select Generate Project
- Select an Select a Project Type
- You'll then get a message saying your project was generated. Select Yes to open your project in a new window
-
What happened?
- The WPI Library framework generated all the necessary files and code for your project. Take a look at some of the java code under the
/srcdirectory on the left
- The WPI Library framework generated all the necessary files and code for your project. Take a look at some of the java code under the
- To simulate the robot project, type "Simulate Robot Code on Desktop" and select the search result
- Select both extensions when asked, and click "OK" to launch the GUI
- A GUI will now pop up, with a variety of information about our build
- A few boxes are open by default when a project is initialized, including:
-
Robot State
- What type of operation?
-
Other Devices
- Devices connected to your robot, not seen under the "Hardware" tab
-
System Joysticks
- Displays your connected robot controllers
- Plug in your controller -- You should see it pop up in this box!
- Displays your connected robot controllers
-
Joysticks
- Displays what joysticks are active
-
Robot State
- By connecting your controller (via bluetooth or wired in), it'll show up under System Joysticks
- Click and drag your controller to the Joysticks box
- Test if your controller is connected
- Try wiggling one of the joysticks -- you should see a response under the axes
- Try clicking a button -- one of the yellow boxes should become toggled
-
Hardware
- Under the "Hardware" tab at the top of the window, you'll see a list of connected hardware for your project
- Open any un-selected hardware, and experiment with the controller to see what happens
- Keep in mind that different example projects will have different hardware!
- Under the "Hardware" tab at the top of the window, you'll see a list of connected hardware for your project
-
Timing
- The "Timing" box displays elapsed time since the code began simulation
- You can also pause, step, and resume the time
- By clicking step you advance the time by increments rather than continuously running
-
Robot States
- The "Robot States" box provides the different modes of operation for our robot, and will simulate the selected state
- Note that an controller will only be able to control the simulated robot in teleoperated mode
- WPI Library also offers a variety of other tools
- Shuffleboard is a kind of dash board that presents the same info but in a more visually pleasing way
-
How to access Shuffleboard/Other Tools:
- Search "Start Tools" in the WPI command line and click on the result
- Select whichever tool you'd like to run
- WPI offers a wide range of tools which can be super useful!
- Simulating designs is key in engineering, as it allows us to visualize and get an idea of how our design works and whether it is valid or not
- More specifically, simulating our Robot code is extremely useful as we can ensure we are getting the results we want before ever even touching a robot!
- This can save a lot of time in the long run...
- I highly encourage you all to simulate different examples, and maybe even write your own based on the given examples
-
Bonus Exercise:
- Try looking into the provided code for examples and reading through to understand what's going on, and what kind of robot was programmed. This goes a long way in enriching your understanding of a program, and is a skill I myself continue to work on all the time (just reading through code and trying to understand)
-
Bonus Exercise:
- And of course, have a great day! :)
-
Team 4910 Simulation Tutorial
- Excellent explanation of features and purposes
- Source code for their project found on their GitHub Page
-
WPI Library "Introduction to Robot Simulation
- This whole website has great tutorials on all WPI aspects -- great resource whenever you're curious about anything