Skip to content

Commit eceefe1

Browse files
authored
Add RobotPy instructions (#1116)
1 parent 7a7c2a1 commit eceefe1

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

tutorials/CodeSimulation.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ feedback link: https://github.com/Autodesk/synthesis/issues
1414
The Synthesis simulator comes with code simulation already integrated. However, a development environment for what ever code your are trying to simulate will be required.
1515
Synthesis' code simulation relies on the WPILib HALSim extensions, specifically the websocket-client extension. You'll need to make the following changes to your `build.gradle` in order to properly simulate your code in Synthesis.
1616

17-
### 1. Desktop Support
17+
### C++/Java
18+
19+
#### 1. Desktop Support
1820

1921
You'll need to enable desktop support for your project in order to run the HALSim:
2022

2123
```java
2224
def includeDesktopSupport = true
2325
```
2426

25-
### 2. Websocket Server Extension
27+
#### 2. Websocket Server Extension
2628

2729
In order to communicate with your browser, you'll need to enable the websocket server extension with the following:
2830

2931
```java
3032
wpi.sim.addWebsocketsServer().defaultEnabled = true
3133
```
3234

33-
### 3. SyntheSim (Optional)
35+
#### 3. SyntheSim (Optional)
3436

3537
For CAN-based device support (TalonFX, CANSparkMax, most Gyros), you'll need our own library--SyntheSim. Currently only available for Java, SyntheSim adds additional support for third party devices that don't follow WPILib's web socket specification. It's still in early development, so you'll need to clone and install the library locally in order to use it:
3638

@@ -63,7 +65,7 @@ All of these instructions can be found in the [SyntheSim README](https://github.
6365

6466
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.
6567

66-
### 4. HALSim GUI
68+
#### 4. HALSim GUI
6769

6870
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.
6971

@@ -74,7 +76,7 @@ wpi.sim.addGui().defaultEnabled = true
7476
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
7577
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.
7678

77-
### 5. Start your code
79+
#### 5. Start your code
7880

7981
To start your robot code, you can use the following simulate commands with gradle:
8082

@@ -92,6 +94,33 @@ WPILib also has a command from within VSCode you can use the start your robot co
9294

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

97+
### Python
98+
99+
#### 1. Install dependencies
100+
101+
Add the 'sim' component to `robotpy_extras` in your `pyproject.toml`:
102+
103+
```toml
104+
[tool.robotpy]
105+
106+
robotpy_version = ...
107+
108+
robotpy_extras = [
109+
# other components here
110+
"sim",
111+
]
112+
```
113+
114+
Run `python -m robotpy sync` to install the needed packages.
115+
116+
#### 2. Start your code
117+
118+
To start your code, you can run the following:
119+
120+
```
121+
python -m robotpy sim --ws-server
122+
```
123+
95124
## Setup (Synthesis Web-app Side)
96125

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

0 commit comments

Comments
 (0)