Skip to content

Commit

Permalink
Add Action:Turn & Add Condition:SucceedOnAverageColour
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Apr 17, 2024
1 parent ccc37fb commit 5d8fef0
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions app/admin_panel/src/lib/CodeBox_Constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { hoverTooltip } from "@codemirror/view";

export const range_0_180 = [
"0",
"1",
"2",
"3",
Expand Down Expand Up @@ -184,6 +185,7 @@ export const range_0_180 = [
];

export const range_0_360 = [
"0",
"1",
"2",
"3",
Expand Down Expand Up @@ -547,6 +549,7 @@ export const range_0_360 = [
];

export const range_0_100 = [
"0",
"1",
"2",
"3",
Expand Down Expand Up @@ -657,6 +660,7 @@ export const common_nodes = [
// Composite
"Selector",
"Sequence",
"Random",

// Decorator
"Invert",
Expand All @@ -668,18 +672,20 @@ export const common_nodes = [
"Task",
"UseRoot",

// Task Nodes
"Action:PauseExecution",

"Action:Print",

"Action:Drive",
"Action:Turn",

"Action:SetAngle",
"Action:SetSpeed",
"Action:SetWheelDirection",

"Condition:SucceedOnAverageNearbyScan",
"Condition:SucceedOnAnyNearbyScan",
"Condition:SucceedOnAverageColour",
];

export const xml_schema = {
Expand Down Expand Up @@ -775,6 +781,17 @@ export const xml_schema = {
],
completion: { type: "keyword" },
},
{
name: "Action:Turn",
attributes: [
{
name: "angle",
values: range_0_180,
completion: { type: "keyword" },
},
],
completion: { type: "keyword" },
},
{
name: "Action:SetAngle",
attributes: [
Expand Down Expand Up @@ -842,7 +859,7 @@ export const xml_schema = {
completion: { type: "keyword" },
},
{
name: "Condition:SucceedOnAllNearbyScan",
name: "Condition:SucceedOnAnyNearbyScan",
attributes: [
{
name: "min_angle",
Expand All @@ -858,6 +875,18 @@ export const xml_schema = {
],
completion: { type: "keyword" },
},
{
name: "Condition:SucceedOnAverageColour",
attributes: [
"hex_colour",
{
name: "tolerance",
values: range_0_100,
completion: { type: "keyword" },
},
],
completion: { type: "keyword" },
}
],
attributes: [{ name: "name", global: true }],
};
Expand All @@ -869,6 +898,7 @@ const node_information_list = new Map([
["Root", "Start of every node tree"],
["Selector", "Runs children until one succeeds"],
["Sequence", "Runs children until one fails"],
["Random", "Runs a random child"],

["UseRoot", "Goes to the given root node id"],
["Invert", "Inverts the result of the child"],
Expand All @@ -881,12 +911,15 @@ const node_information_list = new Map([
["Action:Print", "Prints the given message"],

["Action:Drive", "Set the speed and direction of the car"],
["Action:Turn", "Turns the car by the given angle"],

["Action:SetAngle", "Turns the car by the given angle"],
["Action:SetSpeed", "Moves the car by the given speed"],
["Action:SetWheelDirection", "Sets the direction of the car"],

["Condition:SucceedOnAverageNearbyScan", "Checks the average distance between two angles and succeeds if the average is below the specified cm"],
["Condition:SucceedOnAnyNearbyScan", "Checks the distance of all nearby points and succeeds if any is below the specified cm"],
["Condition:SucceedOnAverageColour", "Checks the average colour of the camera and succeeds if the colour is within the tolerance"],
]);

// Modified code from: https://codemirror.net/examples/tooltip/
Expand Down

0 comments on commit 5d8fef0

Please sign in to comment.