Skip to content

Commit

Permalink
feat[tutorials]: Complete code simulation and configure assets codelabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed Dec 31, 2024
1 parent 629d064 commit 300c208
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 21 deletions.
61 changes: 40 additions & 21 deletions tutorials/CodeSimulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ All of these instructions can be found in the [SyntheSim README](https://github.

SyntheSim is very much a work in progress. If there is a particular device that isn't compatible, feel free to head to our [GitHub](https://github.com/Autodesk/synthesis) to see about contributing.

### 4. HALSim GUI (Optional)
### 4. HALSim GUI

To add controller/joystick support for your robot code, you'll need to use the HALSim GUI extension. Enable by adding the following to `build.gradle`:
This should be added by default, but in case it isn't, add this to your `build.gradle` to enable the SimGUI extension by default.

```java
wpi.sim.addGui().defaultEnabled = true
```

It's very likely that this is already enabled.
This will allow you to change the state of the robot, as well as hook up any joysticks you'd like to use during teleop. You must use this GUI in order
to bring your robot out of disconnected mode, otherwise we won't be able to change the state of your robot from within the app.

## Setup (Synthesis Web-app Side)

**WARNING**: Our web-app's UI for configuring the robot is very much a work in progress and only available in the debug tools.
### 5. Start your code

First, you'll want to start the simulation of your robot code. This can be done with the following command:
To start your robot code, you can use the following simulate commands with gradle:

```bash
$ ./gradlew simulateJava
Expand All @@ -90,33 +89,53 @@ or for C++:
$ ./gradlew simulateNative
```

### Enabling WebSockets
WPILib also has a command from within VSCode you can use the start your robot code:

![image_caption](img/code-sim/wpilib-ext-simulate.png)

## Setup (Synthesis Web-app Side)

Once started, make sure in the SimGUI that your robot state is set to "Disabled", **not** "Disconnected".

### Spawning in a Robot

Open up [Fission](https://synthesis.autodesk.com/fission/) and spawn in a robot. Once spawned in, place it down and open the config panel. This can be
done by using the left-hand menu and navigating to your robot in the config panel, or by right-clicking on your robot and selecting the "Configure" option.

Next, switch the brain currently controlling the robot. In order to give the simulation control over the robot, the brain must be switched from "Synthesis"
to "WPILib". At the moment, only one robot can be controlled by the simulation at a time.

In the top-right, there should be a connection status indicator. If your robot program was running prior to switching to the "WPILib" brain, it should connect
quickly.

![debug tools panel](img/code-sim/debug-tools.png)
### Simulation Configuration

Inside the debug tools panel, configure the robot in the scene to use web socket control by pressing the "WS Test" button.
Under your robot in the config panel, there should be a Simulation option now. Here you can find all the settings for the code simulation.

You can use the "WS Viewer" to view the raw signals we are receiving from your robot code.
![image_caption](img/code-sim/config-panel-simulation.png)

### Configuring your IO Map
#### Auto Reconnect

Next, press the "RoboRIO" button. This will open the RoboRIO Configuration panel, where you'll be able to map the signals from your robot code to Synthesis drivers and stimuli.
You can enabled auto reconnect incase you are having issues with this. In order for it to take affect, you have to enable the setting, then switch back to the "Synthesis"
brain and then back again to the "WPILib" brain. This setting will be saved.

#### Motorcontrollers
#### Wiring Panel

Motorcontrollers can be configured with either PWM or CAN (if using SyntheSim). On the left it will populate with ports currently active from your robot code, and on the right it will populate with drivers that be controlled, along with a name at the top.
This panel can be used to "wire up" your robot. It will show you all the inputs and outputs available from both the simulation and robot. The handles (little circles with
labels) are colored to indicate the type of data they represent. Hover over the information icons for more information.

![can configuration](img/code-sim/can-config.png)
![image_caption](img/code-sim/wiring-panel.png)

#### Encoders
The bottom-left controls can be used to zoom in/out, fit your view to the nodes, and add junction nodes for connection many connections to many connections.

You can select a given input device created by your robot code, and map it to a corresponding stimuli inside of Synthesis (ie. one of your wheels).
#### Auto Testing

![encoder configuration](img/code-sim/encoder-config.png)
The Auto Testing panel allows for iterative testing of an autonomous routine. I'd recommend making sure that the auto reconnect option is enabled.

#### Digital IO, Analog IO, and Gyros
![image_caption](img/code-sim/auto-testing.png)

These are currently being developed. See [this pull-request](https://github.com/Autodesk/synthesis/pull/1103) for status updates regarding their support.
You can specify a max time, alliance station, and game data. Once you've decided on those and have place the robot where you want, you can start your auto routine.
After the specified amount of time, or when the stop button is pressed, the simulation will freeze and you can either reset to where you started, or close the panel.

## Need More Help?

Expand Down
45 changes: 45 additions & 0 deletions tutorials/ConfigureAssets.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,57 @@ feedback link: https://github.com/Autodesk/synthesis/issues

## Main Panel

Use the configure assets panel to modify assemblies in the scene. You can open it either via the left-hand menu,
or by right clicking on an assembly and selecting "Configure".

## Robots

### Brain

The brain determines what controls the robot. There are currently two options, "Synthesis" and "WPILib".

### Move

Add a gizmo tool to your field to orientate it.

### Intake

Setup the intake zone for your robot.

### Ejector

Setup the ejector position and direction for your robot.

### Configure Joints

Edit the joints on your robot and adjust the speed and force behind them.

### Sequence Joints

Configure joints to work together. Helpful for multi-stage elevators.

### Controls (Synthesis Brain)

Change the controls of the input scheme currently in use, as well as switch which scheme is actively in use.

### Simulation (WPILib Brain)

Modify the relation between your robot within Synthesis and your code.

## Fields

### Move

Add a gizmo tool to your field to orientate it.

### Scoring Zones

Add, modify, and delete scoring zones.

## Input

This works the same as the controls section for the robot. You can modify the controls for the schemes, as well as add and delete them.

## Need More Help?

If you need help with anything regarding Synthesis or it's related features please reach out through our
Expand Down
Binary file added tutorials/img/code-sim/auto-testing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/img/code-sim/wiring-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/img/code-sim/wpilib-ext-simulate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 300c208

Please sign in to comment.