@freik/pedroviz 0.1.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 ADDED
@@ -0,0 +1,109 @@
1
+ # A PedroPath visualizer
2
+
3
+ The **goal** is for this to be a _local_ application that let's you vizualize
4
+ and edit PedroPath's. The _reasons_ for this as opposed to just using
5
+ [visualizer.pedropathing.com](https://visualizer.pedropathing.com/) are twofold:
6
+
7
+ 1. When you're connected to the bot (for deployment, debugging, or using a
8
+ panel) you can't use the Visualizer, so you have to launch it, then switch
9
+ 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!
15
+
16
+ # Current status
17
+
18
+ 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
22
+ [PP Visualizer](https://visualizer.pedropathing.com) and then added a bunch more
23
+ straight forward code from there, this thing will probably show you your paths.
24
+
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...
28
+
29
+ **Tasks, in order:**
30
+
31
+ - [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
40
+ - [ ] Support more complex math expression evaluation
41
+ - [ ] Edit existing:
42
+ - [ ] Named values
43
+ - [ ] Named poses
44
+ - [ ] Named curves
45
+ - [ ] Named PathChains
46
+ - [ ] Allow editing points by dragging them on the canvas
47
+ - [ ] Reflect those changes in the code
48
+ - [ ] Checksum the code to detect external edits?
49
+ - [ ] When external edits have occurred, try to resolve the conflicts?
50
+ (ugh...)
51
+ - [ ] Allow creation:
52
+ - [ ] Named values
53
+ - [ ] Named poses
54
+ - [ ] Named curves
55
+ - [ ] Named PathChains
56
+ - [ ] Enable "warning" lines: warn if the robot crosses a line on a path
57
+ - [x] Specify different alliance paths (this is doable through multiple
58
+ classes...)
59
+ - [ ] Bonus: Reflect a path along a line or axis
60
+ - [ ] Support additional parts of the path builder
61
+ - [x] multiple paths
62
+ - [x] path headings (global and last)
63
+ - [ ] max velocity (or, you know, any velocity/acceleration model)
64
+ - [ ] braking strength
65
+ - [ ] 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
69
+
70
+ # Docs-n-stuff
71
+
72
+ To install dependencies:
73
+
74
+ ```bash
75
+ bun install
76
+ ```
77
+
78
+ To start a development server:
79
+
80
+ ```bash
81
+ bun pvdev
82
+ ```
83
+
84
+ To run for production:
85
+
86
+ ```bash
87
+ bun pvstart
88
+ ```
89
+
90
+ ## Development
91
+
92
+ I'm using [React](https://react.dev/),
93
+ [Typescript](https://www.typescriptlang.org/), with [Jotai](https://jotai.org/)
94
+ for state management and
95
+ [FluentUI](https://developer.microsoft.com/en-us/fluentui#/) as the UI/control
96
+ toolbox. None of them are too complicated, but each have their own sets of
97
+ weirdness. Feel free to reach out to me if you're trying to understand the code,
98
+ add a feature, or fix a bug.
99
+
100
+ 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.
104
+
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`
107
+ subdirectory on the backend.
108
+
109
+ TODO: Write moar dox
Binary file
Binary file
@@ -0,0 +1,121 @@
1
+ /* src/client/index.css */
2
+ :root {
3
+ --buncss-light: initial;
4
+ --buncss-dark: ;
5
+ color-scheme: light dark;
6
+ font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Avenir, Helvetica, Arial, sans-serif;
7
+ }
8
+
9
+ @media (prefers-color-scheme: dark) {
10
+ :root {
11
+ --buncss-light: ;
12
+ --buncss-dark: initial;
13
+ }
14
+ }
15
+
16
+ html, body {
17
+ overflow: hidden;
18
+ height: 100%;
19
+ margin: 0;
20
+ }
21
+
22
+ .app {
23
+ display: grid;
24
+ grid-template-columns: 1fr auto;
25
+ grid-template-rows: auto 1fr;
26
+ height: 100vh;
27
+ }
28
+
29
+ .header-left {
30
+ grid-row: 1;
31
+ grid-column: 1;
32
+ justify-content: flex-start;
33
+ justify-self: start;
34
+ }
35
+
36
+ .header-right {
37
+ grid-row: 1;
38
+ grid-column: 2;
39
+ justify-content: flex-end;
40
+ justify-self: end;
41
+ }
42
+
43
+ .main {
44
+ grid-row: 2;
45
+ grid-column: 1 / 3;
46
+ }
47
+
48
+ .sidebar {
49
+ overflow-y: auto;
50
+ }
51
+
52
+ .display {
53
+ display: flex;
54
+ overflow: hidden;
55
+ flex-direction: column;
56
+ width: 100%;
57
+ height: 100%;
58
+ }
59
+
60
+ #view-separator {
61
+ opacity: .5;
62
+ background: linear-gradient(to right, #fff 0%, #000 45% 55%, #fff 100%);
63
+ width: 3px;
64
+ transition: opacity .2s;
65
+ }
66
+
67
+ #view-separator:hover {
68
+ opacity: .9;
69
+ }
70
+
71
+ .pathLabel {
72
+ margin-left: 10px;
73
+ margin-right: 5px;
74
+ }
75
+
76
+ .col3div {
77
+ display: grid;
78
+ grid-template-columns: auto 1fr 4fr 1fr 4fr;
79
+ }
80
+
81
+ .col1 {
82
+ grid-column: 1;
83
+ }
84
+
85
+ .col2 {
86
+ grid-column: 3;
87
+ }
88
+
89
+ .col3 {
90
+ grid-column: 5;
91
+ }
92
+
93
+ .vcentered {
94
+ display: flex;
95
+ justify-content: center;
96
+ align-items: center;
97
+ }
98
+
99
+ .settings {
100
+ display: grid;
101
+ grid-template-columns: 1.5fr 1fr .4fr 1.5fr 1fr;
102
+ align-items: center;
103
+ gap: 5px 1px;
104
+ margin: 10px;
105
+ }
106
+
107
+ .left-label {
108
+ grid-column: 1;
109
+ }
110
+
111
+ .left-field {
112
+ grid-column: 2;
113
+ }
114
+
115
+ .right-label {
116
+ grid-column: 4;
117
+ }
118
+
119
+ .right-field {
120
+ grid-column: 5;
121
+ }