acmerobotics / ftc-dashboard

React-based web dashboard designed for FTC
https://acmerobotics.github.io/ftc-dashboard
Other
178 stars 137 forks source link

Canvas flexible origin #137

Closed IronReignRobotics closed 1 year ago

IronReignRobotics commented 1 year ago

Is there a way to set the Canvas origin to a custom location and orientation? Right now it's in the center of the sample field with positive Y pointing up.

Our robots have an internal field representation that often changes from one year to the next based on game design symmetries. For PowerPlay we recognized a 2 axis symmetry when we placed the origin at the center-wall location in our alliance substation. From that perspective we can use one quadrant of the field to represent all junctions on the field and use mirroring to create the other quadrants. This also means we could define a single auton path that works for both left and right starting locations on either alliance.

So we draw the robot using Canvas using our origin. But since Canvas doesn't have a way to set an alternate origin, when it renders, the robot visualization appears translated and rotated.

To get past this right now, we'll have to do a rotation and translation for all the points in each drawing operation. It would be much cleaner if we could setOrigin(x,y,angleYpositive) and have the required rotation and translation from the default origin done at render time.