diff --git a/.gitignore b/.gitignore index 692bf6f..483fa11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /out exampleFiles/SPINUPfield.pawdraw +*.vsix \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..2e013f3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Andrew Curtis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 224c3a4..bf8fc89 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,58 @@ -# Cat Customs - Custom Editor API Samples - -![Paw draw editor ](documentation/example.png) - -Demonstrates VS Code's [custom editor API](https://code.visualstudio.com/api/extension-guides/custom-editors) using two custom editors: - -- Cat Scratch — Uses the finalized custom text editor api to provide a custom editor for `.cscratch` files (which are just json files) -- Paw Draw - Uses the binary custom editor api to provide a custom editor for `.pawdraw` files (which are just png files with a different file extension). - -## VS Code API - -### `vscode` module - -- [`window.registerCustomEditorProvider`](https://code.visualstudio.com/api/references/vscode-api#window.registerCustomEditorProvider) -- [`CustomTextEditor`](https://code.visualstudio.com/api/references/vscode-api#CustomTextEditor) -- [`CustomEditor`](https://code.visualstudio.com/api/references/vscode-api#CustomEditor) - -## Running the example - -- Open this example in VS Code 1.46+ -- `npm install` -- `npm run watch` or `npm run compile` -- `F5` to start debugging - -Open the example files from the `exampleFiles` directory. \ No newline at end of file +# Auton Builder for Vex Robotics Competition +A graphical editor for vrc autons. +![Auton Editor Example](documentation/example.png) +## What it does +This extension allows programmers to easily create and modify autons in the form of a .vauton (json) file. This file can then be downloaded onto an Micro SD card and interpreted by the program on the robot. + +> _**Note:**_ This extension does not handle how the auton will be performed, it only provides the information that comprises the auton. +## Use +- Interface + - Robot - Represents state of the robot at the current auton node + - Margin of error (red circle) - indicates the range robot will try to get to before moving onto the next node + - Field - VRC Spin Up Field + - Action Bar - Represents actions that robot will perform at the current auton node + - Intake + - Shoot + - Piston Shoot + - Roller + - Expand + - Node Index - shows index of current node (top right) +- Controls + - Movement + - Left Click & Drag - Move the robot around + - Arrow Keys / WASD - Move the robot around + - Left Click + Alt - Rotate robot towards mouse pointer + - R - Rotate robot 90 degrees (can be modified with shift) + - C - Rotate robot to a heading of 0 + - Margin Of Error + - Left Click & Drag - Modify margin of error + - Node Management + - J - Go to previous node + - L - Go to next node + - N - Create new node after this node + - Delete - remove current note + > _**Note:**_ Keybindings cannot be modified +## Installation +1. Go To the desired release ([0.0.2-pre-alpha](https://github.com/meisZWFLZ/AutonGUI/releases/tag/v0.0.2-pre-alpha)) and download the .vsix file +2. Install using any of the below methods + - Open the folder containing the .vsix file in VS Code. Then right click on the .vsix and select `Install Extension VSIX`. + - In VS Code run the `Extensions: Install from VSIX...` command. + - In a terminal, run the following command + `code --install-extension /path/to/file/vrc-auton-0.0.1.vsix` +## Auton Data Structure +The .vauton file that this extension creates is just a .json file. This json is an array of auton nodes each containing an position value and an array of actions +- Auton Node + - `"position": Position & HasMarginOfError` - Represents the position the robot will go to. + - `"x": number` - x coordinate in inches, 0 to 144. 0 being closest to the blue driver station and 144 being closest to the red driver station. + - `"y": number` - y coordinate in inches, 0 to 144. 0 being closest to the audience and 144 being closest to the referees. + - `"heading": number` - heading in degrees, 0 to 360. 0 being facing towards the audience and 90 facing the red driver station + - `"marginOfError": number` - margin of error in inches, positive float. Acceptable distance from target point for robot to go onto the next node. + - `"actions": ACTION[]` - unique array of enumerators representing the actions to be performed when the robot reaches `position`. + - `ACTION.SHOOT = 0` + - `ACTION.PISTON_SHOOT = 1` + - `ACTION.INTAKE = 2` + - `ACTION.ROLLER = 3` + - `ACTION.EXPAND = 4` +## Known Bugs +- Creating an empty .vauton file doesn't work + - Fix: copy an existing, working .vauton file and rename it \ No newline at end of file diff --git a/documentation/example.png b/documentation/example.png index b14743a..6ecb104 100644 Binary files a/documentation/example.png and b/documentation/example.png differ diff --git a/exampleFiles/AWP.vauto b/exampleFiles/AWP.vauto new file mode 100644 index 0000000..4ce2f2b --- /dev/null +++ b/exampleFiles/AWP.vauto @@ -0,0 +1 @@ +[{"position":{"x":49,"y":101,"heading":53,"marginOfError":4.349546658950447},"actions":[0]},{"position":{"x":72,"y":72,"heading":0,"marginOfError":6}},{"position":{"x":83,"y":101,"heading":0,"marginOfError":20.256234283143364}},{"position":{"x":134,"y":58,"heading":97,"marginOfError":9.326487700546172},"actions":[0]}] \ No newline at end of file diff --git a/exampleFiles/SPINUPfield.vauto b/exampleFiles/SPINUPfield.vauto deleted file mode 100644 index cd6d653..0000000 --- a/exampleFiles/SPINUPfield.vauto +++ /dev/null @@ -1 +0,0 @@ -[{"position":{"x":69,"y":98,"heading":-101,"marginOfError":8.981606814793919},"actions":[0,1,3,2,4]},{"position":{"x":72,"y":72,"heading":0,"marginOfError":6}},{"position":{"x":83,"y":101,"heading":0,"marginOfError":20.256234283143364}},{"position":{"x":134,"y":58,"heading":97,"marginOfError":9.326487700546172},"actions":[0]}] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 301c2ef..ad41ff5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "cat-customs", - "version": "0.0.1", + "name": "vrc-auton", + "version": "0.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "cat-customs", - "version": "0.0.1", + "name": "vrc-auton", + "version": "0.0.2", "license": "MIT", "devDependencies": { "@types/node": "^16.11.7", diff --git a/package.json b/package.json index 1976f7a..0dc4edd 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { - "name": "cat-customs", - "displayName": "Cat Customs", - "description": "Custom Editor API Samples", - "version": "0.0.1", - "publisher": "vscode-samples", - "private": true, - "license": "MIT", + "name": "vrc-auton", + "displayName": "VRC Auton Builder", + "description": "Autonomous builder for the Vex Robotics Competition", + "version": "0.0.2", + "publisher": "AndrewCurtis", + "license": "MIT", "repository": { "type": "git", "url": "https://github.com/Microsoft/vscode-extension-samples" diff --git a/src/webview/eventList.ts b/src/common/eventList.ts similarity index 100% rename from src/webview/eventList.ts rename to src/common/eventList.ts diff --git a/src/common/message.ts b/src/common/message.ts index 4b77453..00970c1 100644 --- a/src/common/message.ts +++ b/src/common/message.ts @@ -1,4 +1,4 @@ -import { ListAction } from "../webview/eventList.js"; +import { ListAction } from "./eventList.js"; import { Node } from "./node.js"; export enum MSG_TARGET { diff --git a/src/server/pawDrawEditor.ts b/src/server/pawDrawEditor.ts index 326dd44..4cc9e72 100644 --- a/src/server/pawDrawEditor.ts +++ b/src/server/pawDrawEditor.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode"; import { Disposable, disposeAll } from "./dispose"; import { getNonce } from "./util"; import Message from "../common/message"; -import { ListAction } from "../webview/eventList"; +import { ListAction } from "../common/eventList"; import { Node } from "../common/node"; /** @@ -222,7 +222,7 @@ export class PawDrawEditorProvider private static newPawDrawFileId = 1; public static register(context: vscode.ExtensionContext): vscode.Disposable { - vscode.commands.registerCommand("catCustoms.pawDraw.new", () => { + vscode.commands.registerCommand("vrc-auton.builder.new", () => { const workspaceFolders = vscode.workspace.workspaceFolders; if (!workspaceFolders) { vscode.window.showErrorMessage( @@ -258,7 +258,7 @@ export class PawDrawEditorProvider ); } - private static readonly viewType = "catCustoms.pawDraw"; + private static readonly viewType = "vrc-auton.builder"; /** * Tracks all known webviews diff --git a/src/webview/listManager.ts b/src/webview/listManager.ts index d27ae1f..d84ec42 100644 --- a/src/webview/listManager.ts +++ b/src/webview/listManager.ts @@ -10,7 +10,7 @@ import { import { ACTION, Node } from "../common/node.js"; import ActionsManager from "./actionsManager.js"; import ErrorManager from "./errorManager.js"; -import { ListAction } from "./eventList.js"; +import { ListAction } from "../common/eventList.js"; import NodeList from "./nodeList.js"; import { Robot } from "./robot.js"; diff --git a/src/webview/nodeList.ts b/src/webview/nodeList.ts index 94d5aac..73649d2 100644 --- a/src/webview/nodeList.ts +++ b/src/webview/nodeList.ts @@ -1,4 +1,4 @@ -import EventList, { ListAction } from "./eventList.js"; +import EventList, { ListAction } from "../common/eventList.js"; // import Message from "../common/message.js"; import { Node as MyNode } from "../common/node.js"; import { HasMarginOfError, Position } from "../common/coordinates"; diff --git a/src/webview/pawDraw.ts b/src/webview/pawDraw.ts index 51d4916..aade8da 100644 --- a/src/webview/pawDraw.ts +++ b/src/webview/pawDraw.ts @@ -12,7 +12,7 @@ import Message from "../common/message.js"; import NodeList from "./nodeList.js"; import type { ACTION, Node as MyNode } from "../common/node.js"; import ListManager from "./listManager.js"; -import { ListAction, LIST_ACTION_TYPE } from "./eventList.js"; +import { ListAction, LIST_ACTION_TYPE } from "../common/eventList.js"; // @ts-ignore const vscode = acquireVsCodeApi();