diff --git a/examples/BasicMoves/BasicMoves.ino b/examples/BasicMoves/BasicMoves.ino new file mode 100644 index 0000000..d30b57d --- /dev/null +++ b/examples/BasicMoves/BasicMoves.ino @@ -0,0 +1,42 @@ +// Example of the LARS Movement library +#include + +LARS robot; // using default ESP32 pinning values for constructor + +boolean walk_forward = false; +boolean walk_backward = false; +boolean hello = false; +boolean turn_left = false; +boolean turn_right = false; +boolean moonwalk = false; +boolean audience = false; +boolean omni = false; +boolean omni_left = false; +boolean dance = false; +boolean upDown = false; +boolean PushUp = false; + +void setup() { + Serial.begin(115200); + + robot.init(); + delay(500); +} + +void loop() { + + if (walk_forward) robot.walk(0); + else if (walk_backward) robot.walk(); + else if (hello) robot.hello(); + else if (turn_left) robot.turnL(1, 550); + else if (turn_right) robot.turnR(1, 550); + else if (moonwalk) robot.moonwalk(1, 5000); + else if (audience) robot.wave(1); + else if (dance) robot.dance(1, 600); + else if (omni) robot.omniWalk(1, 600, true, 1); + else if (omni_left) robot.omniWalk(1, 600, false, 1); + else if (PushUp) robot.pushUp(1, 600); + else if (upDown) robot.upDown(1, 5000); + else robot.home(); + +} diff --git a/examples/REPLACEME b/examples/REPLACEME deleted file mode 100644 index e69de29..0000000 diff --git a/examples/WebInterface/WebInterface.ino b/examples/WebInterface/WebInterface.ino new file mode 100644 index 0000000..7a78a55 --- /dev/null +++ b/examples/WebInterface/WebInterface.ino @@ -0,0 +1,176 @@ +// Example of the LARS Movement library using the ESPUI Webinferface by Lukas Bachschwell +#include +#include +#include + +LARS robot; // using default ESP32 pinning values for constructor + +boolean walk_forward = false; +boolean walk_backward = false; +boolean hello = false; +boolean turn_left = false; +boolean turn_right = false; +boolean moonwalk = false; +boolean audience = false; +boolean omni = false; +boolean omni_left = false; +boolean dance = false; +boolean upDown = false; +boolean PushUp = false; + +void setup() { + Serial.begin(115200); + WiFi.mode(WIFI_AP); + WiFi.setHostname("Lars"); + WiFi.softAP("Lars"); + Serial.println(""); + Serial.print("IP address: "); + Serial.println(WiFi.softAPIP()); + + + ESPUI.pad("Walking Control", true, &walkingPad, COLOR_CARROT); + ESPUI.pad("Wave some legs", false, &wavePad, COLOR_CARROT); + ESPUI.button("Wave Button", &audienceWaveButton, COLOR_PETERRIVER); + ESPUI.button("MoonWalk Button", &moonWalkButton, COLOR_PETERRIVER); + ESPUI.button("Dance Button", &danceButton, COLOR_PETERRIVER); + ESPUI.button("PushUp Button", &pushUpButton, COLOR_PETERRIVER); + ESPUI.button("upDown Button", &upDownButton, COLOR_PETERRIVER); + ESPUI.button("Slow Turn Right", &slowTurnRight, COLOR_PETERRIVER); + ESPUI.button("Slow Turn left", &slowTurnLeft, COLOR_PETERRIVER); + + ESPUI.begin("Crabby Control"); + + robot.init(); + delay(1000); +} + +void audienceWaveButton(Control c, int type) { + if (type == B_DOWN) { + audience = true; + } + else { + audience = false; + } +} + + +void moonWalkButton(Control c, int type) { + if (type == B_DOWN) { + moonwalk = true; + } + else { + moonwalk = false; + } +} + +void danceButton(Control c, int type) { + if (type == B_DOWN) { + dance = true; + } + else { + dance = false; + } +} +void pushUpButton(Control c, int type) { + if (type == B_DOWN) { + PushUp = true; + } + else { + PushUp = false; + } +} +void upDownButton(Control c, int type) { + if (type == B_DOWN) { + upDown = true; + } + else { + upDown = false; + } +} +void slowTurnRight(Control c, int type) { + if (type == B_DOWN) { + omni = true; + } + else { + omni = false; + } +} + +void slowTurnLeft(Control c, int type) { + if (type == B_DOWN) { + omni_left = true; + } + else { + omni_left = false; + } +} + +void walkingPad(Control c, int value) { + switch (value) { + case P_LEFT_DOWN: + turn_left = true; + break; + case P_LEFT_UP: + turn_left = false; + break; + case P_RIGHT_DOWN: + turn_right = true; + break; + case P_RIGHT_UP: + turn_right = false; + break; + case P_FOR_DOWN: + walk_forward = true; + break; + case P_FOR_UP: + walk_forward = false; + break; + case P_BACK_DOWN: + walk_backward = true; + break; + case P_BACK_UP: + walk_backward = false; + break; + case P_CENTER_DOWN: + hello = true; + break; + case P_CENTER_UP: + hello = false; + break; + } +} + +void wavePad(Control c, int value) { + switch (value) { + case P_LEFT_DOWN: + robot.wave(1); + break; + case P_RIGHT_DOWN: + robot.wave(2); + break; + case P_FOR_DOWN: + robot.wave(3); + break; + case P_BACK_DOWN: + robot.wave(4); + break; + } +} + +void loop() { + + if (walk_forward) robot.walk(0); + else if (walk_backward) robot.walk(); + else if (hello) robot.hello(); + else if (turn_left) robot.turnL(1, 550); + else if (turn_right) robot.turnR(1, 550); + else if (moonwalk) robot.moonwalk(1, 5000); + else if (audience) robot.wave(1); + else if (dance) robot.dance(1, 600); + else if (omni) robot.omniWalk(1, 600, true, 1); + else if (omni_left) robot.omniWalk(1, 600, false, 1); + else if (PushUp) robot.pushUp(1, 600); + else if (upDown) robot.upDown(1, 5000); + else robot.home(); + +} diff --git a/src/LARS.cpp b/src/LARS.cpp index 0a56afe..6037357 100644 --- a/src/LARS.cpp +++ b/src/LARS.cpp @@ -16,7 +16,7 @@ */ -LARS::LARS(int FRH = 26, int FLH = 25, int BRH = 17, int BLH = 16, int FRL = 27, int FLL = 5, int BRL = 23, int BLL = 13): reverse{0, 0, 0, 0, 0, 0, 0, 0}, trim{0, 0, 0, 0, 0, 0, 0, 0} { +LARS::LARS(int FRH, int FLH, int BRH, int BLH, int FRL, int FLL, int BRL, int BLL): reverse{0, 0, 0, 0, 0, 0, 0, 0}, trim{0, 0, 0, 0, 0, 0, 0, 0} { board_pins[FRONT_RIGHT_HIP] = FRH; // front right inner board_pins[FRONT_LEFT_HIP] = FLH; // front left inner board_pins[BACK_RIGHT_HIP] = BRH; // back right inner diff --git a/src/LARS.h b/src/LARS.h index 7da8eaa..8a9d772 100644 --- a/src/LARS.h +++ b/src/LARS.h @@ -24,7 +24,7 @@ class LARS { public: - LARS(int FRH, int FLH, int BRH, int BLH, int FRL, int FLL, int BRL, int BLL); + LARS(int FRH = 26, int FLH = 25, int BRH = 17, int BLH = 16, int FRL = 27, int FLL = 5, int BRL = 23, int BLL = 13); void init(); void walk(int dir = 1, float steps = 1, float T = 800); // T initial 400 void omniWalk(float steps, float T, bool side, float turn_factor);