@freik/pedroviz 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # A PedroPath visualizer
2
2
 
3
+ ![GIF of visualizer](./docs/screencap.gif)
4
+
5
+ ## How to use this thing:
6
+
7
+ 0. Have a default web browser installed
8
+ 1. Install the [Bun](https://bun.com) Javascript runtime.
9
+ 2. Either:
10
+ 1. Navigate to the root of your robot source code directory from a command
11
+ line
12
+ - Windows: use Windows Terminal or the Command Host, and PowerShell or
13
+ Command Prompt.
14
+ - MacOS: use Terminal or iTerm (or WezTerm, or whatever terminal emulator
15
+ and shell you want).
16
+ - Linux: Use your favorite terminal emulator and shell. If you're using
17
+ Linux, you don't need my help.
18
+ - use `cd <folder location>` to get to where you put your source code.
19
+ 2. Type `bunx @freik/pedroviz`.
20
+ 3. Or:
21
+ 1. Open up a command line
22
+ 2. type `bunx @freik/pedroviz <location of your source repository>`
23
+ 4. Advanced folks (who might use Bun for other things as well):
24
+ 1. Add it to your `package.json` dependency list: `bun add @freik/pedroviz`
25
+ 2. Make a script to call `pedroviz`. If the `package.json` file isn't in your
26
+ source repo root, add the location of your source as the second command.
27
+
28
+ The first time you use the app, it will take some time to download & install the
29
+ package. Once it's been installed, you no longer need to be connected to the
30
+ interwebs to use the visualizer. So you can be connected to your _robot_ :D
31
+
32
+ You'll see something like this:
33
+
34
+ ```text
35
+ Parsing code: Please wait...
36
+ Found directory /home/freik/src/ftc/BioBuzz2026
37
+ 🚀 Server running at http://localhost:3000/
38
+ ```
39
+
40
+ And then a browser window should open up. If it comes up with a 404, just
41
+ refresh the window. Depending on how fast your computer is, it can take a few
42
+ seconds. Once the application is visible:
43
+
44
+ 1. Select your robot (if you have multiple TeamCode-like directories), source
45
+ file (if you have multiple files that contain PedroPath Poses, Beziers, and
46
+ PathChains), and the specific Java Class (if you have multiple nested classes
47
+ in a single `.java` source file). If you only have one file with all your
48
+ paths-n-stuff in it, it will be automatically selected for you.
49
+ 2. Expand the Values, Poses, Curves, and PathChains section to see the data.
50
+ 3. Select a PathChain to see a robot follow the path.
51
+
52
+ # Goals / What is this? / Why not just use the [PedroPath Visualizer](https://visualizer.pedropathing.com)?
53
+
3
54
  The **goal** is for this to be a _local_ application that let's you vizualize
4
55
  and edit PedroPath's. The _reasons_ for this as opposed to just using
5
56
  [visualizer.pedropathing.com](https://visualizer.pedropathing.com/) are twofold:
@@ -7,37 +58,48 @@ and edit PedroPath's. The _reasons_ for this as opposed to just using
7
58
  1. When you're connected to the bot (for deployment, debugging, or using a
8
59
  panel) you can't use the Visualizer, so you have to launch it, then switch
9
60
  your wifi. BOOO!
10
- 2. This should integrate into your code. No more copying stuff back and forth!
11
- It will (eventually) create the class for you, and allow you to name points,
12
- instead of just having random numerical names. Honestly, using Panels to
13
- update things live would be _amazing_: Your code and the bot on the field are
14
- kept in sync!
61
+ 2. This integrates into your code. It's currently not capable of _creating_
62
+ paths, but writing the code and seeing it is, IMO, much better than trying to
63
+ keep a source file in sync with the visualizer yourself through horrible
64
+ copy-paste shenanigans.
65
+
66
+ Basically: *_No more copying stuff back and forth!_ Just write your code and see
67
+ what it looks like. _Eventually_, this will create a class for you, and allow
68
+ you to name values, points, curves, and paths. Honestly, using Panels to update
69
+ things live while also keeping the source code "in sync" would also be
70
+ _amazing_, but that's probably not going to happen in the foreseeable future.
15
71
 
16
72
  # Current status
17
73
 
18
74
  Reading, rendering poses, curves, and paths, and animating paths including
19
- _most_ headings works. You can't currently do anything fancier than
20
- `Math.toRadians(...)` in a numeric expression, and I'm certain that folks have
21
- patterns that I don't properly handle, but if you started using the
75
+ _most_ headings works (`offset`s, some `reverse` usages, and
76
+ `GlobalHeadingInterpolator`s don't currently work). You can't do anything
77
+ fancier than `Math.toRadians(...)` in a numeric expression, either. I'm certain
78
+ that folks have code & coding styles/patterns that I don't (yet) properly
79
+ handle, but if you started using the
22
80
  [PP Visualizer](https://visualizer.pedropathing.com) and then added a bunch more
23
81
  straight forward code from there, this thing will probably show you your paths.
24
82
 
25
- That's all well and good, but you can't use it without using it as a git
26
- submodule yet, so I need to publish what I have to NPM so that average humans
27
- can actually use it...
83
+ # Hey, Kevin, this doesn't work!
28
84
 
29
- **Tasks, in order:**
85
+ If your code doesn't show up properly, please send the file my way! I'm happy to
86
+ extend my silly Java interpretation engine to handle your way of doing stuff!
87
+ You can also create an issue. I'll do my best to stay on top of them. I'm
88
+ retired, so this is a priority for me (along with all my other random projects
89
+ around the house, and other coding projects, but I do let FTC Robotics eat a lot
90
+ of my frei time, because I love working with FTC students...)
91
+
92
+ **Task TODO list, in some sort of order:**
30
93
 
31
94
  - [x] Read paths from code
32
- - [x] Display those paths on the canvas.
33
- - [x] Highlight hovered-over paths/curves/points
34
- - [x] Highlight the hovered path/curve/point in the PathChain list
35
- - [x] Animate the robot along the path
36
- - [ ] Specify robot dimensions
37
- - [x] Put the field graphic under the canvas
38
- - [x] Have a grid key near/under the canvas
39
- - [ ] Publish to NPM to enable use without using it as a git submodule
95
+ - [x] Specify robot dimensions (and other settings)
96
+ - [x] Document basic usage
97
+ - [ ] Display Java source parsing issues so users can see if they should fix
98
+ their code, or send their code to me.
99
+ - [ ] Increase test coverage (ongoing)
40
100
  - [ ] Support more complex math expression evaluation
101
+ - [x] Allow detection of `field-dark.jpg` and `field-light.jpg` from the users's
102
+ code for game-specific field backgrounds
41
103
  - [ ] Edit existing:
42
104
  - [ ] Named values
43
105
  - [ ] Named poses
@@ -45,15 +107,19 @@ can actually use it...
45
107
  - [ ] Named PathChains
46
108
  - [ ] Allow editing points by dragging them on the canvas
47
109
  - [ ] Reflect those changes in the code
48
- - [ ] Checksum the code to detect external edits?
110
+ - [ ] Checksum the code to detect external edits
49
111
  - [ ] When external edits have occurred, try to resolve the conflicts?
50
112
  (ugh...)
113
+ - [ ] Maintain comments
114
+ - [ ] Maintain any code that I don't actually parse from the source code (keep
115
+ chunks of code that aren't represented in the UI)
51
116
  - [ ] Allow creation:
52
117
  - [ ] Named values
53
118
  - [ ] Named poses
54
119
  - [ ] Named curves
55
120
  - [ ] Named PathChains
56
121
  - [ ] Enable "warning" lines: warn if the robot crosses a line on a path
122
+ - [ ] Make work with nodejs (`npx`) as well?
57
123
  - [x] Specify different alliance paths (this is doable through multiple
58
124
  classes...)
59
125
  - [ ] Bonus: Reflect a path along a line or axis
@@ -63,11 +129,12 @@ can actually use it...
63
129
  - [ ] max velocity (or, you know, any velocity/acceleration model)
64
130
  - [ ] braking strength
65
131
  - [ ] tValues
66
- - [ ] Maintain any code that I don't actually parse from the source code (keep
67
- chunks of code that aren't represented in the UI)
68
- - [ ] Maintain comments
132
+ - [ ] Eventually, migrate to use a text file, instead of java source code for
133
+ static paths?
134
+ - [ ] Maybe as part of the SystemCore migration? I've got this done, so adding
135
+ stuff over there seems reasonable...
69
136
 
70
- # Docs-n-stuff
137
+ # Development
71
138
 
72
139
  To install dependencies:
73
140
 
@@ -77,18 +144,17 @@ bun install
77
144
 
78
145
  To start a development server:
79
146
 
80
- ```bash
81
- bun pvdev
147
+ ```sh
148
+ bun dev {FTC Source Location}
82
149
  ```
83
150
 
84
- To run for production:
151
+ To bundle for production (only for Kevin, sorry):
85
152
 
86
153
  ```bash
87
- bun pvstart
154
+ bun bundle
155
+ bun publish --access=public
88
156
  ```
89
157
 
90
- ## Development
91
-
92
158
  I'm using [React](https://react.dev/),
93
159
  [Typescript](https://www.typescriptlang.org/), with [Jotai](https://jotai.org/)
94
160
  for state management and
@@ -98,12 +164,10 @@ weirdness. Feel free to reach out to me if you're trying to understand the code,
98
164
  add a feature, or fix a bug.
99
165
 
100
166
  On the backend, everything is just written in Typescript. It made deployment
101
- much easier. It's built and served from a `Bun.serve` invocation. I'll probably
102
- want to figure out how to package it up in a single bundle in the future, but
103
- for now, that's good enough.
167
+ much easier. It's built and served from a `Bun.serve` invocation. There's some
168
+ weirdness scattered in a few places that are necessary to package it up into a
169
+ single bundle, so make sure that's tested.
104
170
 
105
- The back end code is all served through `index.tsx` which serves up the .ts/.tsx
106
- files from the `pedroviz` subdirectory, and runs the stuff in the `server`
171
+ The back end code is all served through `main.tsx` which serves up the .ts/.tsx
172
+ files from the `client` subdirectory, and runs the stuff in the `server`
107
173
  subdirectory on the backend.
108
-
109
- TODO: Write moar dox
@@ -0,0 +1 @@
1
+ :root{--buncss-light:initial;--buncss-dark: ;color-scheme:light dark;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,Avenir,Helvetica,Arial,sans-serif}@media (prefers-color-scheme:dark){:root{--buncss-light: ;--buncss-dark:initial}}html,body{overflow:hidden;height:100%;margin:0}.app{display:grid;grid-template-columns:1fr auto;grid-template-rows:auto 1fr;height:100vh}.header-left{grid-row:1;grid-column:1;justify-content:flex-start;justify-self:start}.header-right{grid-row:1;grid-column:2;justify-content:flex-end;justify-self:end}.main{grid-row:2;grid-column:1/3}.sidebar{overflow-y:auto}.display{display:flex;overflow:hidden;flex-direction:column;width:100%;height:100%}#view-separator{opacity:.5;background:linear-gradient(90deg,#fff 0%,#000 45% 55%,#fff 100%);width:3px;transition:opacity .2s}#view-separator:hover{opacity:.9}.pathLabel{margin-left:10px;margin-right:5px}.two-column{display:grid;grid-template-columns:auto auto;place-items: center start;row-gap:3px}.col3div{display:grid;grid-template-columns:auto 1fr 4fr 1fr 4fr}.col1{grid-column:1}.col2{grid-column:3}.col3{grid-column:5}.vcentered{display:flex;justify-content:center;align-items: center}.settings{display:grid;grid-template-columns:1.5fr 1fr .4fr 1.5fr 1fr;align-items: center;gap:5px 1px;margin:10px}.left-label{grid-column:1}.left-field{grid-column:2}.right-label{grid-column:4}.right-field{grid-column:5}