Possible negative origin for Field2D in simulator?

I have the sim running nicely with a ramsete controller in robotpy and I’m starting to try it in java as well. I’d like to have a bit more control over the view into the Field2D in the sim.
One thing that would be a nice convenience is being able to use padded images (I think the default 2021 ones for autonomous use a 0.25m padding on each side of the 15’x30’ field) so that we can practice with actual poses w/o going off the screen.
So being able to set the origin (lower left corner) of the visible Field2D to (-.25,-.25) or some other arbitrary value would make it much easier to use the sim w/o having to crop the background images to exactly 15x30’.
If anyone has a clever work around I’d appreciate it.

This is settable, it’s just not shown in the GUI at present. You can either edit the .ini file (the settings are top, left, bottom, and right) or load PathWeaver json files instead of a raw image.

1 Like

Thanks. I tried editing these [GlassStorage][/SmartDashboard/Field] ini parameters (top, left, bottom, and right) in both the java and the python sims but couldn’t connect any changes to them with a change in the field coordinates. Are they overridden by the height and width parameters? Would you mind giving an example of how to change those parameters to have an effect on the field?

Top/Left/Bottom/Right are the image pixel locations of the field corners. You have to set all 4 (specifically, bottom and right need to be non-negative) for it to have an effect. So eg if you had a 1000x500 image, setting top=5, left=5, bottom=495, right=995 would treat 5 pixels from all 4 sides as “outside the field”.

Width and height are different. These represent the width and height of the field in field units (usually meters). The value your robot code sends for x and y is scaled by width and height to determine the location on the field view. These two settings are changeable via the GUI.

Thank you! That was exactly what I needed. I was trying to enter distances instead of pixels. That yellow box around the legal field is a great feature.

In case others are interested, here is what I used with the 2021 images-
Image is 800 x 420, field is 760x380, so there are 20 pixel borders:

[GlassStorage][/SmartDashboard/Field]
image=.\sim\2021-slalom.png
top=20
left=20
bottom=400
right=780
width=9.114000
height=4.572000

Where did you find these images? Screen ship out of the manual?

You can get all the field images (both PNG and JSON) from the PathWeaver repository.

If you grab both the JSON and PNG files, Field2D knows how to load the JSON file (which pulls in the field boundaries as well as the image).

They are built into pathweaver (as of 2021.2.1). PathWeaver/src/main/resources/edu/wpi/first/pathweaver at main · wpilibsuite/PathWeaver · GitHub

1 Like

Note that also all of the work of editing the .ini file is not needed if you just import the .json file into SimGUI/Glass!

Sorry about my earlier post in case it sends others down the wrong track. I didn’t realize everything was in the JSON, and that they are pre-set for the images from the PathWeaver repository.
Loading the JSON also seems to respect my previously entered field size settings in meters so that makes life a lot easier.

1 Like

Thank You, Joe