From 900ff1ae96ad9772eb9dbbf461a4812eb223c92d Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 16 Dec 2022 12:03:10 +0100 Subject: [PATCH 1/2] add statemachine, use RobotLib and logger --- ADIS_Csharp/RaspiControl/Application.cs | 123 +++++++++++++++++++ ADIS_Csharp/RaspiControl/ChallengeFactory.cs | 21 ++++ ADIS_Csharp/RaspiControl/Joystick.cs | 5 +- ADIS_Csharp/RaspiControl/NLog.config | 37 ++++++ ADIS_Csharp/RaspiControl/Program.cs | 100 +-------------- ADIS_Csharp/RaspiControl/RaspiControl.csproj | 10 ++ ADIS_Csharp/RaspiControl/StateMachine.cs | 111 +++++++++++++++++ 7 files changed, 309 insertions(+), 98 deletions(-) create mode 100644 ADIS_Csharp/RaspiControl/Application.cs create mode 100644 ADIS_Csharp/RaspiControl/ChallengeFactory.cs create mode 100644 ADIS_Csharp/RaspiControl/NLog.config create mode 100644 ADIS_Csharp/RaspiControl/StateMachine.cs diff --git a/ADIS_Csharp/RaspiControl/Application.cs b/ADIS_Csharp/RaspiControl/Application.cs new file mode 100644 index 0000000..560bbd3 --- /dev/null +++ b/ADIS_Csharp/RaspiControl/Application.cs @@ -0,0 +1,123 @@ +using NLog.LayoutRenderers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace RaspiControl { + + internal class Application { + private ChallengeFactory? challenge; + private StateMachine sm; + private readonly NLog.Logger log; + public Application() { + this.log = NLog.LogManager.GetCurrentClassLogger(); + this.sm = new StateMachine(); + this.challenge = new ChallengeFactory(); + this.challenge.PublisherSubscriber.ConnectionStateChanged += this.PublisherSubscriber_ConnectionStateChanged; + this.challenge.PublisherSubscriber.Connect("localhost", "ADIS", "TEST"); + Joystick joystick = new Joystick(); + joystick.JoystickChanged += Joystick_JoystickChanged; + } + + public void Run() { + bool success = this.challenge.PublisherSubscriber.Connect("localhost", "ADIS", "TEST"); + if (!success) { + throw new Exception("Could not connect to broker on localhost"); + } else { + this.sm.MoveNext(Command.Connected); + this.log.Info($"Current State: {this.sm.CurrentState}"); + } + } + + private void PublisherSubscriber_ConnectionStateChanged(object? sender, bool e) { + if (e == false) { + this.log.Error("Connection to MQTT broker lost"); + } else { + this.log.Info("Connected to MQTT broker"); + } + } + + private void smHandler() { + this.log.Info($"Current State: {this.sm.CurrentState}"); + switch (this.sm.CurrentState) { + case ProcessState.Startup: + break; + case ProcessState.Init: + break; + case ProcessState.Ready: + // show sf redy + this.challenge.RobotStationary.SplitFlap.Display("REDY"); + break; + case ProcessState.StartMoveManual: + // mode automatic:false + this.challenge.RobotStationary.SplitFlap.Display("WALD"); + this.challenge.RobotMobile.Movement.SetMobilityMode(false); + this.challenge.RobotMobile.Movement.AddSpeed(NavigationConstants.SPEED_FORWARD); + this.sm.MoveNext(Command.none); + break; + case ProcessState.ResumeMoveManual: + this.challenge.RobotMobile.Movement.SetMobilityMode(false); + this.challenge.RobotMobile.Movement.AddSpeed(NavigationConstants.SPEED_FORWARD); + this.sm.MoveNext(Command.none); + break; + case ProcessState.MoveManual: + break; + case ProcessState.MoveManualF: + // move + 100 + this.challenge.RobotMobile.Movement.AddSpeed(NavigationConstants.SPEED_FORWARD); + this.sm.MoveNext(Command.none); + break; + case ProcessState.MoveManualB: + // move -100 + this.challenge.RobotMobile.Movement.AddSpeed(NavigationConstants.SPEED_BACKWARD); + this.sm.MoveNext(Command.none); + break; + case ProcessState.MoveManualL: + this.challenge.RobotMobile.Movement.Turn(NavigationConstants.TURN_ANGLE_LEFT); + this.sm.MoveNext(Command.none); + break; + case ProcessState.MoveManualR: + // turn right 30 + this.challenge.RobotMobile.Movement.Turn(NavigationConstants.TURN_ANGLE_RIGHT); + this.sm.MoveNext(Command.none); + break; + case ProcessState.StopManual: + // stop + this.challenge.RobotMobile.Movement.Stop(); + break; + case ProcessState.Auto: + break; + case ProcessState.Final: + break; + case ProcessState.Error: + break; + } + } + + private void Joystick_JoystickChanged(object sender, JoystickEventArgs e) { + switch (e.Button) { + case JoystickButton.None: + break; + case JoystickButton.Left: + this.sm.MoveNext(Command.JoystickLeft); + break; + case JoystickButton.Right: + this.sm.MoveNext(Command.JoystickRight); + break; + case JoystickButton.Up: + this.sm.MoveNext(Command.JoystickUp); + break; + case JoystickButton.Down: + this.sm.MoveNext(Command.JoystickDown); + break; + case JoystickButton.Center: + this.sm.MoveNext(Command.JoystickCenter); + break; + } + this.smHandler(); + } + } +} diff --git a/ADIS_Csharp/RaspiControl/ChallengeFactory.cs b/ADIS_Csharp/RaspiControl/ChallengeFactory.cs new file mode 100644 index 0000000..941a357 --- /dev/null +++ b/ADIS_Csharp/RaspiControl/ChallengeFactory.cs @@ -0,0 +1,21 @@ +using RobotLib.Communication; +using RobotLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RaspiControl { + internal class ChallengeFactory { + public MqttPublisherSubscriber PublisherSubscriber { get; } + public Robot RobotStationary { get; } + public Robot RobotMobile { get; } + + public ChallengeFactory() { + this.PublisherSubscriber = MqttPublisherSubscriber.Instance; + this.RobotStationary = new Robot(this.PublisherSubscriber); + this.RobotMobile = new Robot(this.PublisherSubscriber); + } + } +} diff --git a/ADIS_Csharp/RaspiControl/Joystick.cs b/ADIS_Csharp/RaspiControl/Joystick.cs index 8f84b83..7a7bca8 100644 --- a/ADIS_Csharp/RaspiControl/Joystick.cs +++ b/ADIS_Csharp/RaspiControl/Joystick.cs @@ -32,13 +32,14 @@ namespace RaspiControl { public event EventHandler? JoystickChanged; private void OnJoystickChanged(JoystickButton state) { - Console.WriteLine($"Joystick was pushed: {state}"); + this.log.Trace($"Joystick was pushed: {state}"); this.JoystickChanged?.Invoke(this, new JoystickEventArgs(state)); } #endregion - + private readonly NLog.Logger log; public Joystick() { Pi.Init(); + this.log = NLog.LogManager.GetCurrentClassLogger(); foreach (var pin in inputPins) { pin.PinMode = GpioPinDriveMode.Input; } diff --git a/ADIS_Csharp/RaspiControl/NLog.config b/ADIS_Csharp/RaspiControl/NLog.config new file mode 100644 index 0000000..6c004ed --- /dev/null +++ b/ADIS_Csharp/RaspiControl/NLog.config @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ADIS_Csharp/RaspiControl/Program.cs b/ADIS_Csharp/RaspiControl/Program.cs index 5c36bfe..5df5de7 100644 --- a/ADIS_Csharp/RaspiControl/Program.cs +++ b/ADIS_Csharp/RaspiControl/Program.cs @@ -5,108 +5,16 @@ using System.Text.Json; namespace RaspiControl { class Programm { - private static MqttClient client; + private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); static void Main(string[] args) { try { - client = new MqttClient("localhost"); - client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived; - string clientId = Guid.NewGuid().ToString(); - client.Connect(clientId); - client.Subscribe(new string[] { MqttConstants.DEVICE_STATUS_APP_TOPIC }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE }); - Joystick joystick = new Joystick(); - joystick.JoystickChanged += Joystick_JoystickChanged; + Application app = new Application(); + app.Run(); } catch (Exception ex) { - Console.WriteLine(ex.Message); + log.Error(ex); } } - - private static void Joystick_JoystickChanged(object sender, JoystickEventArgs e) { - switch (e.Button) { - case JoystickButton.None: - break; - case JoystickButton.Left: - client.Publish(MqttConstants.MOBILE_NAV_TURN_TOPIC, Encoding.UTF8.GetBytes($"{NavigationConstants.TURN_ANGLE_LEFT}"), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); - break; - case JoystickButton.Right: - client.Publish(MqttConstants.MOBILE_NAV_TURN_TOPIC, Encoding.UTF8.GetBytes($"{NavigationConstants.TURN_ANGLE_RIGHT}"), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); - break; - case JoystickButton.Up: - client.Publish(MqttConstants.MOBILE_NAV_MOVE_TOPIC, Encoding.UTF8.GetBytes($"{NavigationConstants.SPEED_FORWARD}"), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); - break; - case JoystickButton.Down: - client.Publish(MqttConstants.MOBILE_NAV_MOVE_TOPIC, Encoding.UTF8.GetBytes($"{NavigationConstants.SPEED_BACKWARD}"), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); - break; - case JoystickButton.Center: - client.Publish(MqttConstants.MOBILE_NAV_STOP_TOPIC, Encoding.UTF8.GetBytes($"{NavigationConstants.STOP}"), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false); - break; - } - } - - private static void PublishSplitFlapDisplay(string message) { - string payload = JsonSerializer.Serialize>(new Dictionary() { { "message", message } }); - client.Publish(MqttConstants.SPLITFLAP_DISPLAY_TOPIC, Encoding.UTF8.GetBytes(payload),MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE,false); - } - private static void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { - string deviceId = ""; - Dictionary data; - if (e.Topic.StartsWith(string.Join('/',MqttConstants.DEVICE_STATUS_APP_TOPIC.Split('/').Take(2)))) { - if(e.Topic.EndsWith(MqttConstants.DEVICE_STATUS_APP_TOPIC.Split('/').Last())) { - deviceId = deviceIdFromStatusTopic(e.Topic); - if(deviceId == "mobile") { - try { - data = getValueFromTopic(Encoding.UTF8.GetString(e.Message)); - object value; - data.TryGetValue("state", out value); - if (value != null) { - APP_STATE appState = (APP_STATE)Convert.ToUInt16(value.ToString()); - switch (appState) { - case APP_STATE.STARTUP: - Console.WriteLine("Startup"); - client.Publish(MqttConstants.SPLITFLAP_INIT_TOPIC, new byte[] { }, MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); - break; - case APP_STATE.INIT: - Console.WriteLine("Init"); - PublishSplitFlapDisplay("INIT"); - break; - case APP_STATE.CALIBRATE: - break; - case APP_STATE.FOLLOW_LINE: - Console.WriteLine("Follow line"); - PublishSplitFlapDisplay("AUTO"); - break; - case APP_STATE.IDLE: - break; - case APP_STATE.FINAL: - break; - case APP_STATE.READY: - Console.WriteLine("ready"); - PublishSplitFlapDisplay("REDY"); - break; - default: - throw new ArgumentException(); - } - } - } catch(Exception) { - Console.WriteLine($"Invalid payload received: {Encoding.UTF8.GetString(e.Message)}"); - } - - - } - else { - Console.WriteLine($"on topic: {e.Topic} no key with state found! | {Encoding.UTF8.GetString(e.Message)}"); - } - } - } - } - - private static string deviceIdFromStatusTopic(string statusTopic) { - string[] topic = statusTopic.Split('/'); - return topic[topic.Length - 2]; - } - private static Dictionary getValueFromTopic(string topic) { - return JsonSerializer.Deserialize>(topic); - } } } \ No newline at end of file diff --git a/ADIS_Csharp/RaspiControl/RaspiControl.csproj b/ADIS_Csharp/RaspiControl/RaspiControl.csproj index f1edd23..d41197f 100644 --- a/ADIS_Csharp/RaspiControl/RaspiControl.csproj +++ b/ADIS_Csharp/RaspiControl/RaspiControl.csproj @@ -17,4 +17,14 @@ + + + + + + + PreserveNewest + + + diff --git a/ADIS_Csharp/RaspiControl/StateMachine.cs b/ADIS_Csharp/RaspiControl/StateMachine.cs new file mode 100644 index 0000000..396cf85 --- /dev/null +++ b/ADIS_Csharp/RaspiControl/StateMachine.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RaspiControl { + public enum ProcessState { + Startup, + Init, + Ready, + StartMoveManual, + ResumeMoveManual, + MoveManual, + MoveManualF, + MoveManualB, + MoveManualL, + MoveManualR, + StopManual, + Auto, + Final, + Error + } + + public enum Command { + Connected, + InitDone, + JoystickUp, + JoystickDown, + JoystickLeft, + JoystickRight, + JoystickCenter, + autoMode, + none + } + internal class StateMachine { + + class StateTransition { + readonly ProcessState CurrentState; + readonly Command Command; + + public StateTransition(ProcessState currentState, Command command) { + CurrentState = currentState; + Command = command; + } + + public override int GetHashCode() { + return 17 + 31 * CurrentState.GetHashCode() + 31 * Command.GetHashCode(); + } + + public override bool Equals(object obj) { + StateTransition other = obj as StateTransition; + return other != null && this.CurrentState == other.CurrentState && this.Command == other.Command; + } + } + + Dictionary transitions; + public ProcessState CurrentState { get; private set; } + + public StateMachine() { + CurrentState = ProcessState.Startup; + transitions = new Dictionary { + {new StateTransition(ProcessState.Startup,Command.Connected), ProcessState.Init }, + + {new StateTransition(ProcessState.Init,Command.JoystickCenter), ProcessState.Ready }, + + {new StateTransition(ProcessState.Ready,Command.JoystickUp), ProcessState.StartMoveManual }, + {new StateTransition(ProcessState.Ready,Command.JoystickDown), ProcessState.StartMoveManual }, + {new StateTransition(ProcessState.Ready,Command.JoystickLeft), ProcessState.StartMoveManual }, + {new StateTransition(ProcessState.Ready,Command.JoystickRight), ProcessState.StartMoveManual }, + + {new StateTransition(ProcessState.StartMoveManual,Command.none), ProcessState.MoveManual }, + + {new StateTransition(ProcessState.MoveManualF, Command.none), ProcessState.MoveManual }, + {new StateTransition(ProcessState.MoveManualB, Command.none), ProcessState.MoveManual }, + {new StateTransition(ProcessState.MoveManualL, Command.none), ProcessState.MoveManual }, + {new StateTransition(ProcessState.MoveManualR, Command.none), ProcessState.MoveManual }, + + {new StateTransition(ProcessState.MoveManual, Command.JoystickUp), ProcessState.MoveManualF }, + {new StateTransition(ProcessState.MoveManual, Command.JoystickDown), ProcessState.MoveManualB }, + {new StateTransition(ProcessState.MoveManual, Command.JoystickLeft), ProcessState.MoveManualL }, + {new StateTransition(ProcessState.MoveManual, Command.JoystickRight), ProcessState.MoveManualR }, + {new StateTransition(ProcessState.MoveManual, Command.JoystickCenter), ProcessState.StopManual }, + + {new StateTransition(ProcessState.StopManual,Command.JoystickUp), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.StopManual,Command.JoystickDown), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.StopManual,Command.JoystickLeft), ProcessState.ResumeMoveManual }, + {new StateTransition(ProcessState.StopManual,Command.JoystickRight), ProcessState.ResumeMoveManual }, + + {new StateTransition(ProcessState.ResumeMoveManual, Command.none),ProcessState.MoveManual }, + + {new StateTransition(ProcessState.MoveManual, Command.autoMode), ProcessState.Auto }, + + }; + } + + public ProcessState GetNext(Command command) { + StateTransition transition = new StateTransition(CurrentState, command); + ProcessState nextState; + if (!transitions.TryGetValue(transition, out nextState)) + throw new Exception("Invalid transition: " + CurrentState + " -> " + command); + return nextState; + } + + public ProcessState MoveNext(Command command) { + CurrentState = GetNext(command); + return CurrentState; + } + + } +} From b96cd7582f6d59a43e8c94ca831e3545f673b97e Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 16 Dec 2022 15:59:27 +0100 Subject: [PATCH 2/2] add present counter, add state app_manual and auto --- ADIS_Sumo/Sumo/Application.c | 53 +++++++++++++++++++++++++++++++++++- ADIS_Sumo/Sumo/LineFollow.c | 2 +- ADIS_Sumo/Sumo/Maze.c | 10 +++++++ ADIS_Sumo/Sumo/Maze.h | 3 ++ ADIS_Sumo/Sumo/Reflectance.c | 2 +- 5 files changed, 67 insertions(+), 3 deletions(-) diff --git a/ADIS_Sumo/Sumo/Application.c b/ADIS_Sumo/Sumo/Application.c index 7e7df9b..6d1d187 100644 --- a/ADIS_Sumo/Sumo/Application.c +++ b/ADIS_Sumo/Sumo/Application.c @@ -163,7 +163,9 @@ typedef enum { #if PL_CONFIG_APP_SUMO APP_STATE_RUN_SUMO, /* Sumo fight */ #endif - APP_STATE_IDLE + APP_STATE_IDLE, + APP_STATE_MANUAL_MOVE, + APP_STATE_AUTO, } AppStateType; static AppStateType appState = APP_STATE_STARTUP; @@ -211,6 +213,8 @@ static unsigned char *AppStateString(AppStateType state) { static void StateMachine(bool buttonPress) { #if PL_CONFIG_USE_LINE_SENSOR static uint8_t cnt; + static uint8_t mazeFailure; + static uint8_t presentCnt; #endif // TODO: send appstate via Mqtt switch (appState) { @@ -357,6 +361,43 @@ static void StateMachine(bool buttonPress) { } break; #endif + case APP_STATE_MANUAL_MOVE: + if(REF_GetLineKind(REF_LINE_KIND_MODE_MAZE) == REF_LINE_STRAIGHT){ + // send to mqtt AUTO + SHELL_SendString((unsigned char*)"AUTO!!!\r\n"); + appState = APP_STATE_AUTO; + mazeFailure = 0; + MAZE_ResetPresentCount(); + presentCnt = MAZE_GetPresentCount(); + MAZE_ClearSolution(); + LF_StartFollowing(); + } + break; + case APP_STATE_AUTO: + if(!LF_IsFollowing() && MAZE_IsSolved()){ + //done + SHELL_SendString((unsigned char*)"MAZE: done, stopped!!!\r\n"); + appState = APP_STATE_IDLE; + }else if(!LF_IsFollowing() && !MAZE_IsSolved() && mazeFailure < 5){ + // failed + mazeFailure++; + SHELL_SendString((unsigned char*)"MAZE: Failure, stopped OMG!!!\r\n"); + MAZE_ClearSolution(); + DRV_SetSpeed(0, 0); + DRV_SetMode(DRV_MODE_SPEED); + LF_StartFollowing(); + }else if(!LF_IsFollowing() && !MAZE_IsSolved() && mazeFailure >= 5){ + appState = APP_STATE_IDLE; + } + if(MAZE_GetPresentCount() != presentCnt){ + presentCnt = MAZE_GetPresentCount(); + //publish + uint8_t counter[5] = ""; + McuUtility_Num8uToStr(counter, sizeof(counter), presentCnt); + SHELL_SendString((unsigned char*)counter); + SHELL_SendString((unsigned char*)"\r\n"); + } + break; default: break; } /* switch */ @@ -456,6 +497,11 @@ static uint8_t AutoCalibrateReflectance(void) { } #endif +static uint8_t SetManualMode(){ + appState = APP_STATE_MANUAL_MOVE; + return ERR_OK; +} + #if 0 /* do not use this any more, use proper debouncing! */ static void CheckButton(void) { #if PL_HAS_USER_BUTTON @@ -1011,6 +1057,8 @@ static uint8_t APP_PrintHelp(const McuShell_StdIOType *io) { #if PL_CONFIG_USE_LINE_SENSOR && PL_HAS_TURN McuShell_SendHelpStr((unsigned char*)" autocalib", (unsigned char*)"Automatically calibrate line sensor\r\n", io->stdOut); #endif + //app manualdrive + McuShell_SendHelpStr((unsigned char*)" manualdrive", (unsigned char*)"Robot can be driven manualy\r\n", io->stdOut); return ERR_OK; } @@ -1048,6 +1096,9 @@ uint8_t APP_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell } else if (McuUtility_strcmp((char*)cmd, (char*)McuShell_CMD_STATUS)==0 || McuUtility_strcmp((char*)cmd, (char*)"app status")==0) { *handled = TRUE; return APP_PrintStatus(io); + }else if(McuUtility_strcmp((char*)cmd, (char*)"app manualdrive")==0){ + *handled = TRUE; + return SetManualMode(); #if PL_CONFIG_USE_LINE_SENSOR && PL_HAS_TURN } else if (McuUtility_strcmp((char*)cmd, (char*)"app autocalib")==0) { *handled = TRUE; diff --git a/ADIS_Sumo/Sumo/LineFollow.c b/ADIS_Sumo/Sumo/LineFollow.c index 4147b35..b79be4a 100644 --- a/ADIS_Sumo/Sumo/LineFollow.c +++ b/ADIS_Sumo/Sumo/LineFollow.c @@ -306,7 +306,7 @@ static void StateMachine(void) { #endif //SHELL_SendString((unsigned char *)"MAZE: Going back to start...\r\n"); //LF_currState = STATE_FOLLOW_SEGMENT; /* go back to start */ - MAZE_ClearSolution(); /* clear solution */ + //MAZE_ClearSolution(); /* clear solution */ LF_currState = STATE_STOP; break; #endif diff --git a/ADIS_Sumo/Sumo/Maze.c b/ADIS_Sumo/Sumo/Maze.c index 6c42b50..740a827 100644 --- a/ADIS_Sumo/Sumo/Maze.c +++ b/ADIS_Sumo/Sumo/Maze.c @@ -51,6 +51,15 @@ static TURN_Kind path[MAZE_MAX_PATH]; static uint8_t pathLength; static bool isSolved = FALSE; static bool useLeftHandOnTheWallRule = TRUE; +static uint8_t presentCounter = 0; + +uint8_t MAZE_ResetPresentCount(){ + presentCounter = 0; +} + +uint8_t MAZE_GetPresentCount(){ + return presentCounter; +} bool MAZE_IsLeftHandRule(void) { return useLeftHandOnTheWallRule; @@ -207,6 +216,7 @@ uint8_t MAZE_EvaluteTurn(bool *finished, bool *deadEndGoBw) { } #endif TURN_Turn(turn, NULL); /* make turn */ + presentCounter++; MAZE_AddPath(turn); MAZE_SimplifyPath(); return ERR_OK; /* turn finished */ diff --git a/ADIS_Sumo/Sumo/Maze.h b/ADIS_Sumo/Sumo/Maze.h index 64e1b06..bc7c9ad 100644 --- a/ADIS_Sumo/Sumo/Maze.h +++ b/ADIS_Sumo/Sumo/Maze.h @@ -11,6 +11,9 @@ #if PL_CONFIG_APP_LINE_MAZE #include "Turn.h" +uint8_t MAZE_ResetPresentCount(); + +uint8_t MAZE_GetPresentCount(); /*! * \brief Adds a new path while going forward through the maze * \param kind New path to be added diff --git a/ADIS_Sumo/Sumo/Reflectance.c b/ADIS_Sumo/Sumo/Reflectance.c index b6ba089..eec3c92 100644 --- a/ADIS_Sumo/Sumo/Reflectance.c +++ b/ADIS_Sumo/Sumo/Reflectance.c @@ -754,7 +754,7 @@ void REF_Init(void) { }; REF_Sensor.isEnabled = true; - REF_Sensor.savePower = false; /* turn off, as this extends the ref sensor task time by around 200 us */ + REF_Sensor.savePower = true; /* turn off, as this extends the ref sensor task time by around 200 us */ McuGPIO_GetDefaultConfig(&gpioConfig); /* IR on/off: PTD1, high active */ gpioConfig.hw.gpio = GPIOD;