-
Notifications
You must be signed in to change notification settings - Fork 25
Added Boomerang code #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Cavaire3D
wants to merge
16
commits into
Jerrylum:main
Choose a base branch
from
Cavaire3D:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f74d68b
✨ Add xVeclib Boomerang format
Cavaire3D 8b270c6
:sparkles: Finished Boomerang generation
Cavaire3D a8da415
:art: Formated code
Cavaire3D 49410c0
🐛 Fixed issue with 0 heading
Cavaire3D 71de232
:bug: Fixed initial rotation setting
Cavaire3D 1738f47
🔀Merge branch 'feature/veclib' of https://github.com/Cavaire3D/path.j…
Cavaire3D 285f2e4
🔇Removed Logs
Cavaire3D 3de64ce
🔥Removed Relative Coords
Cavaire3D 19f7d01
🐛Fixed Several Heading Bugs
Cavaire3D a5b6895
:art: Formated code
Cavaire3D 713ff64
🧪Began Creating tests
Cavaire3D 3659f83
:bug: Fixed lead generation
Cavaire3D cf97d86
:white_check_mark: Finished test cases and synced the repo
Cavaire3D 9035d0e
🔀 Merge remote-tracking branch 'Upstream/main'
Cavaire3D a816282
:lipstick:Added more configurations for lead
Cavaire3D 38cec8b
:children_crossing: Added a link to the new documentation
Cavaire3D File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
public/precache/V5RC-FieldPerimeter-Plain-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
public/precache/V5RC-HighStakes-H2H-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file modified
0
public/static/V5RC-HighStakes-Skills-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
public/static/V5RC-OverUnder-Skills-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
public/static/VURC-HighStakes-H2H-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
public/static/VURC-HighStakes-Skills-TileColor66_71-2000x2000.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
src/app/common.blocks/field-canvas/SegmentControlVisualLineElement.tsx
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
src/app/common.blocks/field-canvas/SegmentPointsHitBoxElement.tsx
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
179 changes: 179 additions & 0 deletions
179
src/format/xVecLibBoomerangFormatV0_1/GeneralConfig.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import { makeAutoObservable, action } from "mobx"; | ||
import { Typography, Button } from "@mui/material"; | ||
import { enqueueSuccessSnackbar, enqueueErrorSnackbar } from "@src/app/Notice"; | ||
import { FieldImageSignatureAndOrigin, FieldImageOriginType, getDefaultBuiltInFieldImage } from "@core/Asset"; | ||
import { UpdateProperties } from "@core/Command"; | ||
import { useCustomHotkeys, getEnableOnNonTextInputFieldsHotkeysOptions } from "@core/Hook"; | ||
import { getAppStores } from "@core/MainApp"; | ||
import { Logger } from "@core/Logger"; | ||
import { UnitOfLength } from "@core/Unit"; | ||
import { IS_MAC_OS, getMacHotKeyString, ValidateNumber } from "@core/Util"; | ||
import { Int, CodePointBuffer } from "@src/token/Tokens"; | ||
import { Expose, Type, Exclude } from "class-transformer"; | ||
import { IsPositive, IsBoolean, ValidateNested, IsObject, IsString, MinLength, IsIn } from "class-validator"; | ||
import { observer } from "mobx-react-lite"; | ||
import { GeneralConfig, initGeneralConfig } from "../Config"; | ||
import { Format } from "../Format"; | ||
import { PanelBox } from "@src/app/component.blocks/PanelBox"; | ||
import { FormInputField } from "@src/app/component.blocks/FormInputField"; | ||
import { getNamedCoordinateSystems } from "@src/core/CoordinateSystem"; | ||
import { FormCheckbox } from "@src/app/component.blocks/FormCheckbox"; | ||
interface FormatWithExportCode extends Format { | ||
exportCode(): string; | ||
} | ||
|
||
const logger = Logger("xVecLib Boomerang v1.0.0 (inch)"); | ||
|
||
const GeneralConfigPanel = observer((props: { config: GeneralConfigImpl }) => { | ||
const { config } = props; | ||
|
||
const { app, confirmation, ui } = getAppStores(); | ||
|
||
const isUsingEditor = !confirmation.isOpen && !ui.isOpeningModal; | ||
|
||
const onCopyCode = action(() => { | ||
try { | ||
const code = config.format.exportCode(); | ||
|
||
navigator.clipboard.writeText(code); | ||
|
||
enqueueSuccessSnackbar(logger, "Copied"); | ||
} catch (e) { | ||
enqueueErrorSnackbar(logger, e); | ||
} | ||
}); | ||
|
||
useCustomHotkeys("Shift+Mod+C", onCopyCode, getEnableOnNonTextInputFieldsHotkeysOptions(isUsingEditor)); | ||
|
||
const hotkey = IS_MAC_OS ? getMacHotKeyString("Shift+Mod+C") : "Shift+Ctrl+C"; | ||
|
||
return ( | ||
<> | ||
<Typography sx={{ marginTop: "16px" }}>Export Settings</Typography> | ||
<PanelBox className="Panel-FlexBox"> | ||
<FormInputField | ||
label="Chassis Name" | ||
getValue={() => config.chassisName} | ||
setValue={(value: string) => { | ||
app.history.execute(`Change chassis variable name`, new UpdateProperties(config, { chassisName: value })); | ||
}} | ||
isValidIntermediate={() => true} | ||
isValidValue={(candidate: string) => candidate !== ""} | ||
sx={{ marginTop: "16px" }} | ||
/> | ||
<FormInputField | ||
label="Movement Timeout" | ||
getValue={() => config.movementTimeout.toString()} | ||
setValue={(value: string) => { | ||
const parsedValue = parseInt(Int.parse(new CodePointBuffer(value))!.value); | ||
app.history.execute( | ||
`Change default movement timeout to ${parsedValue}`, | ||
new UpdateProperties(config, { movementTimeout: parsedValue }) | ||
); | ||
}} | ||
isValidIntermediate={() => true} | ||
isValidValue={(candidate: string) => Int.parse(new CodePointBuffer(candidate)) !== null} | ||
sx={{ marginTop: "16px" }} | ||
numeric | ||
/> | ||
</PanelBox> | ||
|
||
<PanelBox marginTop="16px"> | ||
<Button variant="contained" title={`Copy Generated Code (${hotkey})`} onClick={onCopyCode}> | ||
Copy Code | ||
</Button> | ||
<a href="https://xvec.codeberg.page/Path%20Generation"><h3>Documentation</h3></a> | ||
|
||
</PanelBox> | ||
<Typography sx={{ marginTop: "16px" }}>Lead Settings</Typography> | ||
<PanelBox className="Panel-FlexBox"> | ||
<FormInputField | ||
label="Iterations to find lead" | ||
getValue={() => config.maxIterations.toString()} | ||
setValue={(value: string) => { | ||
const parsedValue = parseInt(Int.parse(new CodePointBuffer(value))!.value); | ||
app.history.execute( | ||
`Change max iterations for lead to ${parsedValue}`, | ||
new UpdateProperties(config, { maxIterations: parsedValue }) | ||
); | ||
}} | ||
isValidIntermediate={() => true} | ||
isValidValue={(candidate: string) => Int.parse(new CodePointBuffer(candidate)) !== null} | ||
sx={{ marginTop: "16px" }} | ||
numeric | ||
/> | ||
<FormCheckbox | ||
label="Use broken lead" | ||
checked={config.badLead} | ||
onCheckedChange={value => { | ||
app.history.execute(`Using real(bad) lead's is ${value}`, new UpdateProperties(config, { badLead: value })); | ||
}} | ||
/> | ||
</PanelBox> | ||
</> | ||
); | ||
}); | ||
export class GeneralConfigImpl implements GeneralConfig { | ||
@IsPositive() | ||
@Expose() | ||
robotWidth: number = 12; | ||
@IsPositive() | ||
@Expose() | ||
robotHeight: number = 12; | ||
@IsBoolean() | ||
@Expose() | ||
robotIsHolonomic: boolean = false; | ||
@IsBoolean() | ||
@Expose() | ||
showRobot: boolean = false; | ||
@ValidateNumber(num => num > 0 && num <= 1000) // Don't use IsEnum | ||
@Expose() | ||
uol: UnitOfLength = UnitOfLength.Inch; | ||
@IsPositive() | ||
@Expose() | ||
pointDensity: number = 2; // inches | ||
@IsPositive() | ||
@Expose() | ||
controlMagnetDistance: number = 5 / 2.54; | ||
@Type(() => FieldImageSignatureAndOrigin) | ||
@ValidateNested() | ||
@IsObject() | ||
@Expose() | ||
fieldImage: FieldImageSignatureAndOrigin<FieldImageOriginType> = | ||
getDefaultBuiltInFieldImage().getSignatureAndOrigin(); | ||
@IsString() | ||
@MinLength(1) | ||
@Expose() | ||
chassisName: string = "chassis"; | ||
@ValidateNumber(num => num >= 0) | ||
@Expose() | ||
movementTimeout: number = 5000; | ||
@Expose() | ||
maxIterations: number = 200; | ||
@IsBoolean() | ||
@Expose() | ||
badLead: boolean = false; | ||
@IsBoolean() | ||
@Expose() | ||
relativeCoords: boolean = true; | ||
@IsIn(getNamedCoordinateSystems().map(s => s.name)) | ||
@Expose() | ||
coordinateSystem: string = "VEX Gaming Positioning System"; | ||
@Exclude() | ||
private format_: FormatWithExportCode; | ||
|
||
constructor(format: FormatWithExportCode) { | ||
this.format_ = format; | ||
makeAutoObservable(this); | ||
|
||
initGeneralConfig(this); | ||
} | ||
|
||
get format() { | ||
return this.format_; | ||
} | ||
|
||
getAdditionalConfigUI() { | ||
return <GeneralConfigPanel config={this} />; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { makeAutoObservable } from "mobx"; | ||
import { Typography } from "@mui/material"; | ||
import { BentRateApplicationDirection, Path } from "@core/Path"; | ||
import { EditableNumberRange } from "@core/Util"; | ||
import { Exclude, Expose } from "class-transformer"; | ||
import { IsNumber } from "class-validator"; | ||
import { PathConfig } from "../Config"; | ||
import { Format } from "../Format"; | ||
import { LayoutContext, LayoutType, PanelBuilderProps, PanelInstanceProps } from "@core/Layout"; | ||
import { getAppStores } from "@core/MainApp"; | ||
import { observer } from "mobx-react-lite"; | ||
import React from "react"; | ||
import LinearScaleIcon from "@mui/icons-material/LinearScale"; | ||
|
||
// observable class | ||
export class PathConfigImpl implements PathConfig { | ||
@Exclude() | ||
speedLimit: EditableNumberRange = { | ||
minLimit: { value: 0, label: "0" }, | ||
maxLimit: { value: 127, label: "127" }, | ||
step: 1, | ||
from: 0, | ||
to: 1 | ||
}; | ||
@Exclude() | ||
bentRateApplicableRange: EditableNumberRange = { | ||
minLimit: { value: 0, label: "0" }, | ||
maxLimit: { value: 1, label: "1" }, | ||
step: 0.01, | ||
from: 0, | ||
to: 1 | ||
}; | ||
@Exclude() | ||
bentRateApplicationDirection = BentRateApplicationDirection.LowToHigh; | ||
@IsNumber() | ||
@Expose() | ||
speed: number = 30; | ||
@Exclude() | ||
readonly format: Format; | ||
|
||
@Exclude() | ||
public path!: Path; | ||
|
||
constructor(format: Format) { | ||
this.format = format; | ||
makeAutoObservable(this); | ||
} | ||
} | ||
|
||
const PathConfigPanelBody = observer((props: {}) => { | ||
const { app } = getAppStores(); | ||
|
||
const pc = app.selectedPath?.pc as PathConfigImpl | undefined; | ||
|
||
const isClassic = React.useContext(LayoutContext) === LayoutType.Classic; | ||
|
||
if (pc === undefined) { | ||
return isClassic ? undefined : <Typography>(No selected path)</Typography>; | ||
} | ||
|
||
return; | ||
}); | ||
|
||
export const PathConfigPanel = (props: PanelBuilderProps): PanelInstanceProps => { | ||
return { | ||
id: "PathConfigAccordion", | ||
header: "Path", | ||
children: <PathConfigPanelBody />, | ||
icon: <LinearScaleIcon fontSize="large" /> | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { xVecLibBoomerangFormatV0_1 } from "."; | ||
import { MainApp, getAppStores } from "@core/MainApp"; | ||
import { Control, EndControl, Segment } from "@core/Path"; | ||
import { GeneralConfigImpl } from "./GeneralConfig"; | ||
import { SmartBuffer } from "smart-buffer"; | ||
import { LemLibV1_0 } from "../LemLibFormatV1_0/Serialization"; | ||
test("dummy", () => { | ||
const { app } = getAppStores(); // suppress constructor error | ||
}); | ||
test("read write path file", () => { | ||
const format = new xVecLibBoomerangFormatV0_1(); | ||
const path = format.createPath(); | ||
|
||
const buffer1 = SmartBuffer.fromSize(1024); // auto resize | ||
path.segments.push(new Segment(new EndControl(1, 1, 0), new EndControl(60, 60, 90))); | ||
path.segments.push(new Segment(path.segments[path.segments.length - 1].last, new EndControl(63, 60, 180))); | ||
path.segments.push(new Segment(path.segments[path.segments.length - 1].last, new EndControl(64, 60, 270))); | ||
|
||
LemLibV1_0.writePath(buffer1, path); | ||
|
||
const result = LemLibV1_0.readPath(buffer1); | ||
|
||
expect(result.name).toBe(path.name); | ||
|
||
const points = path.cachedResult.points; | ||
|
||
expect(result.waypoints.length).toBe(points.length); | ||
|
||
for (let i = 0; i < points.length; i++) { | ||
const point1 = points[i]; | ||
const point2 = result.waypoints[i]; | ||
|
||
expect(point2.x).toBeCloseTo(point1.x, 0.1); | ||
expect(point2.y).toBeCloseTo(point1.y, 0.1); | ||
expect(point2.heading ?? 0).toBeCloseTo(point1.heading ?? 0); | ||
} | ||
|
||
// let code = format.exportCode(); | ||
// console.log(code); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.