From f54da5bf423cbe68ca6492d8dcd9da7cf41dd8f9 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 20 Dec 2024 20:59:59 +0300 Subject: [PATCH] Add CLI command for rebooting the drone --- flix/cli.ino | 5 ++++- gazebo/Arduino.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/flix/cli.ino b/flix/cli.ino index 824d8b3..121a739 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -31,7 +31,8 @@ const char* motd = "cg - calibrate gyro\n" "ca - calibrate accel\n" "mfr, mfl, mrr, mrl - test motor\n" -"reset - reset drone's state\n"; +"reset - reset drone's state\n" +"reboot - reboot the drone\n"; const struct Param { const char* name; @@ -103,6 +104,8 @@ void doCommand(String& command, String& value) { cliTestMotor(MOTOR_REAR_LEFT); } else if (command == "reset") { attitude = Quaternion(); + } else if (command == "reboot") { + ESP.restart(); } else { float val = value.toFloat(); // TODO: on error returns 0, check invalid value diff --git a/gazebo/Arduino.h b/gazebo/Arduino.h index 48b56de..e065992 100644 --- a/gazebo/Arduino.h +++ b/gazebo/Arduino.h @@ -129,6 +129,11 @@ public: HardwareSerial Serial, Serial2; +class EspClass { +public: + void restart() { Serial.println("Ignore reboot in simulation"); } +} ESP; + void delay(uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); }