@freik/pedroviz 0.1.2 → 0.2.0
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 +144 -48
- package/dist/entry.js +172 -0
- package/dist/frontend.js +156 -0
- package/dist/frontend.js.map +7 -0
- package/dist/index.html +4 -3
- package/dist/logo.png +0 -0
- package/dist/{index-0k6xv586.css → styles.css} +35 -41
- package/package.json +28 -24
- package/dist/field-dark-kfzgjbw0.jpg +0 -0
- package/dist/field-light-p0m7q5e8.jpg +0 -0
- package/dist/index-9vzrarn0.js +0 -50869
- package/dist/index-9vzrarn0.js.map +0 -590
- package/dist/logo-pefhw544.png +0 -0
- package/dist/main.js +0 -19471
- package/dist/main.js.map +0 -494
package/README.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# A PedroPath visualizer
|
|
2
2
|
|
|
3
|
+

|
|
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 inside Android Studio
|
|
22
|
+
2. type `bunx @freik/pedroviz` (because Android Studio puts you in the right
|
|
23
|
+
directory automagically)
|
|
24
|
+
4. Advanced folks (who might use Bun for other things as well):
|
|
25
|
+
1. Add it to your `package.json` dependency list: `bun add @freik/pedroviz`
|
|
26
|
+
2. Make a script to call `pedroviz`. If the `package.json` file isn't in your
|
|
27
|
+
source repo root, add the location of your source as the second command.
|
|
28
|
+
Something like this: `"pedro": "bun run pedroviz"` and then you can call
|
|
29
|
+
it by typeing `bun pedro` if you'd prefer!
|
|
30
|
+
|
|
31
|
+
The first time you use the app, it will take some time to download & install the
|
|
32
|
+
package. Once it's been installed, you no longer need to be connected to the
|
|
33
|
+
interwebs to use the visualizer. So you can be connected to your _robot_ :D
|
|
34
|
+
|
|
35
|
+
You'll see something like this:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Parsing code: Please wait...
|
|
39
|
+
Found directory /home/freik/src/ftc/BioBuzz2026
|
|
40
|
+
🚀 Server running at http://localhost:3000/
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
And then a browser window should open up. If it comes up with a 404, just
|
|
44
|
+
refresh the window. Depending on how fast your computer is, it can take a few
|
|
45
|
+
seconds. Once the application is visible:
|
|
46
|
+
|
|
47
|
+
1. Select your robot (if you have multiple TeamCode-like directories), source
|
|
48
|
+
file (if you have multiple files that contain PedroPath Poses, Beziers, and
|
|
49
|
+
PathChains), and the specific Java Class (if you have multiple nested classes
|
|
50
|
+
in a single `.java` source file). If you only have one file with all your
|
|
51
|
+
paths-n-stuff in it, it will be automatically selected for you.
|
|
52
|
+
2. Expand the Values, Poses, Curves, and PathChains section to see the data.
|
|
53
|
+
3. Select a PathChain to see a robot follow the path.
|
|
54
|
+
|
|
55
|
+
# Goals / What is this? / Why not just use the [PedroPath Visualizer](https://visualizer.pedropathing.com)?
|
|
56
|
+
|
|
3
57
|
The **goal** is for this to be a _local_ application that let's you vizualize
|
|
4
58
|
and edit PedroPath's. The _reasons_ for this as opposed to just using
|
|
5
59
|
[visualizer.pedropathing.com](https://visualizer.pedropathing.com/) are twofold:
|
|
@@ -7,37 +61,48 @@ and edit PedroPath's. The _reasons_ for this as opposed to just using
|
|
|
7
61
|
1. When you're connected to the bot (for deployment, debugging, or using a
|
|
8
62
|
panel) you can't use the Visualizer, so you have to launch it, then switch
|
|
9
63
|
your wifi. BOOO!
|
|
10
|
-
2. This
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
64
|
+
2. This integrates into your code. It's currently not capable of _creating_
|
|
65
|
+
paths, but writing the code and seeing it is, IMO, much better than trying to
|
|
66
|
+
keep a source file in sync with the visualizer yourself through horrible
|
|
67
|
+
copy-paste shenanigans.
|
|
68
|
+
|
|
69
|
+
Basically: *_No more copying stuff back and forth!_ Just write your code and see
|
|
70
|
+
what it looks like. _Eventually_, this will create a class for you, and allow
|
|
71
|
+
you to name values, points, curves, and paths. Honestly, using Panels to update
|
|
72
|
+
things live while also keeping the source code "in sync" would also be
|
|
73
|
+
_amazing_, but that's probably not going to happen in the foreseeable future.
|
|
15
74
|
|
|
16
75
|
# Current status
|
|
17
76
|
|
|
18
77
|
Reading, rendering poses, curves, and paths, and animating paths including
|
|
19
|
-
_most_ headings works
|
|
20
|
-
`
|
|
21
|
-
|
|
78
|
+
_most_ headings works (`offset`s, some `reverse` usages, and
|
|
79
|
+
`GlobalHeadingInterpolator`s don't currently work). You can't do anything
|
|
80
|
+
fancier than `Math.toRadians(...)` in a numeric expression, either. I'm certain
|
|
81
|
+
that folks have code & coding styles/patterns that I don't (yet) properly
|
|
82
|
+
handle, but if you started using the
|
|
22
83
|
[PP Visualizer](https://visualizer.pedropathing.com) and then added a bunch more
|
|
23
84
|
straight forward code from there, this thing will probably show you your paths.
|
|
24
85
|
|
|
25
|
-
|
|
26
|
-
submodule yet, so I need to publish what I have to NPM so that average humans
|
|
27
|
-
can actually use it...
|
|
86
|
+
# Hey, Kevin, this doesn't work!
|
|
28
87
|
|
|
29
|
-
|
|
88
|
+
If your code doesn't show up properly, please send the file my way! I'm happy to
|
|
89
|
+
extend my silly Java interpretation engine to handle your way of doing stuff!
|
|
90
|
+
You can also create an issue. I'll do my best to stay on top of them. I'm
|
|
91
|
+
retired, so this is a priority for me (along with all my other random projects
|
|
92
|
+
around the house, and other coding projects, but I do let FTC Robotics eat a lot
|
|
93
|
+
of my frei time, because I love working with FTC students...)
|
|
94
|
+
|
|
95
|
+
**Task TODO list, in some sort of order:**
|
|
30
96
|
|
|
31
97
|
- [x] Read paths from code
|
|
32
|
-
- [x]
|
|
33
|
-
- [x]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
98
|
+
- [x] Specify robot dimensions (and other settings)
|
|
99
|
+
- [x] Document basic usage
|
|
100
|
+
- [ ] Display Java source parsing issues so users can see if they should fix
|
|
101
|
+
their code, or send their code to me.
|
|
102
|
+
- [ ] Increase test coverage (ongoing)
|
|
40
103
|
- [ ] Support more complex math expression evaluation
|
|
104
|
+
- [x] Allow detection of `field-dark.jpg` and `field-light.jpg` from the users's
|
|
105
|
+
code for game-specific field backgrounds
|
|
41
106
|
- [ ] Edit existing:
|
|
42
107
|
- [ ] Named values
|
|
43
108
|
- [ ] Named poses
|
|
@@ -45,15 +110,19 @@ can actually use it...
|
|
|
45
110
|
- [ ] Named PathChains
|
|
46
111
|
- [ ] Allow editing points by dragging them on the canvas
|
|
47
112
|
- [ ] Reflect those changes in the code
|
|
48
|
-
- [ ] Checksum the code to detect external edits
|
|
113
|
+
- [ ] Checksum the code to detect external edits
|
|
49
114
|
- [ ] When external edits have occurred, try to resolve the conflicts?
|
|
50
115
|
(ugh...)
|
|
116
|
+
- [ ] Maintain comments
|
|
117
|
+
- [ ] Maintain any code that I don't actually parse from the source code (keep
|
|
118
|
+
chunks of code that aren't represented in the UI)
|
|
51
119
|
- [ ] Allow creation:
|
|
52
120
|
- [ ] Named values
|
|
53
121
|
- [ ] Named poses
|
|
54
122
|
- [ ] Named curves
|
|
55
123
|
- [ ] Named PathChains
|
|
56
124
|
- [ ] Enable "warning" lines: warn if the robot crosses a line on a path
|
|
125
|
+
- [ ] Make work with nodejs (`npx`) as well?
|
|
57
126
|
- [x] Specify different alliance paths (this is doable through multiple
|
|
58
127
|
classes...)
|
|
59
128
|
- [ ] Bonus: Reflect a path along a line or axis
|
|
@@ -63,11 +132,24 @@ can actually use it...
|
|
|
63
132
|
- [ ] max velocity (or, you know, any velocity/acceleration model)
|
|
64
133
|
- [ ] braking strength
|
|
65
134
|
- [ ] tValues
|
|
66
|
-
- [ ]
|
|
67
|
-
|
|
68
|
-
- [ ]
|
|
135
|
+
- [ ] Eventually, migrate to use a text file, instead of java source code for
|
|
136
|
+
static paths?
|
|
137
|
+
- [ ] Maybe as part of the SystemCore migration? I've got this done, so adding
|
|
138
|
+
stuff over there seems reasonable...
|
|
139
|
+
|
|
140
|
+
# Development
|
|
69
141
|
|
|
70
|
-
|
|
142
|
+
This whole thing is built with [Typescript](https://www.typescriptlang.org/).
|
|
143
|
+
I'm using [Hono](https://hono.dev/) as a local web server,
|
|
144
|
+
[React](https://react.dev/) with [Jotai](https://jotai.org/) for state
|
|
145
|
+
management and [FluentUI](https://developer.microsoft.com/en-us/fluentui#/) as
|
|
146
|
+
the UI/control toolbox. None of these framworks are too complicated to get
|
|
147
|
+
started with, but each have their own sets of weirdness. Feel free to reach out
|
|
148
|
+
to me if you're trying to understand the code, add a feature, or fix a bug.
|
|
149
|
+
|
|
150
|
+
The back end code is all served through `src/entry.ts` which serves up the
|
|
151
|
+
.ts/.tsx files from the `src/client` subdirectory, and runs the stuff in the
|
|
152
|
+
`src/server` subdirectory on the backend.
|
|
71
153
|
|
|
72
154
|
To install dependencies:
|
|
73
155
|
|
|
@@ -78,32 +160,46 @@ bun install
|
|
|
78
160
|
To start a development server:
|
|
79
161
|
|
|
80
162
|
```bash
|
|
81
|
-
bun
|
|
163
|
+
bun dev {FTC Source Location}
|
|
82
164
|
```
|
|
83
165
|
|
|
84
|
-
To
|
|
166
|
+
To bundle for production (only for Kevin, sorry):
|
|
85
167
|
|
|
86
168
|
```bash
|
|
87
|
-
bun
|
|
169
|
+
bun bundle
|
|
170
|
+
bun npm login
|
|
171
|
+
bun publish --access=public
|
|
88
172
|
```
|
|
89
173
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
I
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
174
|
+
### Buy, why????
|
|
175
|
+
|
|
176
|
+
Why did I build it this way, instead of using Java? Because I didn't want to
|
|
177
|
+
learn a new UI toolkit. I've been using React for a very, very long time. It's
|
|
178
|
+
cross-platform, and functional (in the mathematical/programming sense of the
|
|
179
|
+
word). Typescript is just flat out better than Javascript (fight me...), and I
|
|
180
|
+
switched to using [Recoil](https://github.com/facebookexperimental/Recoil) when
|
|
181
|
+
one of the engineers I supported while working at Facebook built in back in 2020
|
|
182
|
+
because I really hated all the boilerplate in Redux. Recoil is dead, but Jotai
|
|
183
|
+
was a public reimplementation that's still actively supported.
|
|
184
|
+
|
|
185
|
+
While a Microsoft employee, I had learned WinForms and WPF way way way back in
|
|
186
|
+
the day, but the various MVC/MVVM data-binding shenanigans just slowly sapped my
|
|
187
|
+
will to build UI's. Writing UI as functional, composable components makes my
|
|
188
|
+
brain so much happier than MVC or MVVM or any sort of forced "this is the UI,
|
|
189
|
+
and that's the dota model" kind a crap.
|
|
190
|
+
|
|
191
|
+
I also have no interest in learning a different UI framework, particularly
|
|
192
|
+
something that's not going to be available everywhere I care about (Java on an
|
|
193
|
+
iPhone is not really a thing). So, it's TypeScript, and React. (I actually built
|
|
194
|
+
[a little C++ app framework](https://github.com/kevinfrei/cuark) that lets me
|
|
195
|
+
write much bigger, more complex things that use React + Typescript for the UI
|
|
196
|
+
across Linux, macOS, and Windows, and it's _not_ React Native).
|
|
197
|
+
|
|
198
|
+
Just know that I'm a grumpy old programmer who retired before Claude Code stole
|
|
199
|
+
the joy of coding if you're willing to pay $500/month to light the planet on
|
|
200
|
+
fire. I love to write code. I _can_ code review (that's my primary role as a
|
|
201
|
+
mentor on FTC) but honestly, asking some miserable AI to create code when I'd
|
|
202
|
+
prefer to do it myself, and then have to code review that miserable AI's code
|
|
203
|
+
is...well, miserable. There's no joy to be had in helping the techno-fascists
|
|
204
|
+
pillage and destroy the planet, while **also** killing jobs that humans are
|
|
205
|
+
pretty good at, and that I actually happen to really enjoy.
|