Robot Renderer
This is a minimal Java (Maven) project that renders a simple robot diagram to a PNG using parameters.
Build
PowerShell:
mvn -v; mvn -DskipTests package
Run
PowerShell example:
java -jar target\robot-renderer-0.1.0-SNAPSHOT-jar-with-dependencies.jar examples\simple.json output\robot.png
Run tests
mvn test
Notes
- The
Appreads a JSON spec (seeexamples/simple.json) and writesoutput/robot.pngby default. - Uses AWT to draw; it works headless on most CI if
java.awt.headless=trueis set.
- Make code changes
- Open the project in your IDE (IntelliJ IDEA, VS Code with Java extensions, or Eclipse).
- Edit source files under
src/main/java/com/example/robotrenderer/. - The main classes:
App— CLI entrypoint that reads a JSON spec and writes a PNG.GuiApp— Swing UI for editing specs, preview, and saving PNGs.Renderer— drawing logic; accepts aRobotSpecand returns aBufferedImage.RobotSpec— parameter model (width, length, drivetrain, hasArm, armLength, mechanism, color, bumperWidth).
- Build locally (no system Maven required)
We included a lightweight wrapper mvnw.ps1 and mvnw.cmd that downloads Maven into .maven/.
Run (PowerShell):
cd 'C:\Users\vivaa\OneDrive\Documents\FRCShenanigans\DiagramRenderer'
powershell -ExecutionPolicy Bypass -File .\mvnw.ps1 -DskipTests packageOr if you have Maven on PATH, just:
mvn -DskipTests packageRun tests (wrapper):
powershell -ExecutionPolicy Bypass -File .\mvnw.ps1 test- Run the CLI app
# after packaging
java -jar target\robot-renderer-0.1.0-SNAPSHOT-jar-with-dependencies.jar examples\simple.json output\robot.png- Launch the Swing GUI (development / desktop)
- From your IDE: run
com.example.robotrenderer.GuiAppmain class. - Or from the packaged jar (jar-with-dependencies):
java -cp target\robot-renderer-0.1.0-SNAPSHOT-jar-with-dependencies.jar com.example.robotrenderer.GuiAppGUI quick walkthrough:
- Edit the
Width/Length(in inches), choose drivetrain (tank, mecanum, swerve). - Toggle "Has Arm" and set
Arm length. - Choose mechanism (intake, shooter, none), set
Coloras hex (e.g.#0077CC), andBumper widthin inches. - Click
Previewto see an in-window preview. - Click
Render & Save PNGto writeoutput/gui_render.png. - Use
Load JSON/Save JSONto persist and loadRobotSpecJSON files.
- What the application does
- Given a JSON
RobotSpec, theRendererdraws a top-down schematic of a robot: robot base, drivetrain wheels or modules, a simple arm, mechanism indicator (intake/shooter), bumpers, and a label. - The GUI lets you interactively edit parameters and produce a PNG render.
- Tips for extending the renderer
- Add more fields to
RobotSpecfor sensors, battery, or team-specific components. - Update
Renderer.render()to position additional components using the same inches-to-pixels scaling. - Add unit tests under
src/test/javathat constructRobotSpecinstances and assert the renderer returns non-null images or writes expected files.
If you want, I can:
- Add the official Maven Wrapper files (
mvnw,.mvn/wrapper/*) instead of the lightweight downloader. - Add an option to the CLI jar to launch the GUI with
--gui. - Add SVG output or more advanced layout presets.