From 99529055797bc18596dd21f15c85059f53d48c99 Mon Sep 17 00:00:00 2001 From: Andreas Merkle Date: Thu, 2 Nov 2023 13:10:01 +0100 Subject: [PATCH] Application specific HAL libraries created. --- lib/{HALSim => HALConvoyLeaderSim}/Board.cpp | 0 lib/{HALSim => HALConvoyLeaderSim}/Board.h | 0 lib/HALConvoyLeaderSim/library.json | 21 + .../Board.cpp | 0 .../Board.h | 0 lib/HALConvoyLeaderTarget/library.json | 23 + lib/HALLineFollowerSim/Board.cpp | 143 +++++++ lib/HALLineFollowerSim/Board.h | 394 ++++++++++++++++++ lib/HALLineFollowerSim/library.json | 21 + lib/HALLineFollowerTarget/Board.cpp | 83 ++++ lib/HALLineFollowerTarget/Board.h | 286 +++++++++++++ lib/HALLineFollowerTarget/library.json | 23 + lib/HALRemoteControlSim/Board.cpp | 143 +++++++ lib/HALRemoteControlSim/Board.h | 394 ++++++++++++++++++ lib/HALRemoteControlSim/library.json | 21 + lib/HALRemoteControlTarget/Board.cpp | 83 ++++ lib/HALRemoteControlTarget/Board.h | 286 +++++++++++++ lib/HALRemoteControlTarget/library.json | 23 + platformio.ini | 150 +++++-- 19 files changed, 2064 insertions(+), 30 deletions(-) rename lib/{HALSim => HALConvoyLeaderSim}/Board.cpp (100%) rename lib/{HALSim => HALConvoyLeaderSim}/Board.h (100%) create mode 100644 lib/HALConvoyLeaderSim/library.json rename lib/{HALTarget => HALConvoyLeaderTarget}/Board.cpp (100%) rename lib/{HALTarget => HALConvoyLeaderTarget}/Board.h (100%) create mode 100644 lib/HALConvoyLeaderTarget/library.json create mode 100644 lib/HALLineFollowerSim/Board.cpp create mode 100644 lib/HALLineFollowerSim/Board.h create mode 100644 lib/HALLineFollowerSim/library.json create mode 100644 lib/HALLineFollowerTarget/Board.cpp create mode 100644 lib/HALLineFollowerTarget/Board.h create mode 100644 lib/HALLineFollowerTarget/library.json create mode 100644 lib/HALRemoteControlSim/Board.cpp create mode 100644 lib/HALRemoteControlSim/Board.h create mode 100644 lib/HALRemoteControlSim/library.json create mode 100644 lib/HALRemoteControlTarget/Board.cpp create mode 100644 lib/HALRemoteControlTarget/Board.h create mode 100644 lib/HALRemoteControlTarget/library.json diff --git a/lib/HALSim/Board.cpp b/lib/HALConvoyLeaderSim/Board.cpp similarity index 100% rename from lib/HALSim/Board.cpp rename to lib/HALConvoyLeaderSim/Board.cpp diff --git a/lib/HALSim/Board.h b/lib/HALConvoyLeaderSim/Board.h similarity index 100% rename from lib/HALSim/Board.h rename to lib/HALConvoyLeaderSim/Board.h diff --git a/lib/HALConvoyLeaderSim/library.json b/lib/HALConvoyLeaderSim/library.json new file mode 100644 index 00000000..e3386ecf --- /dev/null +++ b/lib/HALConvoyLeaderSim/library.json @@ -0,0 +1,21 @@ +{ + "name": "HALConvoyLeaderSim", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALSim" + }, { + "name": "Webots" + }], + "frameworks": "*", + "platforms": "*" +} \ No newline at end of file diff --git a/lib/HALTarget/Board.cpp b/lib/HALConvoyLeaderTarget/Board.cpp similarity index 100% rename from lib/HALTarget/Board.cpp rename to lib/HALConvoyLeaderTarget/Board.cpp diff --git a/lib/HALTarget/Board.h b/lib/HALConvoyLeaderTarget/Board.h similarity index 100% rename from lib/HALTarget/Board.h rename to lib/HALConvoyLeaderTarget/Board.h diff --git a/lib/HALConvoyLeaderTarget/library.json b/lib/HALConvoyLeaderTarget/library.json new file mode 100644 index 00000000..5177e08f --- /dev/null +++ b/lib/HALConvoyLeaderTarget/library.json @@ -0,0 +1,23 @@ +{ + "name": "HALConvoyLeaderTarget", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALTarget" + }, { + "owner": "pololu", + "name": "Zumo32U4", + "version": "^2.0.1" + }], + "frameworks": "arduino", + "platforms": "*" +} \ No newline at end of file diff --git a/lib/HALLineFollowerSim/Board.cpp b/lib/HALLineFollowerSim/Board.cpp new file mode 100644 index 00000000..7eb57d23 --- /dev/null +++ b/lib/HALLineFollowerSim/Board.cpp @@ -0,0 +1,143 @@ +/* MIT License + * + * Copyright (c) 2019 - 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The simulation robot board realization. + * @author Andreas Merkle + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/* Name of the speaker in the robot simulation. */ +const char* Board::SPEAKER_NAME = "robot_speaker"; + +/* Name of the display in the robot simulation. */ +const char* Board::DISPLAY_NAME = "robot_display"; + +/* Name of the left motor in the robot simulation. */ +const char* Board::LEFT_MOTOR_NAME = "motor_left"; + +/* Name of the right motor in the robot simulation. */ +const char* Board::RIGHT_MOTOR_NAME = "motor_right"; + +/* Name of the infrared emitter 0 in the robot simulation. */ +const char* Board::EMITTER_0_NAME = "emitter_l"; + +/* Name of the infrared emitter 1 in the robot simulation. */ +const char* Board::EMITTER_1_NAME = "emitter_lm"; + +/* Name of the infrared emitter 2 in the robot simulation. */ +const char* Board::EMITTER_2_NAME = "emitter_m"; + +/* Name of the infrared emitter 3 in the robot simulation. */ +const char* Board::EMITTER_3_NAME = "emitter_rm"; + +/* Name of the infrared emitter 4 in the robot simulation. */ +const char* Board::EMITTER_4_NAME = "emitter_r"; + +/** Name of the position sensor of the left motor in the robot simulation. */ +const char* Board::POS_SENSOR_LEFT_NAME = "position_sensor_left"; + +/** Name of the position sensor of the right motor in the robot simulation. */ +const char* Board::POS_SENSOR_RIGHT_NAME = "position_sensor_right"; + +/* Name of the light sensor 0 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_0_NAME = "lightsensor_l"; + +/* Name of the light sensor 1 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_1_NAME = "lightsensor_lm"; + +/* Name of the light sensor 2 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_2_NAME = "lightsensor_m"; + +/* Name of the light sensor 3 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_3_NAME = "lightsensor_rm"; + +/* Name of the light sensor 4 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_4_NAME = "lightsensor_r"; + +/* Name of the red LED in the robot simulation. */ +const char* Board::LED_RED_NAME = "led_red"; + +/* Name of the yellow LED in the robot simulation. */ +const char* Board::LED_YELLOW_NAME = "led_yellow"; + +/* Name of the green LED in the robot simulation. */ +const char* Board::LED_GREEN_NAME = "led_green"; + +/* Name of the front left proximity sensor in the robot simulation. */ +const char* Board::PROXIMITY_SENSOR_FRONT_LEFT_NAME = "proxim_sensor_fl"; + +/* Name of the front right proximity sensor in the robot simulation. */ +const char* Board::PROXIMITY_SENSOR_FRONT_RIGHT_NAME = "proxim_sensor_fr"; + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +void Board::init() +{ + m_encoders.init(); + m_keyboard.init(); + m_lineSensors.init(); + m_motors.init(); + m_proximitySensors.initFrontSensor(); +} + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALLineFollowerSim/Board.h b/lib/HALLineFollowerSim/Board.h new file mode 100644 index 00000000..ccb9ef43 --- /dev/null +++ b/lib/HALLineFollowerSim/Board.h @@ -0,0 +1,394 @@ +/* MIT License + * + * Copyright (c) 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The simulation robot board realization. + * @author Andreas Merkle + * + * @addtogroup HALSim + * + * @{ + */ +#ifndef BOARD_H +#define BOARD_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** + * The concrete simulation robot board. + */ +class Board : public IBoard +{ +public: + /** + * Get board instance. + * + * @return Board instance + */ + static Board& getInstance() + { + static Board instance; /* idiom */ + + return instance; + } + + /** + * Initialize the hardware. + */ + void init() final; + + /** + * Get button A driver. + * + * @return Button A driver. + */ + IButton& getButtonA() final + { + return m_buttonA; + } + + /** + * Get button B driver. + * + * @return Button B driver. + */ + IButton& getButtonB() final + { + return m_buttonB; + } + + /** + * Get button C driver. + * + * @return Button C driver. + */ + IButton& getButtonC() final + { + return m_buttonC; + } + + /** + * Get buzzer driver. + * + * @return Buzzer driver. + */ + IBuzzer& getBuzzer() final + { + return m_buzzer; + } + + /** + * Get LCD driver. + * + * @return LCD driver. + */ + IDisplay& getDisplay() final + { + return m_display; + } + + /** + * Get encoders. + * + * @return Encoders driver. + */ + IEncoders& getEncoders() final + { + return m_encoders; + } + + /** + * Get line sensors driver. + * + * @return Line sensor driver. + */ + ILineSensors& getLineSensors() final + { + return m_lineSensors; + } + + /** + * Get motor driver. + * + * @return Motor driver. + */ + IMotors& getMotors() final + { + return m_motors; + } + + /** + * Get red LED driver. + * + * @return Red LED driver. + */ + ILed& getRedLed() final + { + return m_ledRed; + } + + /** + * Get yellow LED driver. + * + * @return Yellow LED driver. + */ + ILed& getYellowLed() final + { + return m_ledYellow; + } + + /** + * Get green LED driver. + * + * @return Green LED driver. + */ + ILed& getGreenLed() final + { + return m_ledGreen; + } + + /** + * Get proximity sensors driver. + * + * @return Proximity sensors driver + */ + IProximitySensors& getProximitySensors() final + { + return m_proximitySensors; + } + +protected: +private: + /** Name of the speaker in the robot simulation. */ + static const char* SPEAKER_NAME; + + /** Name of the display in the robot simulation. */ + static const char* DISPLAY_NAME; + + /** Name of the left motor in the robot simulation. */ + static const char* LEFT_MOTOR_NAME; + + /** Name of the right motor in the robot simulation. */ + static const char* RIGHT_MOTOR_NAME; + + /** Name of the infrared emitter 0 in the robot simulation. */ + static const char* EMITTER_0_NAME; + + /** Name of the infrared emitter 1 in the robot simulation. */ + static const char* EMITTER_1_NAME; + + /** Name of the infrared emitter 2 in the robot simulation. */ + static const char* EMITTER_2_NAME; + + /** Name of the infrared emitter 3 in the robot simulation. */ + static const char* EMITTER_3_NAME; + + /** Name of the infrared emitter 4 in the robot simulation. */ + static const char* EMITTER_4_NAME; + + /** Name of the position sensor of the left motor in the robot simulation. */ + static const char* POS_SENSOR_LEFT_NAME; + + /** Name of the position sensor of the right motor in the robot simulation. */ + static const char* POS_SENSOR_RIGHT_NAME; + + /** Name of the light sensor 0 in the robot simulation. */ + static const char* LIGHT_SENSOR_0_NAME; + + /** Name of the light sensor 1 in the robot simulation. */ + static const char* LIGHT_SENSOR_1_NAME; + + /** Name of the light sensor 2 in the robot simulation. */ + static const char* LIGHT_SENSOR_2_NAME; + + /** Name of the light sensor 3 in the robot simulation. */ + static const char* LIGHT_SENSOR_3_NAME; + + /** Name of the light sensor 4 in the robot simulation. */ + static const char* LIGHT_SENSOR_4_NAME; + + /** Name of the red LED in the robot simulation. */ + static const char* LED_RED_NAME; + + /** Name of the yellow LED in the robot simulation. */ + static const char* LED_YELLOW_NAME; + + /** Name of the green LED in the robot simulation. */ + static const char* LED_GREEN_NAME; + + /** Name of the front proximity sensor in the robot simulation. */ + static const char* PROXIMITY_SENSOR_FRONT_LEFT_NAME; + + /** Name of the front right proximity sensor in the robot simulation. */ + static const char* PROXIMITY_SENSOR_FRONT_RIGHT_NAME; + + /** Simulated roboter instance. */ + webots::Robot m_robot; + + /** Simulation time handler */ + SimTime m_simTime; + + /** Own keyboard that wraps the webots keyboard. */ + Keyboard m_keyboard; + + /** Button A driver */ + ButtonA m_buttonA; + + /** Button B driver */ + ButtonB m_buttonB; + + /** Button C driver */ + ButtonC m_buttonC; + + /** Buzzer driver */ + Buzzer m_buzzer; + + /** Display driver */ + Display m_display; + + /** Encoders driver */ + Encoders m_encoders; + + /** Line sensors driver */ + LineSensors m_lineSensors; + + /** Motors driver */ + Motors m_motors; + + /** Red LED driver */ + LedRed m_ledRed; + + /** Red LED driver */ + LedYellow m_ledYellow; + + /** Red LED driver */ + LedGreen m_ledGreen; + + /** Proximity sensors */ + ProximitySensors m_proximitySensors; + + /** + * Constructs the concrete board. + */ + Board() : + IBoard(), + m_robot(), + m_simTime(m_robot), + m_keyboard(m_simTime, m_robot.getKeyboard()), + m_buttonA(m_keyboard), + m_buttonB(m_keyboard), + m_buttonC(m_keyboard), + m_buzzer(m_robot.getSpeaker(SPEAKER_NAME)), + m_display(m_robot.getDisplay(DISPLAY_NAME)), + m_encoders(m_simTime, m_robot.getPositionSensor(POS_SENSOR_LEFT_NAME), + m_robot.getPositionSensor(POS_SENSOR_RIGHT_NAME)), + m_lineSensors(m_simTime, m_robot.getEmitter(EMITTER_0_NAME), m_robot.getEmitter(EMITTER_1_NAME), + m_robot.getEmitter(EMITTER_2_NAME), m_robot.getEmitter(EMITTER_3_NAME), + m_robot.getEmitter(EMITTER_4_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_0_NAME), + m_robot.getDistanceSensor(LIGHT_SENSOR_1_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_2_NAME), + m_robot.getDistanceSensor(LIGHT_SENSOR_3_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_4_NAME)), + m_motors(m_robot.getMotor(LEFT_MOTOR_NAME), m_robot.getMotor(RIGHT_MOTOR_NAME)), + m_ledRed(m_robot.getLED(LED_RED_NAME)), + m_ledYellow(m_robot.getLED(LED_YELLOW_NAME)), + m_ledGreen(m_robot.getLED(LED_GREEN_NAME)), + m_proximitySensors(m_simTime, m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_LEFT_NAME), + m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_RIGHT_NAME)) + { + } + + /** + * Destroys the concrete board. + */ + ~Board() + { + } + + /** + * Get the simulation time handler. + * + * @return Simulation time handler + */ + SimTime& getSimTime() + { + return m_simTime; + } + + /** + * Get the keyboard instance of the simulation. + * + * @return The keyboard. + */ + Keyboard& getKeyboard() + { + return m_keyboard; + } + + /* The main entry needs access to the simulation robot instance. + * But all other application parts shall have no access, which is + * solved by this friend. + */ + friend int main(int argc, char** argv); +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BOARD_H */ +/** @} */ diff --git a/lib/HALLineFollowerSim/library.json b/lib/HALLineFollowerSim/library.json new file mode 100644 index 00000000..1db98687 --- /dev/null +++ b/lib/HALLineFollowerSim/library.json @@ -0,0 +1,21 @@ +{ + "name": "HALLineFollowerSim", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALSim" + }, { + "name": "Webots" + }], + "frameworks": "*", + "platforms": "*" +} \ No newline at end of file diff --git a/lib/HALLineFollowerTarget/Board.cpp b/lib/HALLineFollowerTarget/Board.cpp new file mode 100644 index 00000000..66721be0 --- /dev/null +++ b/lib/HALLineFollowerTarget/Board.cpp @@ -0,0 +1,83 @@ +/* MIT License + * + * Copyright (c) 2019 - 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The physical robot board realization. + * @author Andreas Merkle + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +void Board::init() +{ + m_encoders.init(); + m_lineSensors.init(); + m_motors.init(); + m_proximitySensors.initFrontSensor(); +} + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALLineFollowerTarget/Board.h b/lib/HALLineFollowerTarget/Board.h new file mode 100644 index 00000000..de9e336e --- /dev/null +++ b/lib/HALLineFollowerTarget/Board.h @@ -0,0 +1,286 @@ +/* MIT License + * + * Copyright (c) 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The physical robot board realization. + * @author Andreas Merkle + * + * @addtogroup HALTarget + * + * @{ + */ +#ifndef BOARD_H +#define BOARD_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** + * The concrete physical board. + */ +class Board : public IBoard +{ +public: + + /** + * Get board instance. + * + * @return Board instance + */ + static Board& getInstance() + { + static Board instance; /* idiom */ + + return instance; + } + + /** + * Initialize the hardware. + */ + void init() final; + + /** + * Get button A driver. + * + * @return Button A driver. + */ + IButton& getButtonA() final + { + return m_buttonA; + } + + /** + * Get button B driver. + * + * @return Button B driver. + */ + IButton& getButtonB() final + { + return m_buttonB; + } + + /** + * Get button C driver. + * + * @return Button C driver. + */ + IButton& getButtonC() final + { + return m_buttonC; + } + + /** + * Get buzzer driver. + * + * @return Buzzer driver. + */ + IBuzzer& getBuzzer() final + { + return m_buzzer; + } + + /** + * Get LCD driver. + * + * @return LCD driver. + */ + IDisplay& getDisplay() final + { + return m_display; + } + + /** + * Get encoders. + * + * @return Encoders driver. + */ + IEncoders& getEncoders() final + { + return m_encoders; + } + + /** + * Get line sensors driver. + * + * @return Line sensor driver. + */ + ILineSensors& getLineSensors() final + { + return m_lineSensors; + } + + /** + * Get motor driver. + * + * @return Motor driver. + */ + IMotors& getMotors() final + { + return m_motors; + } + + /** + * Get red LED driver. + * + * @return Red LED driver. + */ + ILed& getRedLed() final + { + return m_ledRed; + } + + /** + * Get yellow LED driver. + * + * @return Yellow LED driver. + */ + ILed& getYellowLed() final + { + return m_ledYellow; + } + + /** + * Get green LED driver. + * + * @return Green LED driver. + */ + ILed& getGreenLed() final + { + return m_ledGreen; + } + + /** + * Get proximity sensors driver. + * + * @return Proximity sensors driver + */ + IProximitySensors& getProximitySensors() final + { + return m_proximitySensors; + } + +protected: + +private: + + /** Button A driver */ + ButtonA m_buttonA; + + /** Button B driver */ + ButtonB m_buttonB; + + /** Button C driver */ + ButtonC m_buttonC; + + /** Buzzer driver */ + Buzzer m_buzzer; + + /** Display driver */ + Display m_display; + + /** Encoders driver */ + Encoders m_encoders; + + /** Line sensors driver */ + LineSensors m_lineSensors; + + /** Motors driver */ + Motors m_motors; + + /** Red LED driver */ + LedRed m_ledRed; + + /** Red LED driver */ + LedYellow m_ledYellow; + + /** Red LED driver */ + LedGreen m_ledGreen; + + /** Proximity sensors */ + ProximitySensors m_proximitySensors; + + /** + * Constructs the concrete board. + */ + Board() : + IBoard(), + m_buttonA(), + m_buttonB(), + m_buttonC(), + m_buzzer(), + m_display(), + m_encoders(), + m_lineSensors(), + m_motors(), + m_ledRed(), + m_ledYellow(), + m_ledGreen(), + m_proximitySensors() + { + } + + /** + * Destroys the concrete board. + */ + ~Board() + { + } + +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BOARD_H */ +/** @} */ diff --git a/lib/HALLineFollowerTarget/library.json b/lib/HALLineFollowerTarget/library.json new file mode 100644 index 00000000..00083a5d --- /dev/null +++ b/lib/HALLineFollowerTarget/library.json @@ -0,0 +1,23 @@ +{ + "name": "HALLineFollowerTarget", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALTarget" + }, { + "owner": "pololu", + "name": "Zumo32U4", + "version": "^2.0.1" + }], + "frameworks": "arduino", + "platforms": "*" +} \ No newline at end of file diff --git a/lib/HALRemoteControlSim/Board.cpp b/lib/HALRemoteControlSim/Board.cpp new file mode 100644 index 00000000..7eb57d23 --- /dev/null +++ b/lib/HALRemoteControlSim/Board.cpp @@ -0,0 +1,143 @@ +/* MIT License + * + * Copyright (c) 2019 - 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The simulation robot board realization. + * @author Andreas Merkle + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/* Name of the speaker in the robot simulation. */ +const char* Board::SPEAKER_NAME = "robot_speaker"; + +/* Name of the display in the robot simulation. */ +const char* Board::DISPLAY_NAME = "robot_display"; + +/* Name of the left motor in the robot simulation. */ +const char* Board::LEFT_MOTOR_NAME = "motor_left"; + +/* Name of the right motor in the robot simulation. */ +const char* Board::RIGHT_MOTOR_NAME = "motor_right"; + +/* Name of the infrared emitter 0 in the robot simulation. */ +const char* Board::EMITTER_0_NAME = "emitter_l"; + +/* Name of the infrared emitter 1 in the robot simulation. */ +const char* Board::EMITTER_1_NAME = "emitter_lm"; + +/* Name of the infrared emitter 2 in the robot simulation. */ +const char* Board::EMITTER_2_NAME = "emitter_m"; + +/* Name of the infrared emitter 3 in the robot simulation. */ +const char* Board::EMITTER_3_NAME = "emitter_rm"; + +/* Name of the infrared emitter 4 in the robot simulation. */ +const char* Board::EMITTER_4_NAME = "emitter_r"; + +/** Name of the position sensor of the left motor in the robot simulation. */ +const char* Board::POS_SENSOR_LEFT_NAME = "position_sensor_left"; + +/** Name of the position sensor of the right motor in the robot simulation. */ +const char* Board::POS_SENSOR_RIGHT_NAME = "position_sensor_right"; + +/* Name of the light sensor 0 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_0_NAME = "lightsensor_l"; + +/* Name of the light sensor 1 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_1_NAME = "lightsensor_lm"; + +/* Name of the light sensor 2 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_2_NAME = "lightsensor_m"; + +/* Name of the light sensor 3 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_3_NAME = "lightsensor_rm"; + +/* Name of the light sensor 4 in the robot simulation. */ +const char* Board::LIGHT_SENSOR_4_NAME = "lightsensor_r"; + +/* Name of the red LED in the robot simulation. */ +const char* Board::LED_RED_NAME = "led_red"; + +/* Name of the yellow LED in the robot simulation. */ +const char* Board::LED_YELLOW_NAME = "led_yellow"; + +/* Name of the green LED in the robot simulation. */ +const char* Board::LED_GREEN_NAME = "led_green"; + +/* Name of the front left proximity sensor in the robot simulation. */ +const char* Board::PROXIMITY_SENSOR_FRONT_LEFT_NAME = "proxim_sensor_fl"; + +/* Name of the front right proximity sensor in the robot simulation. */ +const char* Board::PROXIMITY_SENSOR_FRONT_RIGHT_NAME = "proxim_sensor_fr"; + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +void Board::init() +{ + m_encoders.init(); + m_keyboard.init(); + m_lineSensors.init(); + m_motors.init(); + m_proximitySensors.initFrontSensor(); +} + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALRemoteControlSim/Board.h b/lib/HALRemoteControlSim/Board.h new file mode 100644 index 00000000..ccb9ef43 --- /dev/null +++ b/lib/HALRemoteControlSim/Board.h @@ -0,0 +1,394 @@ +/* MIT License + * + * Copyright (c) 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The simulation robot board realization. + * @author Andreas Merkle + * + * @addtogroup HALSim + * + * @{ + */ +#ifndef BOARD_H +#define BOARD_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** + * The concrete simulation robot board. + */ +class Board : public IBoard +{ +public: + /** + * Get board instance. + * + * @return Board instance + */ + static Board& getInstance() + { + static Board instance; /* idiom */ + + return instance; + } + + /** + * Initialize the hardware. + */ + void init() final; + + /** + * Get button A driver. + * + * @return Button A driver. + */ + IButton& getButtonA() final + { + return m_buttonA; + } + + /** + * Get button B driver. + * + * @return Button B driver. + */ + IButton& getButtonB() final + { + return m_buttonB; + } + + /** + * Get button C driver. + * + * @return Button C driver. + */ + IButton& getButtonC() final + { + return m_buttonC; + } + + /** + * Get buzzer driver. + * + * @return Buzzer driver. + */ + IBuzzer& getBuzzer() final + { + return m_buzzer; + } + + /** + * Get LCD driver. + * + * @return LCD driver. + */ + IDisplay& getDisplay() final + { + return m_display; + } + + /** + * Get encoders. + * + * @return Encoders driver. + */ + IEncoders& getEncoders() final + { + return m_encoders; + } + + /** + * Get line sensors driver. + * + * @return Line sensor driver. + */ + ILineSensors& getLineSensors() final + { + return m_lineSensors; + } + + /** + * Get motor driver. + * + * @return Motor driver. + */ + IMotors& getMotors() final + { + return m_motors; + } + + /** + * Get red LED driver. + * + * @return Red LED driver. + */ + ILed& getRedLed() final + { + return m_ledRed; + } + + /** + * Get yellow LED driver. + * + * @return Yellow LED driver. + */ + ILed& getYellowLed() final + { + return m_ledYellow; + } + + /** + * Get green LED driver. + * + * @return Green LED driver. + */ + ILed& getGreenLed() final + { + return m_ledGreen; + } + + /** + * Get proximity sensors driver. + * + * @return Proximity sensors driver + */ + IProximitySensors& getProximitySensors() final + { + return m_proximitySensors; + } + +protected: +private: + /** Name of the speaker in the robot simulation. */ + static const char* SPEAKER_NAME; + + /** Name of the display in the robot simulation. */ + static const char* DISPLAY_NAME; + + /** Name of the left motor in the robot simulation. */ + static const char* LEFT_MOTOR_NAME; + + /** Name of the right motor in the robot simulation. */ + static const char* RIGHT_MOTOR_NAME; + + /** Name of the infrared emitter 0 in the robot simulation. */ + static const char* EMITTER_0_NAME; + + /** Name of the infrared emitter 1 in the robot simulation. */ + static const char* EMITTER_1_NAME; + + /** Name of the infrared emitter 2 in the robot simulation. */ + static const char* EMITTER_2_NAME; + + /** Name of the infrared emitter 3 in the robot simulation. */ + static const char* EMITTER_3_NAME; + + /** Name of the infrared emitter 4 in the robot simulation. */ + static const char* EMITTER_4_NAME; + + /** Name of the position sensor of the left motor in the robot simulation. */ + static const char* POS_SENSOR_LEFT_NAME; + + /** Name of the position sensor of the right motor in the robot simulation. */ + static const char* POS_SENSOR_RIGHT_NAME; + + /** Name of the light sensor 0 in the robot simulation. */ + static const char* LIGHT_SENSOR_0_NAME; + + /** Name of the light sensor 1 in the robot simulation. */ + static const char* LIGHT_SENSOR_1_NAME; + + /** Name of the light sensor 2 in the robot simulation. */ + static const char* LIGHT_SENSOR_2_NAME; + + /** Name of the light sensor 3 in the robot simulation. */ + static const char* LIGHT_SENSOR_3_NAME; + + /** Name of the light sensor 4 in the robot simulation. */ + static const char* LIGHT_SENSOR_4_NAME; + + /** Name of the red LED in the robot simulation. */ + static const char* LED_RED_NAME; + + /** Name of the yellow LED in the robot simulation. */ + static const char* LED_YELLOW_NAME; + + /** Name of the green LED in the robot simulation. */ + static const char* LED_GREEN_NAME; + + /** Name of the front proximity sensor in the robot simulation. */ + static const char* PROXIMITY_SENSOR_FRONT_LEFT_NAME; + + /** Name of the front right proximity sensor in the robot simulation. */ + static const char* PROXIMITY_SENSOR_FRONT_RIGHT_NAME; + + /** Simulated roboter instance. */ + webots::Robot m_robot; + + /** Simulation time handler */ + SimTime m_simTime; + + /** Own keyboard that wraps the webots keyboard. */ + Keyboard m_keyboard; + + /** Button A driver */ + ButtonA m_buttonA; + + /** Button B driver */ + ButtonB m_buttonB; + + /** Button C driver */ + ButtonC m_buttonC; + + /** Buzzer driver */ + Buzzer m_buzzer; + + /** Display driver */ + Display m_display; + + /** Encoders driver */ + Encoders m_encoders; + + /** Line sensors driver */ + LineSensors m_lineSensors; + + /** Motors driver */ + Motors m_motors; + + /** Red LED driver */ + LedRed m_ledRed; + + /** Red LED driver */ + LedYellow m_ledYellow; + + /** Red LED driver */ + LedGreen m_ledGreen; + + /** Proximity sensors */ + ProximitySensors m_proximitySensors; + + /** + * Constructs the concrete board. + */ + Board() : + IBoard(), + m_robot(), + m_simTime(m_robot), + m_keyboard(m_simTime, m_robot.getKeyboard()), + m_buttonA(m_keyboard), + m_buttonB(m_keyboard), + m_buttonC(m_keyboard), + m_buzzer(m_robot.getSpeaker(SPEAKER_NAME)), + m_display(m_robot.getDisplay(DISPLAY_NAME)), + m_encoders(m_simTime, m_robot.getPositionSensor(POS_SENSOR_LEFT_NAME), + m_robot.getPositionSensor(POS_SENSOR_RIGHT_NAME)), + m_lineSensors(m_simTime, m_robot.getEmitter(EMITTER_0_NAME), m_robot.getEmitter(EMITTER_1_NAME), + m_robot.getEmitter(EMITTER_2_NAME), m_robot.getEmitter(EMITTER_3_NAME), + m_robot.getEmitter(EMITTER_4_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_0_NAME), + m_robot.getDistanceSensor(LIGHT_SENSOR_1_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_2_NAME), + m_robot.getDistanceSensor(LIGHT_SENSOR_3_NAME), m_robot.getDistanceSensor(LIGHT_SENSOR_4_NAME)), + m_motors(m_robot.getMotor(LEFT_MOTOR_NAME), m_robot.getMotor(RIGHT_MOTOR_NAME)), + m_ledRed(m_robot.getLED(LED_RED_NAME)), + m_ledYellow(m_robot.getLED(LED_YELLOW_NAME)), + m_ledGreen(m_robot.getLED(LED_GREEN_NAME)), + m_proximitySensors(m_simTime, m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_LEFT_NAME), + m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_RIGHT_NAME)) + { + } + + /** + * Destroys the concrete board. + */ + ~Board() + { + } + + /** + * Get the simulation time handler. + * + * @return Simulation time handler + */ + SimTime& getSimTime() + { + return m_simTime; + } + + /** + * Get the keyboard instance of the simulation. + * + * @return The keyboard. + */ + Keyboard& getKeyboard() + { + return m_keyboard; + } + + /* The main entry needs access to the simulation robot instance. + * But all other application parts shall have no access, which is + * solved by this friend. + */ + friend int main(int argc, char** argv); +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BOARD_H */ +/** @} */ diff --git a/lib/HALRemoteControlSim/library.json b/lib/HALRemoteControlSim/library.json new file mode 100644 index 00000000..29af2800 --- /dev/null +++ b/lib/HALRemoteControlSim/library.json @@ -0,0 +1,21 @@ +{ + "name": "HALRemoteControlSim", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALSim" + }, { + "name": "Webots" + }], + "frameworks": "*", + "platforms": "*" +} \ No newline at end of file diff --git a/lib/HALRemoteControlTarget/Board.cpp b/lib/HALRemoteControlTarget/Board.cpp new file mode 100644 index 00000000..66721be0 --- /dev/null +++ b/lib/HALRemoteControlTarget/Board.cpp @@ -0,0 +1,83 @@ +/* MIT License + * + * Copyright (c) 2019 - 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The physical robot board realization. + * @author Andreas Merkle + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +void Board::init() +{ + m_encoders.init(); + m_lineSensors.init(); + m_motors.init(); + m_proximitySensors.initFrontSensor(); +} + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALRemoteControlTarget/Board.h b/lib/HALRemoteControlTarget/Board.h new file mode 100644 index 00000000..de9e336e --- /dev/null +++ b/lib/HALRemoteControlTarget/Board.h @@ -0,0 +1,286 @@ +/* MIT License + * + * Copyright (c) 2023 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief The physical robot board realization. + * @author Andreas Merkle + * + * @addtogroup HALTarget + * + * @{ + */ +#ifndef BOARD_H +#define BOARD_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** + * The concrete physical board. + */ +class Board : public IBoard +{ +public: + + /** + * Get board instance. + * + * @return Board instance + */ + static Board& getInstance() + { + static Board instance; /* idiom */ + + return instance; + } + + /** + * Initialize the hardware. + */ + void init() final; + + /** + * Get button A driver. + * + * @return Button A driver. + */ + IButton& getButtonA() final + { + return m_buttonA; + } + + /** + * Get button B driver. + * + * @return Button B driver. + */ + IButton& getButtonB() final + { + return m_buttonB; + } + + /** + * Get button C driver. + * + * @return Button C driver. + */ + IButton& getButtonC() final + { + return m_buttonC; + } + + /** + * Get buzzer driver. + * + * @return Buzzer driver. + */ + IBuzzer& getBuzzer() final + { + return m_buzzer; + } + + /** + * Get LCD driver. + * + * @return LCD driver. + */ + IDisplay& getDisplay() final + { + return m_display; + } + + /** + * Get encoders. + * + * @return Encoders driver. + */ + IEncoders& getEncoders() final + { + return m_encoders; + } + + /** + * Get line sensors driver. + * + * @return Line sensor driver. + */ + ILineSensors& getLineSensors() final + { + return m_lineSensors; + } + + /** + * Get motor driver. + * + * @return Motor driver. + */ + IMotors& getMotors() final + { + return m_motors; + } + + /** + * Get red LED driver. + * + * @return Red LED driver. + */ + ILed& getRedLed() final + { + return m_ledRed; + } + + /** + * Get yellow LED driver. + * + * @return Yellow LED driver. + */ + ILed& getYellowLed() final + { + return m_ledYellow; + } + + /** + * Get green LED driver. + * + * @return Green LED driver. + */ + ILed& getGreenLed() final + { + return m_ledGreen; + } + + /** + * Get proximity sensors driver. + * + * @return Proximity sensors driver + */ + IProximitySensors& getProximitySensors() final + { + return m_proximitySensors; + } + +protected: + +private: + + /** Button A driver */ + ButtonA m_buttonA; + + /** Button B driver */ + ButtonB m_buttonB; + + /** Button C driver */ + ButtonC m_buttonC; + + /** Buzzer driver */ + Buzzer m_buzzer; + + /** Display driver */ + Display m_display; + + /** Encoders driver */ + Encoders m_encoders; + + /** Line sensors driver */ + LineSensors m_lineSensors; + + /** Motors driver */ + Motors m_motors; + + /** Red LED driver */ + LedRed m_ledRed; + + /** Red LED driver */ + LedYellow m_ledYellow; + + /** Red LED driver */ + LedGreen m_ledGreen; + + /** Proximity sensors */ + ProximitySensors m_proximitySensors; + + /** + * Constructs the concrete board. + */ + Board() : + IBoard(), + m_buttonA(), + m_buttonB(), + m_buttonC(), + m_buzzer(), + m_display(), + m_encoders(), + m_lineSensors(), + m_motors(), + m_ledRed(), + m_ledYellow(), + m_ledGreen(), + m_proximitySensors() + { + } + + /** + * Destroys the concrete board. + */ + ~Board() + { + } + +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BOARD_H */ +/** @} */ diff --git a/lib/HALRemoteControlTarget/library.json b/lib/HALRemoteControlTarget/library.json new file mode 100644 index 00000000..62907680 --- /dev/null +++ b/lib/HALRemoteControlTarget/library.json @@ -0,0 +1,23 @@ +{ + "name": "HALRemoteControlTarget", + "version": "0.1.0", + "description": "...", + "authors": [{ + "name": "Andreas Merkle", + "email": "web@blue-andi.de", + "url": "https://github.com/BlueAndi", + "maintainer": true + }], + "license": "MIT", + "dependencies": [{ + "name": "HALInterfaces" + }, { + "name": "HALTarget" + }, { + "owner": "pololu", + "name": "Zumo32U4", + "version": "^2.0.1" + }], + "frameworks": "arduino", + "platforms": "*" +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 72261f87..c5029929 100644 --- a/platformio.ini +++ b/platformio.ini @@ -142,6 +142,36 @@ lib_ignore = APPLineFollower APPRemoteControl +; ***************************************************************************** +; Convoy leader application specific HAL for target +; ***************************************************************************** +[hal_app:ConvoyLeaderTarget] +extends = hal:Target +build_flags = + ${hal:Target.build_flags} +lib_deps = + ${hal:Target.lib_deps} + HALConvoyLeaderTarget +lib_ignore = + ${hal:Target.lib_ignore} +extra_scripts = + ${hal:Target.extra_scripts} + +; ***************************************************************************** +; Convoy leader application specific HAL for simulation +; ***************************************************************************** +[hal_app:ConvoyLeaderSim] +extends = hal:Sim +build_flags = + ${hal:Sim.build_flags} +lib_deps = + ${hal:Sim.lib_deps} + HALConvoyLeaderSim +lib_ignore = + ${hal:Sim.lib_ignore} +extra_scripts = + ${hal:Sim.extra_scripts} + ; ***************************************************************************** ; Line follower application ; ***************************************************************************** @@ -155,6 +185,36 @@ lib_ignore = APPConvoyLeader APPRemoteControl +; ***************************************************************************** +; Line follower application specific HAL for target +; ***************************************************************************** +[hal_app:LineFollowerTarget] +extends = hal:Target +build_flags = + ${hal:Target.build_flags} +lib_deps = + ${hal:Target.lib_deps} + HALLineFollowerTarget +lib_ignore = + ${hal:Target.lib_ignore} +extra_scripts = + ${hal:Target.extra_scripts} + +; ***************************************************************************** +; Line follower application specific HAL for simulation +; ***************************************************************************** +[hal_app:LineFollowerSim] +extends = hal:Sim +build_flags = + ${hal:Sim.build_flags} +lib_deps = + ${hal:Sim.lib_deps} + HALLineFollowerSim +lib_ignore = + ${hal:Sim.lib_ignore} +extra_scripts = + ${hal:Sim.extra_scripts} + ; ***************************************************************************** ; Remote control application ; ***************************************************************************** @@ -168,107 +228,137 @@ lib_ignore = APPConvoyLeader APPLineFollower +; ***************************************************************************** +; Remote control application specific HAL for target +; ***************************************************************************** +[hal_app:RemoteControlTarget] +extends = hal:Target +build_flags = + ${hal:Target.build_flags} +lib_deps = + ${hal:Target.lib_deps} + HALRemoteControlTarget +lib_ignore = + ${hal:Target.lib_ignore} +extra_scripts = + ${hal:Target.extra_scripts} + +; ***************************************************************************** +; Remote control application specific HAL for simulation +; ***************************************************************************** +[hal_app:RemoteControlSim] +extends = hal:Sim +build_flags = + ${hal:Sim.build_flags} +lib_deps = + ${hal:Sim.lib_deps} + HALRemoteControlSim +lib_ignore = + ${hal:Sim.lib_ignore} +extra_scripts = + ${hal:Sim.extra_scripts} + ; ***************************************************************************** ; Convoy leader application on target ; ***************************************************************************** [env:ConvoyLeaderTarget] -extends = hal:Target, app:ConvoyLeader, static_check_configuration +extends = hal_app:ConvoyLeaderTarget, app:ConvoyLeader, static_check_configuration build_flags = - ${hal:Target.build_flags} + ${hal_app:ConvoyLeaderTarget.build_flags} ${app:ConvoyLeader.build_flags} lib_deps = - ${hal:Target.lib_deps} + ${hal_app:ConvoyLeaderTarget.lib_deps} ${app:ConvoyLeader.lib_deps} lib_ignore = - ${hal:Target.lib_ignore} + ${hal_app:ConvoyLeaderTarget.lib_ignore} ${app:ConvoyLeader.lib_ignore} extra_scripts = - ${hal:Target.extra_scripts} + ${hal_app:ConvoyLeaderTarget.extra_scripts} ; ***************************************************************************** ; Convoy leader application on simulation ; ***************************************************************************** [env:ConvoyLeaderSim] -extends = hal:Sim, app:ConvoyLeader, static_check_configuration +extends = hal_app:ConvoyLeaderSim, app:ConvoyLeader, static_check_configuration build_flags = - ${hal:Sim.build_flags} + ${hal_app:ConvoyLeaderSim.build_flags} ${app:ConvoyLeader.build_flags} lib_deps = - ${hal:Sim.lib_deps} + ${hal_app:ConvoyLeaderSim.lib_deps} ${app:ConvoyLeader.lib_deps} lib_ignore = - ${hal:Sim.lib_ignore} + ${hal_app:ConvoyLeaderSim.lib_ignore} ${app:ConvoyLeader.lib_ignore} extra_scripts = - ${hal:Sim.extra_scripts} + ${hal_app:ConvoyLeaderSim.extra_scripts} ; ***************************************************************************** ; Line follower application on target ; ***************************************************************************** [env:LineFollowerTarget] -extends = hal:Target, app:LineFollower, static_check_configuration +extends = hal_app:LineFollowerTarget, app:LineFollower, static_check_configuration build_flags = - ${hal:Target.build_flags} + ${hal_app:LineFollowerTarget.build_flags} ${app:LineFollower.build_flags} lib_deps = - ${hal:Target.lib_deps} + ${hal_app:LineFollowerTarget.lib_deps} ${app:LineFollower.lib_deps} lib_ignore = - ${hal:Target.lib_ignore} + ${hal_app:LineFollowerTarget.lib_ignore} ${app:LineFollower.lib_ignore} extra_scripts = - ${hal:Target.extra_scripts} + ${hal_app:LineFollowerTarget.extra_scripts} ; ***************************************************************************** ; Line follower application on simulation ; ***************************************************************************** [env:LineFollowerSim] -extends = hal:Sim, app:LineFollower, static_check_configuration +extends = hal_app:LineFollowerSim, app:LineFollower, static_check_configuration build_flags = - ${hal:Sim.build_flags} + ${hal_app:LineFollowerSim.build_flags} ${app:LineFollower.build_flags} lib_deps = - ${hal:Sim.lib_deps} + ${hal_app:LineFollowerSim.lib_deps} ${app:LineFollower.lib_deps} lib_ignore = - ${hal:Sim.lib_ignore} + ${hal_app:LineFollowerSim.lib_ignore} ${app:LineFollower.lib_ignore} extra_scripts = - ${hal:Sim.extra_scripts} + ${hal_app:LineFollowerSim.extra_scripts} ; ***************************************************************************** ; Remote control application on target ; ***************************************************************************** [env:RemoteControlTarget] -extends = hal:Target, app:RemoteControl, static_check_configuration +extends = hal_app:RemoteControlTarget, app:RemoteControl, static_check_configuration build_flags = - ${hal:Target.build_flags} + ${hal_app:RemoteControlTarget.build_flags} ${app:RemoteControl.build_flags} lib_deps = - ${hal:Target.lib_deps} + ${hal_app:RemoteControlTarget.lib_deps} ${app:RemoteControl.lib_deps} lib_ignore = - ${hal:Target.lib_ignore} + ${hal_app:RemoteControlTarget.lib_ignore} ${app:RemoteControl.lib_ignore} extra_scripts = - ${hal:Target.extra_scripts} + ${hal_app:RemoteControlTarget.extra_scripts} ; ***************************************************************************** ; Remote control application on simulation ; ***************************************************************************** [env:RemoteControlSim] -extends = hal:Sim, app:RemoteControl, static_check_configuration +extends = hal_app:RemoteControlSim, app:RemoteControl, static_check_configuration build_flags = - ${hal:Sim.build_flags} + ${hal_app:RemoteControlSim.build_flags} ${app:RemoteControl.build_flags} lib_deps = - ${hal:Sim.lib_deps} + ${hal_app:RemoteControlSim.lib_deps} ${app:RemoteControl.lib_deps} lib_ignore = - ${hal:Sim.lib_ignore} + ${hal_app:RemoteControlSim.lib_ignore} ${app:RemoteControl.lib_ignore} extra_scripts = - ${hal:Sim.extra_scripts} + ${hal_app:RemoteControlSim.extra_scripts} ; ***************************************************************************** ; PC target environment for tests