Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Simulation Support Pt.2 #1103

Merged
merged 14 commits into from
Oct 11, 2024
Merged

More Simulation Support Pt.2 #1103

merged 14 commits into from
Oct 11, 2024

Conversation

PepperLola
Copy link
Member

@PepperLola PepperLola commented Aug 21, 2024

Description

Added support for more of the simulation devices supported by WPILib. Also fixed issue with resetting the brain of the robot every time a PWM Output Group was created so it's now possible to have more than one output group.

The aim of this PR is to add support for the most important items in the Hardware Messages section of the WPILib Hardware WS API docs. This does not include CAN motor support, which is being handled in #1050. All planned devices are listed in Objectives and are what I deem to be most important and worthwhile right now, but these could be subject to change and the list is open to suggestions.

Note

It's worth noting that controls are managed entirely by the HALSim GUI. The available USB devices are assigned to ports through the GUI, which are then read and fed to the robot code. The robot code sets motor outputs depending on the controller input, and the motor values are what's actually sent to fission.

Objectives

  • Encoder support
  • Joystick support through Sim GUI
  • Gyroscope and Accelerometer support
  • Digital and analog sensor support

Testing Done

  • Test driving robot with two different PWM motors
    • Ensure encoders update appropriately

Important

In order for a controller to be appropriately mapped in the Sim GUI, you must enable the checkbox called "Map gamepad" in the Joystick menu. However, this does not appear when running the application on MacOS.

When unchecked, the joystick axes may not be accurate (e.g. the right joystick and L/R trigger axes may be swapped).

When testing, you can uncomment the commented out devices in WPILibBrain.ts. Make sure the inputs are updating appropriately in the simulator. You can see how the inputs are meant to update in in those lines you uncomment, and how the outputs are meant to update in the sample robot code.

// this.addSimInput(new SimGyroInput("Test Gyro[1]", mechanism))
// this.addSimInput(new SimAccelInput("ADXL362[4]", mechanism))
// this.addSimInput(new SimDigitalInput("SYN DI[0]", () => Math.random() > 0.5))
// this.addSimOutput(new SimDigitalOutput("SYN DO[1]"))
// this.addSimInput(new SimAnalogInput("SYN AI[0]", () => Math.random() * 12))
// this.addSimOutput(new SimAnalogOutput("SYN AO[1]"))

JIRA Issue

@PepperLola PepperLola self-assigned this Aug 21, 2024
@PepperLola PepperLola added the codesim Code simulation related task. label Aug 21, 2024
@PepperLola PepperLola marked this pull request as ready for review August 29, 2024 01:27
@PepperLola PepperLola requested review from HunterBarclay and a team as code owners August 29, 2024 01:27
@PepperLola PepperLola requested review from a-crowell, Dhruv-0-Arora, BrandonPacewic and LucaHaverty and removed request for a team August 29, 2024 01:27
@HunterBarclay HunterBarclay mentioned this pull request Sep 5, 2024
Verified that everything seems to be working. However, haven't been able
to test Gyros yet.
@autodesk-chorus
Copy link

Chorus detected one or more security issues with this pull request. See the Checks tab for more details.

As a reminder, please follow the secure code review process as part of the Secure Coding Non-Negotiable requirement.

Copy link
Member

@HunterBarclay HunterBarclay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress on Simulation. I'll be opening another branch to start working on the UI.

@HunterBarclay HunterBarclay merged commit e149858 into dev Oct 11, 2024
14 checks passed
@HunterBarclay HunterBarclay deleted the jwrigh/1766/sim-io branch October 11, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codesim Code simulation related task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants