You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
15
-
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.
14
+
The Synthesis simulator comes with code simulation already integrated. However, a development environment for the code you are trying to simulate will be required. 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` to connect everything properly.
16
15
17
16
### C++/Java
18
17
@@ -24,25 +23,34 @@ You'll need to enable desktop support for your project in order to run the HALSi
24
23
def includeDesktopSupport =true
25
24
```
26
25
27
-
#### 2. Websocket Server Extension
26
+
#### 2. WebSocket Server Extension
28
27
29
-
In order to communicate with your browser, you'll need to enable the websocket server extension with the following:
28
+
In order to communicate with your browser, you'll need to enable the WebSocket server extension with the following:
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 thirdparty 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:
36
+
For CAN-based device support (TalonFX, CANSparkMax, most Gyros), you'll need our SyntheSim library. Although currently only available for Java, SyntheSim adds additional support for third-party devices that don't follow WPILib's WebSocket specification. It's still in early development, so you'll need to clone and install the library locally in order to use it:
38
37
38
+
39
+
To clone just the SyntheSym portion of the repository (faster than cloning the whole repository), you can use the following commands
Next, you'll need to have the local maven repository is added to your project by making sure the following is included in your `build.gradle` file:
53
+
Next, you'll need to ensure that the local Maven repository is added to your project by verifying that the following is included in your `build.gradle` file:
46
54
47
55
```java
48
56
repositories {
@@ -61,24 +69,25 @@ dependencies {
61
69
}
62
70
```
63
71
64
-
All of these instructions can be found in the [SyntheSim README](https://github.com/Autodesk/synthesis/blob/prod/simulation/SyntheSimJava/README.md).
72
+
> [!NOTE]
73
+
> All of these instructions can be found in the [SyntheSim README](https://github.com/Autodesk/synthesis/blob/prod/simulation/SyntheSimJava/README.md).
65
74
66
75
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.
67
76
68
77
#### 4. HALSim GUI
69
78
70
-
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.
79
+
Verify that the following is included in your `build.gradle`—it should be added by default.
71
80
72
81
```java
73
82
wpi.sim.addGui().defaultEnabled =true
74
83
```
75
84
76
-
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
77
-
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.
85
+
This will allow you to change the state of the robot, as well as connect any joysticks you'd like to use during TeleOp. You must use this GUI in order
86
+
to bring your robot out of disconnected mode, or else it won't be possible to change the state of your robot from within the app.
78
87
79
88
#### 5. Start your code
80
89
81
-
To start your robot code, you can use the following simulate commands with gradle:
90
+
To start your robot code, you can use the following simulate commands with Gradle:
82
91
83
92
```bash
84
93
$ ./gradlew simulateJava
@@ -121,51 +130,183 @@ To start your code, you can run the following:
121
130
python -m robotpy sim --ws-server
122
131
```
123
132
124
-
## Setup (Synthesis Web-app Side)
133
+
## Working with Hardware Components
134
+
135
+
Once your simulation is running, you can control various robot components just like you would on a physical robot.
136
+
137
+
### Motors
138
+
139
+
#### PWM Motors
140
+
141
+
Standard servo and speed controller motors work right out of the box with WPILib's built-in simulation support.
142
+
143
+
```java
144
+
privateSpark m_leftMotor =newSpark(0);
145
+
privateSpark m_rightMotor =newSpark(1);
146
+
147
+
publicvoid teleopPeriodic() {
148
+
double forward =-m_Controller.getLeftY();
149
+
double turn = m_Controller.getRightX();
150
+
151
+
m_leftMotor.set(forward + turn);
152
+
m_rightMotor.set(forward - turn);
153
+
}
154
+
```
155
+
156
+
#### CAN Motors
157
+
For advanced motors like TalonFX or CANSparkMax, you'll need to have SyntheSim installed.
if (Math.abs(xAccel) >0.5||Math.abs(yAccel) >0.5) {
221
+
System.out.println("Warning: Robot is tilting!");
222
+
}
223
+
}
224
+
```
225
+
226
+
### Cameras and Vision
227
+
228
+
**Camera simulation** in Synthesis uses a WebSocket bridge to stream real-time 3D rendered frames from the simulator to your robot code. The example code allows camera stream in Shuffleboard:
// Register camera with frame handler to receive frames from simulation
255
+
CameraFrameHandler.getInstance().registerCamera("USB Camera 0", m_videoSource);
256
+
}
257
+
258
+
@Override
259
+
publicvoid simulationPeriodic() {
260
+
boolean cameraConnected = m_Camera.isConnected();
261
+
double cameraWidth = m_Camera.getWidth();
262
+
double cameraHeight = m_Camera.getHeight();
263
+
double cameraFPS = m_Camera.getFPS();
264
+
265
+
// Use camera data here
266
+
}
267
+
```
268
+
269
+
## Setup (Simulator)
125
270
126
271
Once started, make sure in the SimGUI that your robot state is set to "Disabled", **not** "Disconnected".
127
272
128
273
### Spawning in a Robot
129
274
130
-
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
131
-
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.
275
+
Head over to [Fission](https://synthesis.autodesk.com/fission/) and load your robot model into the simulation. Once it appears, place it on the field and open the configuration panel, either through the left sidebar menu or by right-clicking your robot and selecting "Configure."
132
276
133
-
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"
134
-
to "WPILib". At the moment, only one robot can be controlled by the simulation at a time.
277
+
In order to configure your robot to use code simulation, you need to switch the robot's "brain" from "Synthesis" to "WPILib", which tells the simulator to receive inputs from the simulated code rather than from keyboard or controller inputs.
135
278
136
-
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
137
-
quickly.
279
+
The indicator in the top-right corner of the screen will display the status of the connection between Synthesis and the simulator.
138
280
139
281
### Simulation Configuration
140
282
141
-
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.
283
+
Once you've switched to the WPILib brain, a new "Simulation" section will appear in your robot's config panel.
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"
148
-
brain and then back again to the "WPILib" brain. This setting will be saved.
289
+
This setting configures Synthesis to automatically attempt to reconnect when connection is lost, and will stay configured the next time you open Synthesis.
149
290
150
291
#### Wiring Panel
151
292
152
-
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
153
-
labels) are colored to indicate the type of data they represent. Hover over the information icons for more information.
293
+
The wiring panel shows all available inputs and outputs from both your running code and the simulated robot hardware. Each connection point (the small labeled circles) is color-coded by data type: analog signals, digital I/O, PWM outputs, etc.
154
294
155
-

295
+

156
296
157
-
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.
297
+
The controls in the bottom-left of the panel can be used to zoom, auto-fit the view, and add junction nodes when you need to split one signal to multiple destinations.
158
298
159
299
#### Auto Testing
160
300
161
-
The Auto Testing panel allows for iterative testing of an autonomous routine. I'd recommend making sure that the auto reconnect option is enabled.
301
+
The Auto Testing panel can be used to easily reset your robot's state for rapid autonomous testing.
Set your maximum test time, choose your alliance station, and input any game-specific data your autonomous routine needs. Position your robot exactly where you want it to start, then press the start button to begin your autonomous routine.
164
306
165
-
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.
166
-
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.
307
+
When the timer elapses or the test is manually stopped, you're provided the option to reset the robot for another test.
167
308
168
309
## Need More Help?
169
310
170
311
If you need help with anything regarding Synthesis or it's related features please reach out through our
171
-
[discord server](https://www.discord.gg/hHcF9AVgZA). It's the best way to get in contact with the community and our current developers.
312
+
[Discord](https://www.discord.gg/hHcF9AVgZA). It's the best way to get in contact with the community and our current developers.
0 commit comments