├── docs ├── module.rst ├── index.rst ├── Makefile └── make.bat ├── .clang-format-hook-exclude ├── README.generation.md ├── test-project ├── .gitignore ├── build_tools │ └── __init__.py ├── Pipfile ├── src │ └── main.cpp └── clean_test_project.sh ├── .gitignore ├── .vscode ├── extensions.json └── c_cpp_properties.json ├── .gitlab ├── Makefile ├── README.md └── get-new-version.sh ├── .gitmodules ├── .devcontainer.json ├── lbuild-scripts ├── hosted_platforms.py ├── lbuild_utils.py └── board_info_parser.py ├── test └── tap │ ├── mock │ ├── can_mock.cpp │ ├── pwm_mock.cpp │ ├── leds_mock.cpp │ ├── uart_mock.cpp │ ├── analog_mock.cpp │ ├── digital_mock.cpp │ ├── abstract_imu_mock.cpp │ ├── imu_interface_mock.cpp │ ├── remote_mock.cpp │ ├── encoder_interface_mock.cpp │ ├── ref_serial_mock.cpp │ ├── can_rx_handler_mock.cpp │ ├── bmi088_mock.cpp │ ├── command_mapper_mock.cpp │ ├── motor_interface_mock.cpp │ ├── mpu6500_mock.cpp │ ├── command_governor_interface_mock.cpp │ ├── terminal_serial_mock.cpp │ ├── command_scheduler_mock.cpp │ ├── robot_to_robot_message_handler_mock.cpp │ ├── can_rx_listener_mock.cpp │ ├── terminal_serial_callback_interface_mock.cpp │ ├── ref_serial_transmitter_mock.cpp │ ├── scheduler_terminal_handler_mock.cpp │ ├── dji_motor_tx_handler_mock.cpp │ ├── command_mock.cpp │ ├── dji_motor_terminal_serial_handler_mock.cpp │ ├── imu_terminal_serial_handler_mock.cpp │ ├── setpoint_subsystem_mock.cpp │ ├── move_integral_command_mock.cpp │ ├── subsystem_mock.cpp │ ├── unjam_integral_command_mock.cpp │ ├── error_controller_mock.cpp │ ├── integrable_setpoint_subsystem_mock.cpp │ ├── leds_mock.hpp │ ├── analog_mock.hpp │ ├── hold_repeat_command_mapping_mock.cpp │ ├── command_governor_interface_mock.hpp │ ├── dji_motor_mock.cpp │ ├── can_rx_listener_mock.hpp │ ├── terminal_serial_callback_interface_mock.hpp │ ├── scheduler_terminal_handler_mock.hpp │ ├── pwm_mock.hpp │ ├── terminal_serial_mock.hpp │ ├── robot_to_robot_message_handler_mock.hpp │ ├── digital_mock.hpp │ ├── dji_motor_terminal_serial_handler_mock.hpp │ ├── imu_terminal_serial_handler_mock.hpp │ ├── encoder_interface_mock.hpp │ ├── error_controller_mock.hpp │ ├── can_rx_handler_mock.hpp │ ├── odometry_2d_interface_mock.hpp │ ├── can_mock.hpp │ ├── hold_repeat_command_mapping_mock.hpp │ ├── command_mapper_mock.hpp │ ├── dji_motor_encoder_mock.cpp │ ├── command_mock.hpp │ ├── imu_interface_mock.hpp │ ├── subsystem_mock.hpp │ ├── abstract_imu_mock.hpp │ ├── motor_interface_mock.hpp │ └── dji_motor_encoder_mock.hpp │ └── control │ ├── test_subsystem.hpp │ └── test_command.hpp ├── .gitattributes ├── src └── tap │ ├── communication │ ├── module.lb │ ├── can │ │ ├── can_bus.hpp │ │ ├── can_rx_listener.cpp │ │ └── module.lb │ ├── sensors │ │ ├── imu │ │ │ ├── bmi088 │ │ │ │ ├── bmi088_hal.cpp │ │ │ │ └── module.lb │ │ │ ├── mpu6500 │ │ │ │ └── module.lb │ │ │ └── module.lb │ │ ├── module.lb │ │ ├── voltage │ │ │ ├── module.lb │ │ │ └── voltage_sensor_interface.hpp │ │ ├── distance │ │ │ ├── module.lb │ │ │ ├── sharp_ir_GP2Y0A41.cpp │ │ │ ├── distance_sensor.cpp │ │ │ └── analog_distance_sensor.cpp │ │ ├── limit_switch │ │ │ ├── module.lb │ │ │ └── limit_switch_interface.hpp │ │ ├── current │ │ │ ├── module.lb │ │ │ ├── current_sensor_interface.hpp │ │ │ └── analog_current_sensor.cpp │ │ ├── encoder │ │ │ ├── can_encoder │ │ │ │ ├── module.lb │ │ │ │ └── can_encoder.cpp │ │ │ └── module.lb │ │ ├── imu_heater │ │ │ └── imu_heater_constants.hpp.in │ │ ├── sensor_interface.hpp │ │ └── buzzer │ │ │ ├── buzzer.cpp.in │ │ │ ├── buzzer.hpp │ │ │ └── module.lb │ ├── serial │ │ ├── remote_serial_constants.hpp.in │ │ ├── ref_serial_constants.hpp.in │ │ ├── uart_terminal_device_constants.hpp.in │ │ └── uart_terminal_device.cpp │ ├── tcp-server │ │ ├── module.lb │ │ └── json_messages.hpp │ └── gpio │ │ └── analog.hpp.in │ ├── storage │ ├── module.lb │ └── littlefs-internal │ │ └── module.lb │ ├── algorithms │ ├── strtok.hpp │ ├── strtok.cpp │ ├── linear_interpolation_predictor.cpp │ ├── fuzzy_pd.cpp │ ├── linear_interpolation_predictor_wrapped.cpp │ └── extended_kalman.cpp │ ├── errors │ ├── module.lb │ ├── system_error.hpp │ └── create_errors.hpp │ ├── control │ ├── command_scheduler_types.hpp │ ├── press_command_mapping.cpp │ ├── setpoint │ │ ├── commands │ │ │ ├── unjam_command_interface.hpp │ │ │ └── calibrate_command.cpp │ │ └── interfaces │ │ │ └── integrable_setpoint_subsystem.hpp │ ├── hold_command_mapping.cpp │ ├── command.cpp │ └── governor │ │ └── command_governor_interface.hpp │ ├── board │ └── board.cpp │ ├── display │ ├── dummy_allocator.hpp │ ├── module.lb │ ├── sh1106_mock_impl.hpp │ └── sh1107_mock_impl.hpp │ ├── motor │ ├── m3508_constants.hpp │ ├── dji_motor_ids.hpp │ ├── motor_constants.hpp │ └── motorsim │ │ └── can_serializer.hpp │ ├── util_macros.hpp │ └── architecture │ └── clock.cpp ├── modm-project-files └── sim-modm │ └── project.xml.in └── ext ├── module.lb ├── eigen-project └── module.lb ├── SConscript └── littlefs-project └── module.lb /docs/module.rst: -------------------------------------------------------------------------------- 1 | Class APIs 2 | ========== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 -------------------------------------------------------------------------------- /.clang-format-hook-exclude: -------------------------------------------------------------------------------- 1 | .gitlab/* 2 | .vscode/* 3 | test-project 4 | modm/* 5 | scripts/* -------------------------------------------------------------------------------- /README.generation.md: -------------------------------------------------------------------------------- 1 | All files in this directory and subdirectories are modified and SHOULD NOT BE MODIFIED! 2 | -------------------------------------------------------------------------------- /test-project/.gitignore: -------------------------------------------------------------------------------- 1 | taproot 2 | openocd.cfg 3 | project.xml.log 4 | build 5 | src/drivers.hpp 6 | pipfile.lock 7 | -------------------------------------------------------------------------------- /test-project/build_tools/__init__.py: -------------------------------------------------------------------------------- 1 | # aruw Python build tools 2 | __all__ = [ 3 | "parse_args" 4 | ] 5 | 6 | from . import parse_args 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/.cortex-debug.peripherals.state.json 2 | .vscode/.cortex-debug.registers.state.json 3 | .sconsign.dblite 4 | *.pyc 5 | docs/_build 6 | docs/api 7 | docs/doxyoutput 8 | gcov-result 9 | **/.DS_Store 10 | .sconsign 11 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "aruwrobotchooser.robot-chooser", 6 | "ms-vscode-remote.remote-containers", 7 | "samuelcolvin.jinjahtml" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.gitlab/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_VERSION := "$(shell ./get-new-version.sh)" 2 | 3 | build: 4 | time docker build . --tag aruw/mcb-2020-gitlab-ci 5 | 6 | publish: 7 | docker tag aruw/mcb-2020-gitlab-ci aruw/mcb-2020-gitlab-ci:$(IMAGE_VERSION) 8 | docker push aruw/mcb-2020-gitlab-ci:$(IMAGE_VERSION) 9 | -------------------------------------------------------------------------------- /.gitlab/README.md: -------------------------------------------------------------------------------- 1 | # MCB CI Docker image 2 | 3 | ## Build and publish instructions 4 | 5 | With Makefile: 6 | ``` 7 | make build 8 | make publish 9 | ``` 10 | 11 | Manually (make sure to change version): 12 | ``` 13 | docker build -t aruw/mcb-2020-gitlab-ci:2020-02-17.1 . 14 | docker push aruw/mcb-2020-gitlab-ci:2020-02-17.1 15 | ``` -------------------------------------------------------------------------------- /test-project/Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | scons = "==3.1.2" 8 | lbuild = "==1.20.0" 9 | pyelftools = "*" 10 | pywin32 = { version = "*", markers = "sys_platform == 'win32'" } 11 | 12 | [dev-packages] 13 | 14 | [requires] 15 | python_version = "3" 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "modm"] 2 | path = modm 3 | url = https://github.com/uw-advanced-robotics/modm.git 4 | branch = aruw-master 5 | [submodule "taproot-scripts"] 6 | path = taproot-scripts 7 | url = https://gitlab.com/aruw/controls/taproot-scripts.git 8 | [submodule "ext/littlefs"] 9 | path = ext/littlefs-project/littlefs 10 | url = https://github.com/littlefs-project/littlefs 11 | [submodule "ext/eigen-project/eigen"] 12 | path = ext/eigen-project/eigen 13 | url = https://gitlab.com/libeigen/eigen.git 14 | -------------------------------------------------------------------------------- /.devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "aruw/mcb-dev:2021-06-02.3", 3 | // TODO: consider supporting/promoting using WSL2 file system for perf? 4 | // Might make it harder to deploy to an MCB. 5 | "extensions": [ 6 | "marus25.cortex-debug", 7 | "ms-vscode.cpptools", 8 | "aruwrobotchooser.robot-chooser" 9 | ], 10 | "mounts": [ 11 | // Persist installed extensions across container rebuilds 12 | "source=TAPROOT-extensions,target=/root/.vscode-server/extensions,type=volume", 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.gitlab/get-new-version.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | TAGS_API_URL="https://registry.hub.docker.com/v1/repositories/aruw/mcb-2020-gitlab-ci/tags" 4 | 5 | ver_base=$(TZ='America/Los_Angeles' date +%F) 6 | 7 | # requires jq: sudo apt install jq 8 | curl --silent "$TAGS_API_URL" \ 9 | | jq -r " 10 | [ 11 | .[] 12 | | .name 13 | | select(startswith(\"$ver_base\")) 14 | | ltrimstr(\"$ver_base.\") 15 | | tonumber 16 | ] | max // 0 17 | | .+1 18 | | tostring 19 | | \"$ver_base.\" + . 20 | " 21 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. Taproot documentation master file, created by 2 | sphinx-quickstart on Sat Jun 20 20:03:07 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Taproot documentation! 7 | ================================================== 8 | 9 | Here you will find documentation for MCB embedded/control code. Navigate to a specific subject by searching. Browse through code by looking through "Library API" below. 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | :caption: Contents: 14 | 15 | api/library_root 16 | 17 | Indices and tables 18 | ================== 19 | 20 | :ref:`genindex` -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /test-project/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "tap/drivers.hpp" 21 | 22 | int main() { return 0; } 23 | -------------------------------------------------------------------------------- /lbuild-scripts/hosted_platforms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | ALL_HOSTED_TARGET_NAMES = [ 19 | "hosted-linux", 20 | "hosted-darwin", 21 | "hosted-windows", 22 | ] 23 | -------------------------------------------------------------------------------- /test/tap/mock/can_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "can_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CanMock::CanMock() {} 25 | CanMock::~CanMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/pwm_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "pwm_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | PwmMock::PwmMock() {} 25 | PwmMock::~PwmMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/leds_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "leds_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | LedsMock::LedsMock() {} 25 | LedsMock::~LedsMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/uart_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "uart_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | UartMock::UartMock() {} 25 | UartMock::~UartMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/analog_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "analog_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | AnalogMock::AnalogMock() {} 25 | AnalogMock::~AnalogMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/digital_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "digital_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | DigitalMock::DigitalMock() {} 25 | DigitalMock::~DigitalMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | ####### C++ .gitattributes template copied from: 5 | # https://github.com/alexkaratarakis/gitattributes/blob/master/C%2B%2B.gitattributes 6 | ####### 7 | # Sources 8 | *.c text diff=cpp 9 | *.cc text diff=cpp 10 | *.cxx text diff=cpp 11 | *.cpp text diff=cpp 12 | *.c++ text diff=cpp 13 | *.hpp text diff=cpp 14 | *.h text diff=cpp 15 | *.h++ text diff=cpp 16 | *.hh text diff=cpp 17 | 18 | # Compiled Object files 19 | *.slo binary 20 | *.lo binary 21 | *.o binary 22 | *.obj binary 23 | 24 | # Precompiled Headers 25 | *.gch binary 26 | *.pch binary 27 | 28 | # Compiled Dynamic libraries 29 | *.so binary 30 | *.dylib binary 31 | *.dll binary 32 | 33 | # Compiled Static libraries 34 | *.lai binary 35 | *.la binary 36 | *.a binary 37 | *.lib binary 38 | 39 | # Executables 40 | *.exe binary 41 | *.elf binary 42 | *.out binary 43 | *.app binary 44 | 45 | ############# C++ .gitattributes template end 46 | -------------------------------------------------------------------------------- /src/tap/communication/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication" 20 | module.description = "Various communication HALs" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | pass 27 | -------------------------------------------------------------------------------- /test/tap/mock/abstract_imu_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "abstract_imu_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | AbstractImuMock::AbstractImuMock() {} 25 | AbstractImuMock::~AbstractImuMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/imu_interface_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "imu_interface_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | ImuInterfaceMock::ImuInterfaceMock() {} 25 | ImuInterfaceMock::~ImuInterfaceMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /src/tap/storage/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":storage" 20 | module.description = "Support for non-volatile storage" 21 | 22 | def prepare(module, options): 23 | module.depends(":core") 24 | return True 25 | 26 | def build(env): 27 | pass 28 | -------------------------------------------------------------------------------- /src/tap/communication/can/can_bus.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CAN_BUS_HPP_ 21 | #define TAPROOT_CAN_BUS_HPP_ 22 | 23 | namespace tap::can 24 | { 25 | enum class CanBus 26 | { 27 | CAN_BUS1, 28 | CAN_BUS2, 29 | }; 30 | } 31 | 32 | #endif // TAPROOT_CAN_BUS_HPP_ 33 | -------------------------------------------------------------------------------- /test/tap/mock/remote_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "remote_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | RemoteMock::RemoteMock(tap::Drivers *drivers) : tap::communication::serial::Remote(drivers) {} 25 | RemoteMock::~RemoteMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/encoder_interface_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "encoder_interface_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | EncoderInterfaceMock::EncoderInterfaceMock() : EncoderInterface() {} 25 | EncoderInterfaceMock::~EncoderInterfaceMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/ref_serial_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "ref_serial_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | RefSerialMock::RefSerialMock(Drivers *drivers) : tap::communication::serial::RefSerial(drivers) {} 25 | RefSerialMock::~RefSerialMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/can_rx_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "can_rx_handler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CanRxHandlerMock::CanRxHandlerMock(tap::Drivers *drivers) : can::CanRxHandler(drivers) {} 25 | CanRxHandlerMock::~CanRxHandlerMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/bmi088_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "bmi088_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | Bmi088Mock::Bmi088Mock(tap::Drivers *drivers) 25 | : tap::communication::sensors::imu::bmi088::Bmi088(drivers) 26 | { 27 | } 28 | Bmi088Mock::~Bmi088Mock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /test/tap/mock/command_mapper_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "command_mapper_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CommandMapperMock::CommandMapperMock(tap::Drivers *drivers) : control::CommandMapper(drivers) {} 25 | CommandMapperMock::~CommandMapperMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /test/tap/mock/motor_interface_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "motor_interface_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | MotorInterfaceMock::MotorInterfaceMock() : tap::motor::MotorInterface(), encoder() {} 25 | 26 | MotorInterfaceMock::~MotorInterfaceMock() {} 27 | } // namespace tap::mock 28 | -------------------------------------------------------------------------------- /test/tap/mock/mpu6500_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "mpu6500_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | Mpu6500Mock::Mpu6500Mock(tap::Drivers *drivers) 25 | : communication::sensors::imu::mpu6500::Mpu6500(drivers) 26 | { 27 | } 28 | Mpu6500Mock::~Mpu6500Mock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/imu/bmi088/bmi088_hal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "bmi088_hal.hpp" 21 | 22 | #if defined(ENV_UNIT_TESTS) 23 | namespace tap::communication::sensors::imu::bmi088 24 | { 25 | std::deque Bmi088Hal::rxData; 26 | } // namespace tap::communication::sensors::imu::bmi088 27 | #endif 28 | -------------------------------------------------------------------------------- /test/tap/mock/command_governor_interface_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "command_governor_interface_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CommandGovernorInterfaceMock::CommandGovernorInterfaceMock() {} 25 | CommandGovernorInterfaceMock::~CommandGovernorInterfaceMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2022 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors" 20 | module.description = "Various sensors" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors" 27 | env.copy("sensor_interface.hpp") 28 | -------------------------------------------------------------------------------- /test/tap/mock/terminal_serial_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "terminal_serial_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | TerminalSerialMock::TerminalSerialMock(Drivers *drivers) 25 | : communication::serial::TerminalSerial(drivers) 26 | { 27 | } 28 | TerminalSerialMock::~TerminalSerialMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /modm-project-files/sim-modm/project.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ../../{{ modm_path }} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | modm:architecture:atomic 14 | modm:architecture:can 15 | modm:architecture:delay 16 | modm:build:scons 17 | modm:container 18 | modm:io 19 | modm:math:filter 20 | modm:math:geometry 21 | modm:math:interpolation 22 | modm:math:saturated 23 | modm:math:utils 24 | modm:platform:core 25 | modm:processing 26 | modm:processing:protothread 27 | modm:ui:display 28 | modm:ui:menu 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/voltage/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:voltage" 20 | module.description = "Voltage sensor interface" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/voltage" 27 | env.copy(".") 28 | -------------------------------------------------------------------------------- /test/tap/mock/command_scheduler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "command_scheduler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CommandSchedulerMock::CommandSchedulerMock(tap::Drivers *drivers) 25 | : control::CommandScheduler(drivers) 26 | { 27 | } 28 | CommandSchedulerMock::~CommandSchedulerMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/distance/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:distance" 20 | module.description = "Various distance sensors" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/distance" 27 | env.copy(".") 28 | -------------------------------------------------------------------------------- /test/tap/mock/robot_to_robot_message_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "robot_to_robot_message_handler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | RobotToRobotMessageHandlerMock::RobotToRobotMessageHandlerMock() 25 | : tap::communication::serial::RefSerial::RobotToRobotMessageHandler() 26 | { 27 | } 28 | } // namespace tap::mock 29 | -------------------------------------------------------------------------------- /ext/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":ext" 20 | module.description = "External Libraries" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | # Copy all folders and files that are not configurable in this 27 | # top level module 28 | env.outbasepath = "taproot/ext" 29 | env.copy("SConscript") 30 | 31 | -------------------------------------------------------------------------------- /test/tap/mock/can_rx_listener_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "can_rx_listener_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CanRxListenerMock::CanRxListenerMock(tap::Drivers *drivers, uint32_t id, can::CanBus bus) 25 | : can::CanRxListener(drivers, id, bus) 26 | { 27 | } 28 | CanRxListenerMock::~CanRxListenerMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /test/tap/mock/terminal_serial_callback_interface_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "terminal_serial_callback_interface_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | TerminalSerialCallbackInterfaceMock::TerminalSerialCallbackInterfaceMock() {} 25 | TerminalSerialCallbackInterfaceMock::~TerminalSerialCallbackInterfaceMock() {} 26 | } // namespace tap::mock 27 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/limit_switch/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:limit-switch" 20 | module.description = "Limit switch related interfaces/drivers" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/limit_switch" 27 | env.copy(".") 28 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/current/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:current" 20 | module.description = "Current sensor interface and various current sensors" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/current" 27 | env.copy(".") 28 | -------------------------------------------------------------------------------- /test/tap/mock/ref_serial_transmitter_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "ref_serial_transmitter_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | RefSerialTransmitterMock::RefSerialTransmitterMock(Drivers *drivers) 25 | : tap::communication::serial::RefSerialTransmitter(drivers) 26 | { 27 | } 28 | RefSerialTransmitterMock::~RefSerialTransmitterMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /test-project/clean_test_project.sh: -------------------------------------------------------------------------------- 1 | # !/bin/bash 2 | # 3 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 4 | # 5 | # This file is part of Taproot. 6 | # 7 | # Taproot is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Taproot is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Taproot. If not, see . 19 | 20 | # See https://stackoverflow.com/questions/39340169/dir-cd-dirname-bash-source0-pwd-how-does-that-work/39340259 21 | # for how the following line works. 22 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 23 | 24 | cd $SCRIPT_DIR 25 | 26 | rm -rf taproot 27 | rm -rf build 28 | rm -f .sconsign.dblite 29 | rm -f project.xml.log 30 | -------------------------------------------------------------------------------- /test/tap/mock/scheduler_terminal_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "scheduler_terminal_handler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | SchedulerTerminalHandlerMock::SchedulerTerminalHandlerMock(Drivers *drivers) 25 | : control::SchedulerTerminalHandler(drivers) 26 | { 27 | } 28 | SchedulerTerminalHandlerMock::~SchedulerTerminalHandlerMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_tx_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "dji_motor_tx_handler_mock.hpp" 21 | 22 | #include "tap/motor/dji_motor.hpp" 23 | 24 | namespace tap::mock 25 | { 26 | DjiMotorTxHandlerMock::DjiMotorTxHandlerMock(tap::Drivers *drivers) 27 | : tap::motor::DjiMotorTxHandler(drivers) 28 | { 29 | } 30 | DjiMotorTxHandlerMock::~DjiMotorTxHandlerMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /src/tap/storage/littlefs-internal/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":storage:littlefs-internal" 20 | module.description = "LittleFS port on STM32F427II" 21 | 22 | def prepare(module, options): 23 | module.depends(":core") 24 | module.depends(":ext:littlefs") 25 | return True 26 | 27 | def build(env): 28 | env.outbasepath = "taproot/src/tap/storage/littlefs-internal" 29 | env.copy(".") 30 | -------------------------------------------------------------------------------- /src/tap/algorithms/strtok.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_STRTOK_HPP_ 21 | #define TAPROOT_STRTOK_HPP_ 22 | 23 | #ifndef __DOXYGEN__ 24 | 25 | /** 26 | * Source code from glibc/string/strtok_r.c. arm-none-eabi-gcc does not have strtok_r, 27 | * so we implement it ourselves. 28 | */ 29 | char *strtokR(char *s, const char *delim, char **savePtr); 30 | 31 | #endif 32 | 33 | #endif // TAPROOT_STRTOK_HPP_ 34 | -------------------------------------------------------------------------------- /src/tap/errors/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":errors" 20 | module.description = "Error handler" 21 | 22 | def prepare(module, options): 23 | module.depends( 24 | ":core", 25 | ":communication:serial:terminal_serial", 26 | ":communication:gpio:leds") 27 | 28 | return True 29 | 30 | def build(env): 31 | env.outbasepath = "taproot/src/tap/errors" 32 | env.copy(".") 33 | -------------------------------------------------------------------------------- /src/tap/control/command_scheduler_types.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_COMMAND_SCHEDULER_TYPES_HPP_ 21 | #define TAPROOT_COMMAND_SCHEDULER_TYPES_HPP_ 22 | 23 | #include 24 | 25 | namespace tap::control 26 | { 27 | typedef uint64_t command_scheduler_bitmap_t; 28 | typedef uint64_t subsystem_scheduler_bitmap_t; 29 | } // namespace tap::control 30 | 31 | #endif // TAPROOT_COMMAND_SCHEDULER_TYPES_HPP_ 32 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/encoder/can_encoder/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:encoder:can_encoder" 20 | module.description = "ARUW CAN Encoder" 21 | 22 | def prepare(module, options): 23 | module.depends(":communication:sensors:encoder") 24 | return True 25 | 26 | def build(env): 27 | env.outbasepath = "taproot/src/tap/communication/sensors/encoder/can_encoder" 28 | env.copy(".") 29 | -------------------------------------------------------------------------------- /lbuild-scripts/lbuild_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | import os 19 | 20 | from pathlib import Path 21 | 22 | def repo_path_rel_repolb(file, path): 23 | """ 24 | Relocate given path to the path of the repo file. 25 | Copied from `modm/test/all/run_all.py` 26 | 27 | - file: __file__ that the function is called in 28 | - path: path relative to repo.lb file that you want get 29 | """ 30 | return (Path(os.path.abspath(file)).parents[1] / path) 31 | -------------------------------------------------------------------------------- /test/tap/mock/command_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "command_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | CommandMock::CommandMock() : Command() 25 | { 26 | // Most of the time tests expect that we are adding commands that 27 | // are ready to be added. This makes tests cleaner 28 | ON_CALL(*this, isReady).WillByDefault(testing::Return(true)); 29 | } 30 | CommandMock::~CommandMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_terminal_serial_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "dji_motor_terminal_serial_handler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | DjiMotorTerminalSerialHandlerMock::DjiMotorTerminalSerialHandlerMock(tap::Drivers *drivers) 25 | : motor::DjiMotorTerminalSerialHandler(drivers) 26 | { 27 | } 28 | DjiMotorTerminalSerialHandlerMock::~DjiMotorTerminalSerialHandlerMock() {} 29 | } // namespace tap::mock 30 | -------------------------------------------------------------------------------- /src/tap/communication/serial/remote_serial_constants.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_REMOTE_SERIAL_CONSTANTS_HPP_ 21 | #define TAPROOT_REMOTE_SERIAL_CONSTANTS_HPP_ 22 | 23 | namespace tap::communication::serial::bound_ports 24 | { 25 | static constexpr Uart::UartPort REMOTE_SERIAL_UART_PORT = Uart::UartPort::{{ uart_port }}; 26 | } // namespace tap::communication::serial::bound_ports 27 | 28 | #endif // TAPROOT_REMOTE_SERIAL_CONSTANTS_HPP_ 29 | 30 | -------------------------------------------------------------------------------- /ext/eigen-project/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":ext:eigen" 20 | module.description = "Eigen: A template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | # Copy all folders and files that are not configurable in this 27 | # top level module 28 | env.outbasepath = "taproot/ext" 29 | env.copy("eigen/Eigen", dest="Eigen") 30 | -------------------------------------------------------------------------------- /src/tap/communication/serial/ref_serial_constants.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_REF_SERIAL_CONSTANTS_HPP_ 21 | #define TAPROOT_REF_SERIAL_CONSTANTS_HPP_ 22 | 23 | #include "uart.hpp" 24 | 25 | namespace tap::communication::serial::bound_ports 26 | { 27 | static constexpr Uart::UartPort REF_SERIAL_UART_PORT = Uart::UartPort::{{ uart_port }}; 28 | } // namespace tap::communication::serial::bound_ports 29 | 30 | #endif // TAPROOT_REF_SERIAL_CONSTANTS_HPP_ 31 | 32 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/encoder/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:encoder" 20 | module.description = "Encoder related interfaces/drivers" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/encoder" 27 | env.copy("encoder_interface.hpp") 28 | env.copy("multi_encoder.hpp") 29 | env.copy("wrapped_encoder.cpp") 30 | env.copy("wrapped_encoder.hpp") 31 | -------------------------------------------------------------------------------- /src/tap/communication/serial/uart_terminal_device_constants.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_UART_TERMINAL_DEVICE_CONSTANTS_HPP_ 21 | #define TAPROOT_UART_TERMINAL_DEVICE_CONSTANTS_HPP_ 22 | 23 | namespace tap::communication::serial::bound_ports 24 | { 25 | static constexpr Uart::UartPort TERMINAL_SERIAL_UART_PORT = Uart::UartPort::{{ uart_port }}; 26 | } // namespace tap::communication::serial::bound_ports 27 | 28 | #endif // TAPROOT_UART_TERMINAL_DEVICE_CONSTANTS_HPP_ 29 | 30 | -------------------------------------------------------------------------------- /test/tap/mock/imu_terminal_serial_handler_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "imu_terminal_serial_handler_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | ImuTerminalSerialHandlerMock::ImuTerminalSerialHandlerMock( 25 | tap::Drivers* drivers, 26 | communication::sensors::imu::AbstractIMU* imu) 27 | : communication::sensors::imu::ImuTerminalSerialHandler(drivers, imu) 28 | { 29 | } 30 | ImuTerminalSerialHandlerMock::~ImuTerminalSerialHandlerMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /ext/SConscript: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | Import("env") 19 | 20 | from os.path import abspath 21 | 22 | files = env.FindSourceFiles(".") 23 | 24 | if len(files) != 0: 25 | newenv = env.Clone() 26 | newenv.Append(CCFLAGS=["-w"]) # suppress all warnings 27 | library = newenv.StaticLibrary(target="taproot-ext", source=files) 28 | 29 | env.AppendUnique(LIBPATH=[ 30 | abspath(str(library[0].get_dir())), 31 | ]) 32 | 33 | env.AppendUnique(LIBS=[ 34 | library, 35 | ]) 36 | 37 | Return("library") 38 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/imu_heater/imu_heater_constants.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_IMU_HEATER_CONSTANTS_HPP_ 21 | #define TAPROOT_IMU_HEATER_CONSTANTS_HPP_ 22 | 23 | #include "tap/communication/gpio/pwm.hpp" 24 | 25 | namespace tap::communication::sensors::imu_heater::bound_ports 26 | { 27 | static constexpr tap::gpio::Pwm::Timer IMU_HEATER_TIMER = tap::gpio::Pwm::Timer::{{ timer|upper }}; 28 | } // tap::sensors 29 | 30 | #endif // TAPROOT_IMU_HEATER_CONSTANTS_HPP_ 31 | 32 | -------------------------------------------------------------------------------- /src/tap/board/board.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "board.hpp" 21 | 22 | // In simulation, we'll let modm's default implementation handle this. 23 | #ifndef PLATFORM_HOSTED 24 | modm_extern_c void modm_abandon(const modm::AssertionInfo &) 25 | { 26 | Board::LedsPort::setOutput(); 27 | for (int times = 10; times >= 0; times--) 28 | { 29 | Board::LedsPort::toggle(); 30 | modm::delay_ms(100); 31 | Board::LedsPort::toggle(); 32 | modm::delay_ms(100); 33 | } 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /test/tap/mock/setpoint_subsystem_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "setpoint_subsystem_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | SetpointSubsystemMock::SetpointSubsystemMock(Drivers *drivers) : Subsystem(drivers) 25 | { 26 | // Default to simulating an online and unjammed setpointSubsystem 27 | ON_CALL(*this, isOnline).WillByDefault(testing::Return(true)); 28 | ON_CALL(*this, isJammed).WillByDefault(testing::Return(false)); 29 | } 30 | SetpointSubsystemMock::~SetpointSubsystemMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /test/tap/mock/move_integral_command_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "move_integral_command_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | MoveIntegralCommandMock::MoveIntegralCommandMock( 25 | tap::control::setpoint::IntegrableSetpointSubsystem& integrableSetpointSubsystem, 26 | const tap::control::setpoint::MoveIntegralCommand::Config& config) 27 | : tap::control::setpoint::MoveIntegralCommand(integrableSetpointSubsystem, config) 28 | { 29 | } 30 | MoveIntegralCommandMock::~MoveIntegralCommandMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /ext/littlefs-project/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":ext:littlefs" 20 | module.description = "littleFS: A little fail-safe filesystem designed for microcontrollers" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | # Copy all folders and files that are not configurable in this 27 | # top level module 28 | env.outbasepath = "taproot/ext" 29 | env.copy("littlefs/lfs_util.h") 30 | env.copy("littlefs/lfs_util.c") 31 | env.copy("littlefs/lfs.c") 32 | env.copy("littlefs/lfs.h") 33 | -------------------------------------------------------------------------------- /test/tap/mock/subsystem_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "subsystem_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | SubsystemMock::SubsystemMock(Drivers *drivers) : control::Subsystem(drivers) 25 | { 26 | // Most of the time tests expect that we don't have a test command 27 | // for the subsystem. This makes tests cleaner 28 | EXPECT_CALL(*this, getTestCommand) 29 | .Times(testing::AnyNumber()) 30 | .WillRepeatedly(testing::Return(nullptr)); 31 | } 32 | SubsystemMock::~SubsystemMock() {} 33 | } // namespace tap::mock 34 | -------------------------------------------------------------------------------- /test/tap/mock/unjam_integral_command_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "unjam_integral_command_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | UnjamIntegralCommandMock::UnjamIntegralCommandMock( 25 | tap::control::setpoint::IntegrableSetpointSubsystem& integrableSetpointSubsystem, 26 | const tap::control::setpoint::UnjamIntegralCommand::Config& config) 27 | : tap::control::setpoint::UnjamIntegralCommand(integrableSetpointSubsystem, config) 28 | { 29 | } 30 | UnjamIntegralCommandMock::~UnjamIntegralCommandMock() {} 31 | } // namespace tap::mock 32 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/imu/bmi088/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2022 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:imu:bmi088" 20 | module.description = "Robomaster Development Board Type C specific communication" \ 21 | "with the on board bmi088" 22 | 23 | def prepare(module, options): 24 | module.depends(":communication:sensors:imu_heater") 25 | module.depends(":communication:sensors:imu") 26 | return options[":dev_board"] == "rm-dev-board-c" 27 | 28 | def build(env): 29 | env.outbasepath = "taproot/src/tap/communication/sensors/imu/bmi088" 30 | env.copy(".") 31 | -------------------------------------------------------------------------------- /test/tap/control/test_subsystem.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_TEST_SUBSYSTEM_HPP_ 21 | #define TAPROOT_TEST_SUBSYSTEM_HPP_ 22 | 23 | #include "tap/control/subsystem.hpp" 24 | 25 | namespace tap 26 | { 27 | namespace control 28 | { 29 | class TestSubsystem : public tap::control::Subsystem 30 | { 31 | public: 32 | TestSubsystem(tap::Drivers *drivers) : tap::control::Subsystem(drivers) {} 33 | void refresh() override {} 34 | void refreshSafeDisconnect() override {} 35 | }; 36 | } // namespace control 37 | } // namespace tap 38 | 39 | #endif // TAPROOT_TEST_SUBSYSTEM_HPP_ 40 | -------------------------------------------------------------------------------- /test/tap/mock/error_controller_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "error_controller_mock.hpp" 21 | 22 | bool errorDescriptionContainsSubstr( 23 | const tap::errors::SystemError& error, 24 | const std::string& substr) 25 | { 26 | std::string errorStr = error.getDescription(); 27 | return errorStr.find(substr) != std::string::npos; 28 | } 29 | 30 | namespace tap::mock 31 | { 32 | ErrorControllerMock::ErrorControllerMock(tap::Drivers* drivers) 33 | : tap::errors::ErrorController(drivers) 34 | { 35 | } 36 | ErrorControllerMock::~ErrorControllerMock() {} 37 | } // namespace tap::mock 38 | -------------------------------------------------------------------------------- /test/tap/mock/integrable_setpoint_subsystem_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "integrable_setpoint_subsystem_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | IntegrableSetpointSubsystemMock::IntegrableSetpointSubsystemMock(Drivers *drivers) 25 | : Subsystem(drivers) 26 | { 27 | // Default to simulating an online and unjammed setpointSubsystem 28 | ON_CALL(*this, isOnline).WillByDefault(testing::Return(true)); 29 | ON_CALL(*this, isJammed).WillByDefault(testing::Return(false)); 30 | } 31 | IntegrableSetpointSubsystemMock::~IntegrableSetpointSubsystemMock() {} 32 | } // namespace tap::mock 33 | -------------------------------------------------------------------------------- /test/tap/mock/leds_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_LEDS_MOCK_HPP_ 21 | #define TAPROOT_LEDS_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/gpio/leds.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class LedsMock : public tap::gpio::Leds 32 | { 33 | public: 34 | LedsMock(); 35 | virtual ~LedsMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(void, set, (LedPin pin, bool isSet), (override)); 39 | }; // class LedsMock 40 | } // namespace mock 41 | } // namespace tap 42 | 43 | #endif // TAPROOT_LEDS_MOCK_HPP_ 44 | -------------------------------------------------------------------------------- /src/tap/control/press_command_mapping.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "press_command_mapping.hpp" 21 | 22 | namespace tap 23 | { 24 | namespace control 25 | { 26 | void PressCommandMapping::executeCommandMapping(const RemoteMapState &currState) 27 | { 28 | if (mappingSubset(currState) && 29 | !(mapState.getNegKeysUsed() && negKeysSubset(mapState, currState))) 30 | { 31 | if (!pressed) 32 | { 33 | pressed = true; 34 | addCommands(); 35 | } 36 | } 37 | else 38 | { 39 | pressed = false; 40 | } 41 | } 42 | } // namespace control 43 | } // namespace tap 44 | -------------------------------------------------------------------------------- /test/tap/mock/analog_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ANALOG_MOCK_HPP_ 21 | #define TAPROOT_ANALOG_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/gpio/analog.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class AnalogMock : public tap::gpio::Analog 32 | { 33 | public: 34 | AnalogMock(); 35 | virtual ~AnalogMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(uint16_t, read, (Analog::Pin pin), (const override)); 39 | }; // class AnalogMock 40 | } // namespace mock 41 | } // namespace tap 42 | 43 | #endif // TAPROOT_ANALOG_MOCK_HPP_ 44 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/imu/mpu6500/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2022 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:imu:mpu6500" 20 | module.description = "Robomaster Development Board Type A specific communication" \ 21 | "with the on board mpu6500" 22 | 23 | def prepare(module, options): 24 | module.depends(":communication:sensors:imu_heater") 25 | module.depends(":communication:serial:terminal_serial") 26 | module.depends(":communication:sensors:imu") 27 | return options[":dev_board"] == "rm-dev-board-a" 28 | 29 | def build(env): 30 | env.outbasepath = "taproot/src/tap/communication/sensors/imu/mpu6500" 31 | env.copy(".") 32 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/distance/sharp_ir_GP2Y0A41.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "sharp_ir_GP2Y0A41.hpp" 21 | 22 | namespace tap 23 | { 24 | namespace sensors 25 | { 26 | // Constructor to init Sharp IR analog pin 27 | // Uses preset values for boundary and distance conversion 28 | SharpIrGP2Y0A41::SharpIrGP2Y0A41(Drivers *drivers, gpio::Analog::Pin pin) 29 | : AnalogDistanceSensor( 30 | drivers, 31 | SHARP_IR_MIN, 32 | SHARP_IR_MAX, 33 | SHARP_IR_M, 34 | SHARP_IR_B, 35 | SHARP_IR_OFFSET, 36 | pin) 37 | { 38 | } 39 | } // namespace sensors 40 | 41 | } // namespace tap 42 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/limit_switch/limit_switch_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_LIMIT_SWITCH_INTERFACE_HPP_ 21 | #define TAPROOT_LIMIT_SWITCH_INTERFACE_HPP_ 22 | 23 | namespace tap::communication::sensors::limit_switch 24 | { 25 | /** 26 | * Interface for generic limit switch sensor. 27 | */ 28 | class LimitSwitchInterface 29 | { 30 | public: 31 | /** 32 | * Returns true if the limit switch depressed (in the down position), false otherwise. 33 | */ 34 | virtual bool getLimitSwitchDepressed() const = 0; 35 | }; 36 | } // namespace tap::communication::sensors::limit_switch 37 | 38 | #endif // TAPROOT_LIMIT_SWITCH_INTERFACE_HPP_ 39 | -------------------------------------------------------------------------------- /src/tap/communication/tcp-server/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:tcp-server" 20 | module.description = "Generic TCP server that runs on a hosted Linux environment " \ 21 | "Provides utility for opening and connecting to a port. Provides read/write " \ 22 | "utilities for interacting with a TCP port. This is a **simulation-only module** - " \ 23 | "it will only be built when running on the hosted platform." 24 | 25 | def prepare(module, options): 26 | module.depends(":core") 27 | 28 | return True 29 | 30 | def build(env): 31 | env.outbasepath = "taproot/src/tap/communication/tcp-server" 32 | env.copy(".") 33 | -------------------------------------------------------------------------------- /src/tap/control/setpoint/commands/unjam_command_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_UNJAM_COMMAND_INTERFACE_HPP_ 21 | #define TAPROOT_UNJAM_COMMAND_INTERFACE_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/architecture/timeout.hpp" 26 | #include "tap/control/command.hpp" 27 | 28 | #include "../interfaces/integrable_setpoint_subsystem.hpp" 29 | 30 | namespace tap::control::setpoint 31 | { 32 | /** 33 | * Command that attempts to unjam an agitator subsystem. 34 | */ 35 | class UnjamCommandInterface : public tap::control::Command 36 | { 37 | }; 38 | 39 | } // namespace tap::control::setpoint 40 | 41 | #endif // TAPROOT_UNJAM_COMMAND_INTERFACE_HPP_ 42 | -------------------------------------------------------------------------------- /src/tap/communication/can/can_rx_listener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "can_rx_listener.hpp" 21 | 22 | #include "tap/drivers.hpp" 23 | 24 | #include "modm/architecture/interface/can_message.hpp" 25 | 26 | namespace tap 27 | { 28 | namespace can 29 | { 30 | CanRxListener::CanRxListener(Drivers *drivers, uint32_t id, CanBus cB) 31 | : canIdentifier(id), 32 | canBus(cB), 33 | drivers(drivers) 34 | { 35 | } 36 | 37 | void CanRxListener::attachSelfToRxHandler() { drivers->canRxHandler.attachReceiveHandler(this); } 38 | 39 | CanRxListener::~CanRxListener() { drivers->canRxHandler.removeReceiveHandler(*this); } 40 | } // namespace can 41 | 42 | } // namespace tap 43 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/distance/distance_sensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "distance_sensor.hpp" 21 | 22 | namespace tap 23 | { 24 | namespace sensors 25 | { 26 | // Constructor to init boundaries 27 | DistanceSensor::DistanceSensor(float minDistance, float maxDistance) 28 | : distance(0), 29 | minDistance(minDistance), 30 | maxDistance(maxDistance) 31 | { 32 | } 33 | 34 | float DistanceSensor::getMinDistance() const { return minDistance; } 35 | 36 | float DistanceSensor::getMaxDistance() const { return maxDistance; } 37 | 38 | float DistanceSensor::getDistance() const { return distance; } 39 | 40 | } // namespace sensors 41 | 42 | } // namespace tap 43 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/imu/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | def init(module): 19 | module.name = ":communication:sensors:imu" 20 | module.description = "Drivers, OLED menu, and terminal serial handler for various IMU sensors" 21 | 22 | def prepare(module, options): 23 | return True 24 | 25 | def build(env): 26 | env.outbasepath = "taproot/src/tap/communication/sensors/imu" 27 | env.copy("imu_interface.hpp") 28 | env.copy("imu_terminal_serial_handler.hpp") 29 | env.copy("imu_terminal_serial_handler.cpp") 30 | env.copy("abstract_imu.hpp") 31 | env.copy("abstract_imu.cpp") 32 | 33 | if (env.has_module("taproot:display")): 34 | env.copy("imu_menu.hpp") 35 | env.copy("imu_menu.cpp") 36 | -------------------------------------------------------------------------------- /src/tap/control/hold_command_mapping.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "hold_command_mapping.hpp" 21 | 22 | namespace tap 23 | { 24 | namespace control 25 | { 26 | void HoldCommandMapping::executeCommandMapping(const RemoteMapState &currState) 27 | { 28 | if (mappingSubset(currState) && 29 | !(mapState.getNegKeysUsed() && negKeysSubset(mapState, currState))) 30 | { 31 | if (!commandScheduled) 32 | { 33 | commandScheduled = true; 34 | addCommands(); 35 | } 36 | } 37 | else if (commandScheduled) 38 | { 39 | commandScheduled = false; 40 | removeCommands(); 41 | } 42 | } 43 | } // namespace control 44 | } // namespace tap 45 | -------------------------------------------------------------------------------- /test/tap/mock/hold_repeat_command_mapping_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "hold_repeat_command_mapping_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | HoldRepeatCommandMappingMock::HoldRepeatCommandMappingMock( 25 | Drivers *drivers, 26 | const std::vector cmds, 27 | const control::RemoteMapState &rms, 28 | bool endCommandsWhenNotHeld, 29 | int maxTimesToSchedule) 30 | : control::HoldRepeatCommandMapping( 31 | drivers, 32 | cmds, 33 | rms, 34 | endCommandsWhenNotHeld, 35 | maxTimesToSchedule) 36 | { 37 | } 38 | 39 | HoldRepeatCommandMappingMock::~HoldRepeatCommandMappingMock() {} 40 | } // namespace tap::mock 41 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/sensor_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SENSOR_INTERFACE_HPP_ 21 | #define TAPROOT_SENSOR_INTERFACE_HPP_ 22 | 23 | namespace tap::communication::sensors 24 | { 25 | /** 26 | * Interface for generic sensor that requires a periodic update. 27 | * 28 | * This interface may be used in conjunction with a sensor scheduler (see #132). 29 | */ 30 | class SensorInterface 31 | { 32 | public: 33 | /** 34 | * Function that one implements that reads data from the sensor and performs any filtering as 35 | * required. 36 | */ 37 | virtual void update() = 0; 38 | }; 39 | } // namespace tap::communication::sensors 40 | 41 | #endif // TAPROOT_SENSOR_INTERFACE_HPP_ 42 | -------------------------------------------------------------------------------- /src/tap/control/command.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "command.hpp" 21 | 22 | #include "command_scheduler.hpp" 23 | #include "subsystem.hpp" 24 | 25 | namespace tap 26 | { 27 | namespace control 28 | { 29 | Command::Command() : globalIdentifier(CommandScheduler::constructCommand(this)) {} 30 | 31 | Command::~Command() { CommandScheduler::destructCommand(this); } 32 | 33 | void Command::addSubsystemRequirement(Subsystem* requirement) 34 | { 35 | if (requirement == nullptr) 36 | { 37 | return; 38 | } 39 | commandRequirementsBitwise |= (1UL << requirement->getGlobalIdentifier()); 40 | } 41 | 42 | bool Command::isReady() { return true; } 43 | 44 | } // namespace control 45 | } // namespace tap 46 | -------------------------------------------------------------------------------- /src/tap/display/dummy_allocator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_DUMMY_ALLOCATOR_HPP_ 21 | #define TAPROOT_DUMMY_ALLOCATOR_HPP_ 22 | 23 | #include "modm/utils/allocator/allocator_base.hpp" 24 | 25 | namespace tap 26 | { 27 | namespace display 28 | { 29 | template 30 | class DummyAllocator : public modm::allocator::AllocatorBase 31 | { 32 | public: 33 | DummyAllocator() : modm::allocator::AllocatorBase() {} 34 | 35 | DummyAllocator(const DummyAllocator& other) = default; 36 | 37 | T* allocate(size_t) { return nullptr; } 38 | 39 | void deallocate(T*) {} 40 | }; // class DummyAllocator 41 | } // namespace display 42 | } // namespace tap 43 | 44 | #endif // TAPROOT_DUMMY_ALLOCATOR_HPP_ 45 | -------------------------------------------------------------------------------- /test/tap/mock/command_governor_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_COMMAND_GOVERNOR_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_COMMAND_GOVERNOR_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/governor/command_governor_interface.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class CommandGovernorInterfaceMock : public tap::control::governor::CommandGovernorInterface 30 | { 31 | public: 32 | CommandGovernorInterfaceMock(); 33 | ~CommandGovernorInterfaceMock(); 34 | MOCK_METHOD(bool, isReady, (), (override)); 35 | MOCK_METHOD(bool, isFinished, (), (override)); 36 | }; 37 | } // namespace tap::mock 38 | 39 | #endif // TAPROOT_COMMAND_GOVERNOR_INTERFACE_MOCK_HPP_ 40 | -------------------------------------------------------------------------------- /src/tap/motor/m3508_constants.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_M3508_CONSTANTS_HPP_ 21 | #define TAPROOT_M3508_CONSTANTS_HPP_ 22 | 23 | #include "motor_constants.hpp" 24 | 25 | namespace tap::motor 26 | { 27 | class M3508Constants : public MotorConstants 28 | { 29 | public: 30 | /** 31 | * According to the C620 documentation, the current output range is [-16384, 16384] scaled to 32 | * [-20, 20] amps. 33 | */ 34 | inline float convertOutputToCurrent(float output) const override 35 | { 36 | return output * 20000.0f / 16384.0f; 37 | } 38 | 39 | inline float getTorqueConstant() const override { return 0.3; } 40 | }; 41 | } // namespace tap::motor 42 | 43 | #endif // TAPROOT_M3508_CONSTANTS_HPP_ 44 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Test", 5 | "includePath": [ 6 | "${default}", 7 | "test-project/taproot/test", 8 | "test-project/taproot/sim-modm/hosted-linux/modm/src" 9 | ], 10 | "defines": ["${default}", "ENV_UNIT_TESTS", "PLATFORM_HOSTED", "RUN_WITH_PROFILING"], 11 | "intelliSenseMode": "gcc-x64", 12 | "browse": { "limitSymbolsToIncludedHeaders": true }, 13 | "compilerPath": "g++" 14 | }, 15 | { 16 | "name": "Sim", 17 | "includePath": [ 18 | "${default}", 19 | "test-project/taproot/sim-modm/hosted-linux/modm/src" 20 | ], 21 | "defines": ["${default}", "PLATFORM_HOSTED", "RUN_WITH_PROFILING"], 22 | "intelliSenseMode": "gcc-x64", 23 | "browse": { "limitSymbolsToIncludedHeaders": true }, 24 | "compilerPath": "g++" 25 | }, 26 | { 27 | "name": "MCB", 28 | "includePath": [ 29 | "${default}", 30 | "test-project/taproot/modm/src", 31 | "test-project/taproot/modm/ext/cmsis/core", 32 | "test-project/taproot/modm/ext/cmsis/device", 33 | ], 34 | "intelliSenseMode": "gcc-arm", 35 | "browse": { "limitSymbolsToIncludedHeaders": true }, 36 | "compilerPath": "arm-none-eabi-g++" 37 | } 38 | ], 39 | "version": 4 40 | } 41 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/current/current_sensor_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CURRENT_SENSOR_INTERFACE_HPP_ 21 | #define TAPROOT_CURRENT_SENSOR_INTERFACE_HPP_ 22 | 23 | #include "tap/communication/sensors/sensor_interface.hpp" 24 | 25 | namespace tap::communication::sensors::current 26 | { 27 | /** 28 | * Interface for a generic current sensor. 29 | */ 30 | class CurrentSensorInterface : public tap::communication::sensors::SensorInterface 31 | { 32 | public: 33 | /** 34 | * @return The current read by the current sensor, in milliamps. 35 | */ 36 | virtual float getCurrentMa() const = 0; 37 | }; 38 | } // namespace tap::communication::sensors::current 39 | 40 | #endif // TAPROOT_CURRENT_SENSOR_INTERFACE_HPP_ 41 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/voltage/voltage_sensor_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_VOLTAGE_SENSOR_INTERFACE_HPP_ 21 | #define TAPROOT_VOLTAGE_SENSOR_INTERFACE_HPP_ 22 | 23 | #include "tap/communication/sensors/sensor_interface.hpp" 24 | 25 | namespace tap::communication::sensors::voltage 26 | { 27 | /** 28 | * Interface for a generic voltage sensor. 29 | */ 30 | class VoltageSensorInterface : public tap::communication::sensors::SensorInterface 31 | { 32 | public: 33 | /** 34 | * @return The voltage read by the voltage sensor, in millivolts. 35 | */ 36 | virtual float getVoltageMv() const = 0; 37 | }; 38 | } // namespace tap::communication::sensors::voltage 39 | 40 | #endif // TAPROOT_CURRENT_SENSOR_INTERFACE_HPP_ 41 | -------------------------------------------------------------------------------- /src/tap/motor/dji_motor_ids.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_DJI_MOTOR_IDS_HPP_ 21 | #define TAPROOT_DJI_MOTOR_IDS_HPP_ 22 | 23 | #include 24 | 25 | namespace tap::motor 26 | { 27 | /** 28 | * CAN IDs for the feedback messages sent by DJI motor controllers. Motor `i` in the set 29 | * {1, 2,...,8} sends feedback data with in a CAN message with ID 0x200 + `i`. 30 | * for declaring a new motor, must be one of these motor 31 | * identifiers 32 | */ 33 | enum MotorId : uint32_t 34 | { 35 | MOTOR1 = 0X201, 36 | MOTOR2 = 0x202, 37 | MOTOR3 = 0x203, 38 | MOTOR4 = 0x204, 39 | MOTOR5 = 0x205, 40 | MOTOR6 = 0x206, 41 | MOTOR7 = 0x207, 42 | MOTOR8 = 0x208, 43 | }; 44 | } // namespace tap::motor 45 | 46 | #endif // TAPROOT_DJI_MOTOR_IDS_HPP_ 47 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/buzzer/buzzer.cpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "buzzer.hpp" 21 | 22 | #include "tap/algorithms/math_user_utils.hpp" 23 | #include "tap/communication/gpio/pwm.hpp" 24 | 25 | #include "modm/architecture/interface/delay.hpp" 26 | 27 | namespace tap::buzzer 28 | { 29 | void playNote(gpio::Pwm *pwmController, uint32_t frequency) 30 | { 31 | if (frequency == 0) 32 | { 33 | silenceBuzzer(pwmController); 34 | } 35 | else 36 | { 37 | pwmController->write(0.5f, gpio::Pwm::Buzzer); 38 | pwmController->setTimerFrequency(gpio::Pwm::{{ buzzer_timer|upper }}, frequency); 39 | } 40 | } 41 | 42 | void silenceBuzzer(gpio::Pwm *pwmController) { pwmController->write(0, gpio::Pwm::Buzzer); } 43 | } // namespace tap::buzzer 44 | -------------------------------------------------------------------------------- /src/tap/communication/serial/uart_terminal_device.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "uart_terminal_device.hpp" 21 | 22 | #include "tap/drivers.hpp" 23 | 24 | namespace tap::communication::serial 25 | { 26 | UartTerminalDevice::UartTerminalDevice(Drivers *drivers) : drivers(drivers) {} 27 | 28 | void UartTerminalDevice::initialize() { drivers->uart.init(); } 29 | 30 | bool UartTerminalDevice::read(char &c) 31 | { 32 | return drivers->uart.read(TERMINAL_UART_PORT, &reinterpret_cast(c)); 33 | } 34 | 35 | void UartTerminalDevice::write(char c) { drivers->uart.write(TERMINAL_UART_PORT, c); } 36 | 37 | void UartTerminalDevice::flush() { drivers->uart.flushWriteBuffer(TERMINAL_UART_PORT); } 38 | } // namespace tap::communication::serial 39 | -------------------------------------------------------------------------------- /src/tap/algorithms/strtok.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef __DOXYGEN__ 21 | 22 | #include "strtok.hpp" 23 | 24 | #include 25 | 26 | char *strtokR(char *s, const char *delim, char **savePtr) 27 | { 28 | char *end; 29 | 30 | if (s == nullptr) 31 | { 32 | s = *savePtr; 33 | } 34 | 35 | if (*s == '\0') 36 | { 37 | *savePtr = s; 38 | return nullptr; 39 | } 40 | 41 | s += strspn(s, delim); 42 | if (*s == '\0') 43 | { 44 | *savePtr = s; 45 | return nullptr; 46 | } 47 | 48 | end = s + strcspn(s, delim); 49 | if (*end == '\0') 50 | { 51 | *savePtr = end; 52 | return s; 53 | } 54 | 55 | *end = '\0'; 56 | *savePtr = end + 1; 57 | return s; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/tap/motor/motor_constants.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_MOTOR_CONSTANTS_HPP_ 21 | #define TAPROOT_MOTOR_CONSTANTS_HPP_ 22 | 23 | namespace tap::motor 24 | { 25 | /** 26 | * An interface to store motor constants and conversions. 27 | */ 28 | class MotorConstants 29 | { 30 | public: 31 | /** 32 | * @return the corresponding output in mA for a given raw motor output value (the one that you 33 | * directly send to the motor/receive from the motor) 34 | */ 35 | virtual inline float convertOutputToCurrent(float output) const = 0; 36 | /** 37 | * @return The motor torque constant, in N * m. 38 | */ 39 | virtual inline float getTorqueConstant() const = 0; 40 | }; 41 | } // namespace tap::motor 42 | 43 | #endif // TAPROOT_MOTOR_CONSTANTS_HPP_ 44 | -------------------------------------------------------------------------------- /src/tap/display/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | # TODO this module needs some cleaning up, see this issue: https://gitlab.com/aruw/controls/taproot/-/issues/51 19 | 20 | def init(module): 21 | module.name = ":display" 22 | module.description = "Support for displaying information on an OLED display." \ 23 | "Currently this module contains sh1106-specific display code as well as " \ 24 | "generic menu objects that you can use. This software is designed and tested " \ 25 | "to be used on the RoboMaster Development Board OLED " \ 26 | "(https://www.robomaster.com/en-US/products/components/general/development-board)" 27 | 28 | def prepare(module, options): 29 | module.depends(":core") 30 | 31 | return True 32 | 33 | def build(env): 34 | env.outbasepath = "taproot/src/tap/display" 35 | env.copy(".") 36 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "dji_motor_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | DjiMotorMock::DjiMotorMock( 25 | Drivers *drivers, 26 | tap::motor::MotorId desMotorIdentifier, 27 | tap::can::CanBus motorCanBus, 28 | bool isInverted, 29 | const char *name, 30 | bool currentControl, 31 | float gearRatio, 32 | uint32_t encoderHomePosition, 33 | tap::encoder::EncoderInterface *externalEncoder) 34 | : DjiMotor( 35 | drivers, 36 | desMotorIdentifier, 37 | motorCanBus, 38 | isInverted, 39 | name, 40 | currentControl, 41 | gearRatio, 42 | encoderHomePosition, 43 | externalEncoder) 44 | { 45 | } 46 | DjiMotorMock::~DjiMotorMock() {} 47 | } // namespace tap::mock 48 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/buzzer/buzzer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_BUZZER_HPP_ 21 | #define TAPROOT_BUZZER_HPP_ 22 | 23 | #include 24 | 25 | namespace tap 26 | { 27 | namespace gpio 28 | { 29 | class Pwm; 30 | } 31 | 32 | namespace buzzer 33 | { 34 | /** 35 | * Plays the buzzer at the given frequency. 36 | * 37 | * @param[in] pwmController The PWM object that has access to the buzzer. 38 | * @param[in] frequency The PWM freqneucy that corresponds to a pitch. 39 | */ 40 | void playNote(gpio::Pwm *pwmController, uint32_t frequency); 41 | 42 | /** 43 | * Silences the buzzer. 44 | * 45 | * @param[in] pwmController the PWM object that has access to the buzzer. 46 | */ 47 | void silenceBuzzer(gpio::Pwm *pwmController); 48 | } // namespace buzzer 49 | } // namespace tap 50 | 51 | #endif // TAPROOT_BUZZER_HPP_ 52 | -------------------------------------------------------------------------------- /test/tap/mock/can_rx_listener_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CAN_RX_LISTENER_MOCK_HPP_ 21 | #define TAPROOT_CAN_RX_LISTENER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "tap/communication/can/can_rx_listener.hpp" 28 | 29 | #include "modm/architecture/interface/can_message.hpp" 30 | 31 | namespace tap 32 | { 33 | namespace mock 34 | { 35 | class CanRxListenerMock : public tap::can::CanRxListener 36 | { 37 | public: 38 | CanRxListenerMock(tap::Drivers* drivers, uint32_t id, tap::can::CanBus bus); 39 | virtual ~CanRxListenerMock(); 40 | 41 | MOCK_METHOD(void, processMessage, (const modm::can::Message& message), (override)); 42 | 43 | }; // class CanRxListenerMock 44 | } // namespace mock 45 | } // namespace tap 46 | 47 | #endif // TAPROOT_CAN_RX_LISTENER_MOCK_HPP_ 48 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/current/analog_current_sensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "analog_current_sensor.hpp" 21 | 22 | #include "tap/algorithms/math_user_utils.hpp" 23 | 24 | using namespace tap::algorithms; 25 | 26 | namespace tap::communication::sensors::current 27 | { 28 | AnalogCurrentSensor::AnalogCurrentSensor(const Config &config) : config(config) {} 29 | 30 | float AnalogCurrentSensor::getCurrentMa() const { return prevCurrent; } 31 | 32 | void AnalogCurrentSensor::update() 33 | { 34 | prevCurrent = lowPassFilter( 35 | prevCurrent, 36 | abs(static_cast(config.analogDriver->read(config.analogSensorPin)) - 37 | config.currentSensorZeroMv) * 38 | config.currentSensorMaPerMv, 39 | config.currentSensorLowPassAlpha); 40 | } 41 | 42 | } // namespace tap::communication::sensors::current 43 | -------------------------------------------------------------------------------- /test/tap/mock/terminal_serial_callback_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_TERMINAL_SERIAL_CALLBACK_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_TERMINAL_SERIAL_CALLBACK_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/serial/terminal_serial.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class TerminalSerialCallbackInterfaceMock 30 | : public tap::communication::serial::TerminalSerialCallbackInterface 31 | { 32 | public: 33 | TerminalSerialCallbackInterfaceMock(); 34 | ~TerminalSerialCallbackInterfaceMock(); 35 | 36 | MOCK_METHOD(bool, terminalSerialCallback, (char *, modm::IOStream &, bool), (override)); 37 | MOCK_METHOD(void, terminalSerialStreamCallback, (modm::IOStream &), (override)); 38 | }; 39 | } // namespace tap::mock 40 | 41 | #endif // TAPROOT_TERMINAL_SERIAL_CALLBACK_INTERFACE_MOCK_HPP_ 42 | -------------------------------------------------------------------------------- /src/tap/util_macros.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_UTIL_MACROS_HPP_ 21 | #define TAPROOT_UTIL_MACROS_HPP_ 22 | 23 | #define DISALLOW_COPY_AND_ASSIGN(Typename) \ 24 | Typename(const Typename &) = delete; \ 25 | Typename &operator=(const Typename &) = delete; 26 | 27 | #ifdef PLATFORM_HOSTED 28 | /// Wrap class functions that are not already virtual in this function if you wish to mock them. 29 | #define mockable virtual 30 | /// Use this instead of final if you want to mock a function when unit testing. 31 | #define final_mockable 32 | #else 33 | /// Wrap class functions that are not already virtual in this function if you wish to mock them. 34 | #define mockable 35 | /// Use this instead of final if you want to mock a function when unit testing. 36 | #define final_mockable final 37 | #endif 38 | 39 | #define UNUSED(var) (void)(var) 40 | 41 | #endif // TAPROOT_UTIL_MACROS_HPP_ 42 | -------------------------------------------------------------------------------- /test/tap/mock/scheduler_terminal_handler_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SCHEDULER_TERMINAL_HANDLER_MOCK_HPP_ 21 | #define TAPROOT_SCHEDULER_TERMINAL_HANDLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/scheduler_terminal_handler.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class SchedulerTerminalHandlerMock : public control::SchedulerTerminalHandler 32 | { 33 | public: 34 | SchedulerTerminalHandlerMock(Drivers *drivers); 35 | virtual ~SchedulerTerminalHandlerMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(bool, terminalSerialCallback, (char *, modm::IOStream &, bool), (override)); 39 | MOCK_METHOD(void, terminalSerialStreamCallback, (modm::IOStream &), (override)); 40 | }; 41 | } // namespace mock 42 | } // namespace tap 43 | 44 | #endif // TAPROOT_SCHEDULER_TERMINAL_HANDLER_MOCK_HPP_ 45 | -------------------------------------------------------------------------------- /src/tap/architecture/clock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #if defined(PLATFORM_HOSTED) && defined(ENV_UNIT_TESTS) 21 | 22 | #include "clock.hpp" 23 | 24 | #include "modm/architecture/interface/assert.h" 25 | 26 | namespace tap::arch::clock 27 | { 28 | static ClockStub *globalStubInstance = nullptr; 29 | 30 | ClockStub::ClockStub() 31 | { 32 | modm_assert( 33 | globalStubInstance == nullptr, 34 | "ClockStub", 35 | "multiple clock stubs defined at the same time"); 36 | globalStubInstance = this; 37 | } 38 | ClockStub::~ClockStub() { globalStubInstance = nullptr; } 39 | 40 | uint32_t getTimeMilliseconds() 41 | { 42 | return globalStubInstance == nullptr ? 0 : globalStubInstance->time; 43 | } 44 | 45 | uint32_t getTimeMicroseconds() 46 | { 47 | return globalStubInstance == nullptr ? 0 : 1000 * globalStubInstance->time; 48 | } 49 | } // namespace tap::arch::clock 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/tap/mock/pwm_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_PWM_MOCK_HPP_ 21 | #define TAPROOT_PWM_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/gpio/pwm.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class PwmMock : public tap::gpio::Pwm 32 | { 33 | public: 34 | PwmMock(); 35 | virtual ~PwmMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(void, writeAllZeros, (), (override)); 39 | MOCK_METHOD(void, write, (float duty, tap::gpio::Pwm::Pin), (override)); 40 | MOCK_METHOD(void, setTimerFrequency, (tap::gpio::Pwm::Timer, uint32_t), (override)); 41 | MOCK_METHOD(void, pause, (tap::gpio::Pwm::Timer), (override)); 42 | MOCK_METHOD(void, start, (tap::gpio::Pwm::Timer), (override)); 43 | }; // class PwmMock 44 | } // namespace mock 45 | } // namespace tap 46 | 47 | #endif // TAPROOT_PWM_MOCK_HPP_ 48 | -------------------------------------------------------------------------------- /test/tap/mock/terminal_serial_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_TERMINAL_SERIAL_MOCK_HPP_ 21 | #define TAPROOT_TERMINAL_SERIAL_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/serial/terminal_serial.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class TerminalSerialMock : public communication::serial::TerminalSerial 32 | { 33 | public: 34 | TerminalSerialMock(Drivers *drivers); 35 | virtual ~TerminalSerialMock(); 36 | 37 | MOCK_METHOD(void, initialize, (), (override)); 38 | MOCK_METHOD(void, update, (), (override)); 39 | MOCK_METHOD( 40 | void, 41 | addHeader, 42 | (const char *, communication::serial::TerminalSerialCallbackInterface *), 43 | (override)); 44 | }; // class TerminalSerialMock 45 | } // namespace mock 46 | } // namespace tap 47 | 48 | #endif // TAPROOT_TERMINAL_SERIAL_MOCK_HPP_ 49 | -------------------------------------------------------------------------------- /src/tap/algorithms/linear_interpolation_predictor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "linear_interpolation_predictor.hpp" 21 | 22 | namespace tap::algorithms 23 | { 24 | LinearInterpolationPredictor::LinearInterpolationPredictor() 25 | : lastUpdateCallTime(0), 26 | previousValue(0.0f), 27 | slope(0.0f) 28 | { 29 | } 30 | 31 | void LinearInterpolationPredictor::update(float newValue, uint32_t currTime) 32 | { 33 | if (currTime <= lastUpdateCallTime) 34 | { 35 | slope = 0.0f; 36 | return; 37 | } 38 | slope = (newValue - previousValue) / (currTime - lastUpdateCallTime); 39 | previousValue = newValue; 40 | lastUpdateCallTime = currTime; 41 | } 42 | 43 | void LinearInterpolationPredictor::reset(float initialValue, uint32_t initialTime) 44 | { 45 | previousValue = initialValue; 46 | lastUpdateCallTime = initialTime; 47 | slope = 0.0f; 48 | } 49 | } // namespace tap::algorithms 50 | -------------------------------------------------------------------------------- /src/tap/errors/system_error.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SYSTEM_ERROR_HPP_ 21 | #define TAPROOT_SYSTEM_ERROR_HPP_ 22 | 23 | namespace tap::errors 24 | { 25 | class SystemError 26 | { 27 | public: 28 | constexpr SystemError() : lineNumber(0), description("default"), filename("none") {} 29 | 30 | constexpr SystemError(const char *desc, int line, const char *file) 31 | : lineNumber(line), 32 | description(desc), 33 | filename(file) 34 | { 35 | } 36 | 37 | constexpr int getLineNumber() const { return lineNumber; } 38 | 39 | const char *getDescription() const { return description; } 40 | 41 | const char *getFilename() const { return filename; } 42 | 43 | private: 44 | int lineNumber; 45 | 46 | const char *description; 47 | 48 | const char *filename; 49 | }; // class SystemError 50 | } // namespace tap::errors 51 | 52 | #endif // TAPROOT_SYSTEM_ERROR_HPP_ 53 | -------------------------------------------------------------------------------- /test/tap/mock/robot_to_robot_message_handler_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ROBOT_TO_ROBOT_MESSAGE_HANDLER_MOCK_HPP_ 21 | #define TAPROOT_ROBOT_TO_ROBOT_MESSAGE_HANDLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/serial/ref_serial.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class RobotToRobotMessageHandlerMock 30 | : public tap::communication::serial::RefSerial::RobotToRobotMessageHandler 31 | { 32 | public: 33 | RobotToRobotMessageHandlerMock(); 34 | MOCK_METHOD1( 35 | functorOp, 36 | void(const tap::communication::serial::DJISerial::ReceivedSerialMessage &)); 37 | void operator()( 38 | const tap::communication::serial::DJISerial::ReceivedSerialMessage &message) override 39 | { 40 | return functorOp(message); 41 | } 42 | }; 43 | } // namespace tap::mock 44 | 45 | #endif // TAPROOT_ROBOT_TO_ROBOT_MESSAGE_HANDLER_MOCK_HPP_ 46 | -------------------------------------------------------------------------------- /lbuild-scripts/board_info_parser.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | import glob 19 | import lxml 20 | 21 | from lbuild_utils import repo_path_rel_repolb 22 | 23 | parsed_board_info = {} 24 | 25 | def parse_board_info(device): 26 | global parsed_board_info 27 | 28 | device_file_names = glob.glob(str(repo_path_rel_repolb(__file__, "supported-devices/*.xml"))) 29 | device_file_names = [dfn for dfn in device_file_names if device in dfn] 30 | assert len(device_file_names) == 1, f"Device {device} not found or there are multiple device files with the device name" 31 | device = device_file_names[0] 32 | 33 | if device not in parsed_board_info: 34 | # parse the xml-file if we haven't already 35 | parser = lxml.etree.XMLParser(no_network=True) 36 | xmlroot = lxml.etree.parse(device_file_names[0], parser=parser) 37 | xmlroot.xinclude() 38 | parsed_board_info[device] = xmlroot.getroot() 39 | 40 | return parsed_board_info[device] 41 | -------------------------------------------------------------------------------- /test/tap/mock/digital_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_DIGITAL_MOCK_HPP_ 21 | #define TAPROOT_DIGITAL_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/gpio/digital.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class DigitalMock : public tap::gpio::Digital 32 | { 33 | public: 34 | DigitalMock(); 35 | virtual ~DigitalMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD( 39 | void, 40 | configureInputPullMode, 41 | (tap::gpio::Digital::InputPin pin, tap::gpio::Digital::InputPullMode mode), 42 | (override)); 43 | MOCK_METHOD(void, set, (tap::gpio::Digital::OutputPin pin, bool isSet), (override)); 44 | MOCK_METHOD(bool, read, (tap::gpio::Digital::InputPin pin), (const override)); 45 | }; // class DigitalMock 46 | } // namespace mock 47 | } // namespace tap 48 | 49 | #endif // TAPROOT_DIGITAL_MOCK_HPP_ 50 | -------------------------------------------------------------------------------- /src/tap/communication/can/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | import sys 19 | sys.path.append(repopath("scripts/lbuild-helpers")) 20 | import board_info_parser 21 | 22 | def init(module): 23 | module.name = ":communication:can" 24 | module.description = "CAN I/O interface wrappers" 25 | 26 | def prepare(module, options): 27 | return True 28 | 29 | def build(env): 30 | metadata = board_info_parser.parse_board_info(env[":dev_board"]) 31 | 32 | can_pins = metadata.find("can-pins") 33 | can_pins = { pin.get("alias"): pin.get("name") for pin in can_pins } 34 | 35 | env.substitutions = { 36 | "can_pins": can_pins, 37 | } 38 | 39 | env.outbasepath = "taproot/src/tap/communication/can" 40 | env.copy("can_bus.hpp") 41 | env.copy("can_rx_handler.cpp") 42 | env.copy("can_rx_handler.hpp") 43 | env.copy("can_rx_listener.cpp") 44 | env.copy("can_rx_listener.hpp") 45 | env.copy("can.hpp") 46 | env.template("can.cpp.in", "can.cpp") 47 | -------------------------------------------------------------------------------- /test/tap/control/test_command.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_TEST_COMMAND_HPP_ 21 | #define TAPROOT_TEST_COMMAND_HPP_ 22 | 23 | #include "tap/control/command.hpp" 24 | 25 | #include "test_subsystem.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace control 30 | { 31 | class TestCommand : public tap::control::Command 32 | { 33 | public: 34 | TestCommand(TestSubsystem *ts) : finished(false), s(ts) { addSubsystemRequirement(s); } 35 | 36 | void initialize() override {} 37 | void execute() override {} 38 | void end(bool) override {} 39 | bool isFinished() const override { return finished; } 40 | const char *getName() const override { return "test command"; } 41 | void setFinished(bool finished) { this->finished = finished; } 42 | 43 | private: 44 | bool finished; 45 | TestSubsystem *s; 46 | }; // TestCommand 47 | } // namespace control 48 | } // namespace tap 49 | 50 | #endif // TAPROOT_TEST_COMMAND_HPP_ 51 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_terminal_serial_handler_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_DJI_MOTOR_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 21 | #define TAPROOT_DJI_MOTOR_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/motor/dji_motor_terminal_serial_handler.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class DjiMotorTerminalSerialHandlerMock : public motor::DjiMotorTerminalSerialHandler 32 | { 33 | public: 34 | DjiMotorTerminalSerialHandlerMock(Drivers *drivers); 35 | virtual ~DjiMotorTerminalSerialHandlerMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(bool, terminalSerialCallback, (char *, modm::IOStream &, bool), (override)); 39 | MOCK_METHOD(void, terminalSerialStreamCallback, (modm::IOStream &), (override)); 40 | }; 41 | } // namespace mock 42 | } // namespace tap 43 | 44 | #endif // TAPROOT_DJI_MOTOR_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 45 | -------------------------------------------------------------------------------- /test/tap/mock/imu_terminal_serial_handler_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_IMU_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 21 | #define TAPROOT_IMU_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/sensors/imu/imu_terminal_serial_handler.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class ImuTerminalSerialHandlerMock : public communication::sensors::imu::ImuTerminalSerialHandler 30 | { 31 | public: 32 | ImuTerminalSerialHandlerMock( 33 | tap::Drivers* drivers, 34 | communication::sensors::imu::AbstractIMU* imu); 35 | virtual ~ImuTerminalSerialHandlerMock(); 36 | 37 | MOCK_METHOD(void, init, (), (override)); 38 | MOCK_METHOD(bool, terminalSerialCallback, (char*, modm::IOStream&, bool), (override)); 39 | MOCK_METHOD(void, terminalSerialStreamCallback, (modm::IOStream&), (override)); 40 | }; 41 | } // namespace tap::mock 42 | 43 | #endif // TAPROOT_IMU_TERMINAL_SERIAL_HANDLER_MOCK_HPP_ 44 | -------------------------------------------------------------------------------- /test/tap/mock/encoder_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ENCODER_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_ENCODER_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/sensors/encoder/encoder_interface.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class EncoderInterfaceMock : public tap::encoder::EncoderInterface 30 | { 31 | public: 32 | EncoderInterfaceMock(); 33 | virtual ~EncoderInterfaceMock(); 34 | 35 | MOCK_METHOD(void, initialize, (), (override)); 36 | 37 | MOCK_METHOD(bool, isOnline, (), (const override)); 38 | 39 | MOCK_METHOD(tap::algorithms::WrappedFloat, getPosition, (), (const override)); 40 | 41 | MOCK_METHOD(float, getVelocity, (), (const override)); 42 | 43 | MOCK_METHOD(void, resetEncoderValue, (), (override)); 44 | 45 | MOCK_METHOD(void, alignWith, (EncoderInterface*), (override)); 46 | }; 47 | 48 | } // namespace tap::mock 49 | 50 | #endif // TAPROOT_ENCODER_INTERFACE_MOCK_HPP_ 51 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/buzzer/module.lb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 2 | # 3 | # This file is part of Taproot. 4 | # 5 | # Taproot is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Taproot is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Taproot. If not, see . 17 | 18 | import sys 19 | sys.path.append(repopath("scripts/lbuild-helpers")) 20 | import board_info_parser 21 | 22 | BUZZER_PIN = "Buzzer" 23 | 24 | buzzer_timer = None 25 | 26 | def init(module): 27 | module.name = ":communication:sensors:buzzer" 28 | module.description = "Analog buzzer API" 29 | 30 | def prepare(module, options): 31 | metadata = board_info_parser.parse_board_info(options[":dev_board"]) 32 | pins = metadata.find("gpio-pins") 33 | buzzer_pins = [pin for pin in pins if pin.get("alias") == BUZZER_PIN] 34 | if len(buzzer_pins) == 1: 35 | global buzzer_timer 36 | buzzer_timer = buzzer_pins[0].find("timer").get("name") 37 | return len(buzzer_pins) == 1 38 | 39 | def build(env): 40 | global buzzer_timer 41 | env.outbasepath = "taproot/src/tap/communication/sensors/buzzer" 42 | env.substitutions = {"buzzer_timer": buzzer_timer} 43 | env.template("buzzer.cpp.in", "buzzer.cpp") 44 | env.copy("buzzer.hpp") 45 | -------------------------------------------------------------------------------- /test/tap/mock/error_controller_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ERROR_CONTROLLER_MOCK_HPP_ 21 | #define TAPROOT_ERROR_CONTROLLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "tap/errors/error_controller.hpp" 28 | 29 | /** 30 | * @param[in] error Error to check. 31 | * @param[in] substr Substring to check in the error description for. 32 | */ 33 | bool errorDescriptionContainsSubstr( 34 | const tap::errors::SystemError& error, 35 | const std::string& substr); 36 | 37 | namespace tap 38 | { 39 | namespace mock 40 | { 41 | class ErrorControllerMock : public tap::errors::ErrorController 42 | { 43 | public: 44 | ErrorControllerMock(tap::Drivers* drivers); 45 | virtual ~ErrorControllerMock(); 46 | 47 | MOCK_METHOD(void, addToErrorList, (const tap::errors::SystemError& error), (override)); 48 | }; // class ErrorControllerMock 49 | } // namespace mock 50 | } // namespace tap 51 | 52 | #endif // TAPROOT_ERROR_CONTROLLER_MOCK_HPP_ 53 | -------------------------------------------------------------------------------- /src/tap/control/setpoint/commands/calibrate_command.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "calibrate_command.hpp" 21 | 22 | #include "tap/control/setpoint/interfaces/setpoint_subsystem.hpp" 23 | #include "tap/control/subsystem.hpp" 24 | 25 | using tap::control::setpoint::SetpointSubsystem; 26 | 27 | namespace tap::control::setpoint 28 | { 29 | CalibrateCommand::CalibrateCommand(SetpointSubsystem* setpointSubsystem) 30 | : setpointSubsystem(setpointSubsystem) 31 | { 32 | this->addSubsystemRequirement(setpointSubsystem); 33 | } 34 | 35 | bool CalibrateCommand::isReady() { return setpointSubsystem->isOnline(); } 36 | 37 | // No initialization necessary 38 | void CalibrateCommand::initialize() { calibrationSuccessful = false; } 39 | 40 | void CalibrateCommand::execute() { calibrationSuccessful = setpointSubsystem->calibrateHere(); } 41 | 42 | void CalibrateCommand::end(bool) {} 43 | 44 | bool CalibrateCommand::isFinished() const { return calibrationSuccessful; } 45 | 46 | } // namespace tap::control::setpoint 47 | -------------------------------------------------------------------------------- /test/tap/mock/can_rx_handler_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CAN_RX_HANDLER_MOCK_HPP_ 21 | #define TAPROOT_CAN_RX_HANDLER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "tap/communication/can/can_rx_handler.hpp" 28 | #include "tap/communication/can/can_rx_listener.hpp" 29 | 30 | namespace tap 31 | { 32 | namespace mock 33 | { 34 | class CanRxHandlerMock : public tap::can::CanRxHandler 35 | { 36 | public: 37 | CanRxHandlerMock(tap::Drivers* drivers); 38 | virtual ~CanRxHandlerMock(); 39 | 40 | MOCK_METHOD(void, attachReceiveHandler, (tap::can::CanRxListener* const listener), (override)); 41 | MOCK_METHOD(void, pollCanData, (), (override)); 42 | MOCK_METHOD( 43 | void, 44 | removeReceiveHandler, 45 | (const tap::can::CanRxListener& rxListener), 46 | (override)); 47 | }; // class CanRxHandlerMock 48 | } // namespace mock 49 | } // namespace tap 50 | 51 | #endif // TAPROOT_CAN_RX_HANDLER_MOCK_HPP_ 52 | -------------------------------------------------------------------------------- /src/tap/errors/create_errors.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CREATE_ERRORS_HPP_ 21 | #define TAPROOT_CREATE_ERRORS_HPP_ 22 | 23 | #include "system_error.hpp" 24 | 25 | namespace tap::errors 26 | { 27 | /** 28 | * Example for how to create and add an error. `drivers` is a pointer to an 29 | * `tap::Drivers`, which contains an instance of an `ErrorController`. 30 | * 31 | * @see ErrorController 32 | * @see SystemError 33 | * 34 | * ```cpp 35 | * RAISE_ERROR(drivers, "CRC8 failure"); 36 | * ``` 37 | */ 38 | #define RAISE_ERROR(drivers, desc) \ 39 | do \ 40 | { \ 41 | tap::errors::SystemError stringError(desc, __LINE__, __FILE__); \ 42 | drivers->errorController.addToErrorList(stringError); \ 43 | } while (0); 44 | 45 | } // namespace tap::errors 46 | 47 | #endif // TAPROOT_TAPROOT_CREATE_ERRORS_HPP_ 48 | -------------------------------------------------------------------------------- /test/tap/mock/odometry_2d_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ODOMETRY_2D_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_ODOMETRY_2D_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/algorithms/odometry/odometry_2d_interface.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class Odometry2DInterfaceMock : public algorithms::odometry::Odometry2DInterface 30 | { 31 | public: 32 | MOCK_METHOD(modm::Location2D, getCurrentLocation2D, (), (const override)); 33 | MOCK_METHOD(modm::Vector2f, getCurrentVelocity2D, (), (const override)); 34 | MOCK_METHOD(uint32_t, getLastComputedOdometryTime, (), (const override)); 35 | MOCK_METHOD(float, getYaw, (), (const override)); 36 | MOCK_METHOD( 37 | void, 38 | overrideOdometryPosition, 39 | (const float positionX, const float positionY), 40 | (override)); 41 | MOCK_METHOD(void, reset, (), (override)); 42 | }; 43 | } // namespace tap::mock 44 | 45 | #endif // TAPROOT_ODOMETRY_2D_INTERFACE_MOCK_HPP_ 46 | -------------------------------------------------------------------------------- /src/tap/algorithms/fuzzy_pd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "fuzzy_pd.hpp" 21 | 22 | #include "tap/algorithms/math_user_utils.hpp" 23 | 24 | using namespace tap::algorithms; 25 | 26 | namespace tap::algorithms 27 | { 28 | FuzzyPD::FuzzyPD(const FuzzyPDConfig &pidConfig, const SmoothPidConfig &smoothPidConfig) 29 | : SmoothPid(smoothPidConfig), 30 | config(pidConfig) 31 | { 32 | } 33 | 34 | float FuzzyPD::runController(float error, float errorDerivative, float dt) 35 | { 36 | udpatePidGains( 37 | limitVal(error / config.maxError, -1.0f, 1.0f), 38 | limitVal(errorDerivative / config.maxErrorDerivative, -1.0f, 1.0f)); 39 | return SmoothPid::runController(error, errorDerivative, dt); 40 | } 41 | 42 | void FuzzyPD::udpatePidGains(float error, float errorDerivative) 43 | { 44 | config.fuzzyTable.performFuzzyUpdate(error, errorDerivative); 45 | 46 | setP(config.fuzzyTable.getFuzzyGains()[0][0]); 47 | setD(config.fuzzyTable.getFuzzyGains()[1][0]); 48 | } 49 | 50 | } // namespace tap::algorithms 51 | -------------------------------------------------------------------------------- /test/tap/mock/can_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CAN_MOCK_HPP_ 21 | #define TAPROOT_CAN_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/can/can.hpp" 26 | 27 | #include "modm/architecture/interface/can_message.hpp" 28 | 29 | namespace tap 30 | { 31 | namespace mock 32 | { 33 | class CanMock : public tap::can::Can 34 | { 35 | public: 36 | CanMock(); 37 | virtual ~CanMock(); 38 | 39 | MOCK_METHOD(void, initialize, (), (override)); 40 | MOCK_METHOD(bool, isMessageAvailable, (tap::can::CanBus bus), (const override)); 41 | MOCK_METHOD(bool, getMessage, (tap::can::CanBus bus, modm::can::Message *message), (override)); 42 | MOCK_METHOD(bool, isReadyToSend, (tap::can::CanBus bus), (const override)); 43 | MOCK_METHOD( 44 | bool, 45 | sendMessage, 46 | (tap::can::CanBus bus, const modm::can::Message &message), 47 | (override)); 48 | }; // class CanMock 49 | } // namespace mock 50 | } // namespace tap 51 | 52 | #endif // TAPROOT_CAN_MOCK_HPP_ 53 | -------------------------------------------------------------------------------- /test/tap/mock/hold_repeat_command_mapping_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_MOCK_HPP_ 21 | #define TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/hold_repeat_command_mapping.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class HoldRepeatCommandMappingMock : public control::HoldRepeatCommandMapping 30 | { 31 | public: 32 | HoldRepeatCommandMappingMock( 33 | Drivers *drivers, 34 | const std::vector cmds, 35 | const control::RemoteMapState &rms, 36 | bool endCommandsWhenNotHeld, 37 | int maxTimesToSchedule = -1); 38 | virtual ~HoldRepeatCommandMappingMock(); 39 | 40 | MOCK_METHOD(void, executeCommandMapping, (const tap::control::RemoteMapState &), (override)); 41 | MOCK_METHOD(void, setMaxTimesToSchedule, (int), (override)); 42 | }; // class HoldRepeatCommandMappingMock 43 | } // namespace tap::mock 44 | 45 | #endif // TAPROOT_HOLD_REPEAT_COMMAND_MAPPING_MOCK_HPP_ 46 | -------------------------------------------------------------------------------- /src/tap/display/sh1106_mock_impl.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SH1106_HPP_ 21 | #error "Don't include this file directly, use 'sh1106.hpp' instead!" 22 | #endif 23 | 24 | template 25 | modm::ResumableResult tap::display::Sh1106::updateNonblocking() 26 | { 27 | RF_BEGIN(0); 28 | // no-op 29 | RF_END_RETURN(false); 30 | } 31 | 32 | template 33 | void tap::display::Sh1106::update() 34 | { 35 | // no-op 36 | } 37 | 38 | template 39 | void tap::display::Sh1106::setInvert(bool invert) 40 | { 41 | // no-op 42 | } 43 | 44 | // ---------------------------------------------------------------------------- 45 | template 46 | void tap::display::Sh1106::initializeBlocking() 47 | { 48 | this->clear(); 49 | this->update(); 50 | } 51 | -------------------------------------------------------------------------------- /test/tap/mock/command_mapper_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_COMMAND_MAPPER_MOCK_HPP_ 21 | #define TAPROOT_COMMAND_MAPPER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/command.hpp" 26 | #include "tap/control/command_mapper.hpp" 27 | 28 | namespace tap 29 | { 30 | namespace mock 31 | { 32 | class CommandMapperMock : public tap::control::CommandMapper 33 | { 34 | public: 35 | CommandMapperMock(tap::Drivers *drivers); 36 | virtual ~CommandMapperMock(); 37 | 38 | MOCK_METHOD( 39 | void, 40 | handleKeyStateChange, 41 | (uint16_t, 42 | tap::communication::serial::Remote::SwitchState, 43 | tap::communication::serial::Remote::SwitchState, 44 | bool, 45 | bool), 46 | (override)); 47 | MOCK_METHOD(void, addMap, (tap::control::CommandMapping *), (override)); 48 | MOCK_METHOD(std::size_t, getSize, (), (const override)); 49 | }; // class CommandMapperMock 50 | } // namespace mock 51 | } // namespace tap 52 | 53 | #endif // TAPROOT_COMMAND_MAPPER_MOCK_HPP_ 54 | -------------------------------------------------------------------------------- /src/tap/algorithms/linear_interpolation_predictor_wrapped.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "linear_interpolation_predictor_wrapped.hpp" 21 | 22 | namespace tap::algorithms 23 | { 24 | LinearInterpolationPredictorWrapped::LinearInterpolationPredictorWrapped( 25 | float lowerBound, 26 | float upperBound) 27 | : lastUpdateCallTime(0), 28 | previousValue(0.0f, lowerBound, upperBound), 29 | slope(0.0f) 30 | { 31 | } 32 | 33 | void LinearInterpolationPredictorWrapped::update(float newValue, uint32_t currTime) 34 | { 35 | if (currTime <= lastUpdateCallTime) 36 | { 37 | slope = 0; 38 | return; 39 | } 40 | slope = (previousValue.minDifference(newValue)) / (currTime - lastUpdateCallTime); 41 | previousValue.setWrappedValue(newValue); 42 | lastUpdateCallTime = currTime; 43 | } 44 | 45 | void LinearInterpolationPredictorWrapped::reset(float initialValue, uint32_t initialTime) 46 | { 47 | previousValue.setWrappedValue(initialValue); 48 | lastUpdateCallTime = initialTime; 49 | slope = 0.0f; 50 | } 51 | } // namespace tap::algorithms 52 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_encoder_mock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "dji_motor_encoder_mock.hpp" 21 | 22 | namespace tap::mock 23 | { 24 | DjiMotorEncoderMock::DjiMotorEncoderMock( 25 | bool isInverted, 26 | float gearRatio, 27 | uint32_t encoderHomePosition) 28 | : DjiMotorEncoder(isInverted, gearRatio, encoderHomePosition) 29 | { 30 | ON_CALL(*this, isOnline).WillByDefault(testing::Return(true)); 31 | ON_CALL(*this, getVelocity).WillByDefault(testing::Invoke([&]() { 32 | return this->DjiMotorEncoder::getVelocity(); 33 | })); 34 | ON_CALL(*this, getPosition).WillByDefault(testing::Invoke([&]() { 35 | return this->DjiMotorEncoder::getPosition(); 36 | })); 37 | ON_CALL(*this, getEncoder) 38 | .WillByDefault(testing::Return(tap::algorithms::WrappedFloat(0, 0, ENC_RESOLUTION))); 39 | } 40 | 41 | DjiMotorEncoderMock::~DjiMotorEncoderMock() 42 | { 43 | ON_CALL(*this, getVelocity).WillByDefault(testing::Return(0)); 44 | ON_CALL(*this, getPosition).WillByDefault(testing::Return(tap::algorithms::Angle(0))); 45 | } 46 | } // namespace tap::mock 47 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/encoder/can_encoder/can_encoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "can_encoder.hpp" 21 | 22 | #include "modm/architecture/interface/can_message.hpp" 23 | 24 | namespace tap::encoder 25 | { 26 | CanEncoder::CanEncoder( 27 | Drivers* drivers, 28 | CanEncoderId id, 29 | tap::can::CanBus canBus, 30 | bool isInverted, 31 | float gearRatio, 32 | uint32_t encoderHomePosition) 33 | : CanRxListener(drivers, id, canBus), 34 | WrappedEncoder(isInverted, ENCODER_RESOLUTION, gearRatio, encoderHomePosition), 35 | gauss(0) 36 | { 37 | } 38 | 39 | bool CanEncoder::isOnline() const { return !this->encoderDisconnectTimeout.isExpired(); } 40 | 41 | void CanEncoder::initialize() { attachSelfToRxHandler(); } 42 | 43 | void CanEncoder::processMessage(const modm::can::Message& message) 44 | { 45 | uint16_t encoder = (message.data[1] << 8) | message.data[0]; 46 | this->updateEncoderValue(encoder); 47 | 48 | this->gauss = (message.data[3] << 8) | message.data[2]; 49 | this->encoderDisconnectTimeout.restart(DISCONNECT_TIME); 50 | } 51 | 52 | } // namespace tap::encoder -------------------------------------------------------------------------------- /test/tap/mock/command_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_COMMAND_MOCK_HPP_ 21 | #define TAPROOT_COMMAND_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/command.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class CommandMock : public control::Command 32 | { 33 | public: 34 | CommandMock(); 35 | virtual ~CommandMock(); 36 | 37 | MOCK_METHOD( 38 | control::subsystem_scheduler_bitmap_t, 39 | getRequirementsBitwise, 40 | (), 41 | (const override)); 42 | MOCK_METHOD(void, addSubsystemRequirement, (control::Subsystem * requirement), (override)); 43 | MOCK_METHOD(const char*, getName, (), (const override)); 44 | MOCK_METHOD(bool, isReady, (), (override)); 45 | MOCK_METHOD(void, initialize, (), (override)); 46 | MOCK_METHOD(void, execute, (), (override)); 47 | MOCK_METHOD(void, end, (bool interrupted), (override)); 48 | MOCK_METHOD(bool, isFinished, (), (const override)); 49 | }; // class CommandMock 50 | } // namespace mock 51 | } // namespace tap 52 | 53 | #endif // TAPROOT_COMMAND_MOCK_HPP_ 54 | -------------------------------------------------------------------------------- /test/tap/mock/imu_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_IMU_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_IMU_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/sensors/imu/imu_interface.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class ImuInterfaceMock : public tap::communication::sensors::imu::ImuInterface 30 | { 31 | public: 32 | ImuInterfaceMock(); 33 | virtual ~ImuInterfaceMock(); 34 | 35 | MOCK_METHOD(const char *, getName, (), (const override)); 36 | MOCK_METHOD(float, getAx, (), (const override)); 37 | MOCK_METHOD(float, getAy, (), (const override)); 38 | MOCK_METHOD(float, getAz, (), (const override)); 39 | MOCK_METHOD(float, getGx, (), (const override)); 40 | MOCK_METHOD(float, getGy, (), (const override)); 41 | MOCK_METHOD(float, getGz, (), (const override)); 42 | MOCK_METHOD(float, getYaw, (), (const override)); 43 | MOCK_METHOD(float, getPitch, (), (const override)); 44 | MOCK_METHOD(float, getRoll, (), (const override)); 45 | }; 46 | } // namespace tap::mock 47 | 48 | #endif // TAPROOT_IMU_INTERFACE_MOCK_HPP_ 49 | -------------------------------------------------------------------------------- /test/tap/mock/subsystem_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SUBSYSTEM_MOCK_HPP_ 21 | #define TAPROOT_SUBSYSTEM_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/control/subsystem.hpp" 26 | 27 | namespace tap 28 | { 29 | namespace mock 30 | { 31 | class SubsystemMock : public control::Subsystem 32 | { 33 | public: 34 | SubsystemMock(Drivers *drivers); 35 | virtual ~SubsystemMock(); 36 | 37 | MOCK_METHOD(void, initialize, (), (override)); 38 | MOCK_METHOD(void, setDefaultCommand, (control::Command * defaultCommand), (override)); 39 | MOCK_METHOD(control::Command *, getDefaultCommand, (), (const override)); 40 | MOCK_METHOD(void, refresh, (), (override)); 41 | MOCK_METHOD(void, refreshSafeDisconnect, (), ()); 42 | MOCK_METHOD(void, setTestCommand, (control::Command * testCommand), (override)); 43 | MOCK_METHOD(control::Command *, getTestCommand, (), (const override)); 44 | MOCK_METHOD(const char *, getName, (), (const override)); 45 | }; // class SubsystemMock 46 | } // namespace mock 47 | } // namespace tap 48 | 49 | #endif // TAPROOT_SUBSYSTEM_MOCK_HPP_ 50 | -------------------------------------------------------------------------------- /src/tap/communication/tcp-server/json_messages.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_JSON_MESSAGES_HPP_ 21 | #define TAPROOT_JSON_MESSAGES_HPP_ 22 | 23 | #ifdef PLATFORM_HOSTED 24 | 25 | #include 26 | 27 | namespace tap 28 | { 29 | namespace motor 30 | { 31 | class DjiMotor; 32 | } 33 | namespace communication 34 | { 35 | /** 36 | * The JSON namespace provides methods for working with JSON strings 37 | * which the MCB-simulator will be sending to the Windows simulator 38 | * and potentially vice versa. 39 | */ 40 | namespace json 41 | { 42 | /** 43 | * Pre: motorValues should be at least size 4 and contain valid 44 | * current values. 45 | * Post: Returns a string in valid JSON format that says that it is a 46 | * motor message, whether or not it is for the upper 4 motors based 47 | * on "upperMessage", and with the four current values in motorValues. 48 | */ 49 | std::string makeMotorMessage(const tap::motor::DjiMotor& motor); 50 | 51 | } // namespace json 52 | 53 | } // namespace communication 54 | 55 | } // namespace tap 56 | 57 | #endif // PLATFORM_HOSTED 58 | 59 | #endif // TAPROOT_JSON_MESSAGES_HPP_ 60 | -------------------------------------------------------------------------------- /src/tap/control/setpoint/interfaces/integrable_setpoint_subsystem.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_INTEGRABLE_SETPOINT_SUBSYSTEM_HPP_ 21 | #define TAPROOT_INTEGRABLE_SETPOINT_SUBSYSTEM_HPP_ 22 | 23 | #include "setpoint_subsystem.hpp" 24 | 25 | namespace tap 26 | { 27 | // Forward declaration 28 | class Drivers; 29 | } // namespace tap 30 | 31 | namespace tap::control::setpoint 32 | { 33 | /** 34 | * An extension of the SetpointSubsystem. Identical to the SetpointSubsystem except that the 35 | * setpoint is assumed to be integrable. As such, an additional getCurrentValueIntegral abstract 36 | * function must be implemented by those who choose to extend this class. 37 | */ 38 | class IntegrableSetpointSubsystem : public virtual SetpointSubsystem 39 | { 40 | public: 41 | /** 42 | * @return The current integral value of the setpoint, a measurement with units `units * 43 | * seconds` (units of setpoint integrated with respect to time) 44 | */ 45 | virtual float getCurrentValueIntegral() const = 0; 46 | }; 47 | 48 | } // namespace tap::control::setpoint 49 | 50 | #endif // TAPROOT_INTEGRABLE_SETPOINT_SUBSYSTEM_HPP_ 51 | -------------------------------------------------------------------------------- /src/tap/communication/gpio/analog.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ANALOG_HPP_ 21 | #define TAPROOT_ANALOG_HPP_ 22 | 23 | #include 24 | 25 | #ifndef PLATFORM_HOSTED 26 | #include "modm/platform/adc/adc_1.hpp" 27 | #endif 28 | 29 | #include "tap/util_macros.hpp" 30 | 31 | namespace tap 32 | { 33 | namespace gpio 34 | { 35 | /** 36 | * To read from a pin call Read and pass the function a pin from the 37 | * analog Pin enum. 38 | */ 39 | class Analog 40 | { 41 | public: 42 | Analog() = default; 43 | DISALLOW_COPY_AND_ASSIGN(Analog) 44 | mockable ~Analog() = default; 45 | 46 | // Analog pins 47 | enum Pin 48 | { 49 | %% for pin in pins 50 | {{ pin }}, 51 | %% endfor 52 | }; 53 | 54 | /** 55 | * Initializes the ADC and connects the configured analog pins to it. 56 | */ 57 | mockable void init(); 58 | 59 | /** 60 | * Reads voltage across the specified pin. Units in mV. 61 | */ 62 | mockable uint16_t read(Analog::Pin pin) const; 63 | }; // class Analog 64 | } // namespace gpio 65 | 66 | } // namespace tap 67 | 68 | #endif // TAPROOT_ANALOG_HPP_ 69 | 70 | -------------------------------------------------------------------------------- /src/tap/algorithms/extended_kalman.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019 Sanger_X 22 | */ 23 | 24 | #include "extended_kalman.hpp" 25 | 26 | namespace tap 27 | { 28 | namespace algorithms 29 | { 30 | ExtendedKalman::ExtendedKalman(float tQ, float tR) 31 | : xLast(0.0f), 32 | xMid(0.0f), 33 | xNow(0.0f), 34 | pMid(0.0f), 35 | pNow(0.0f), 36 | pLast(0.0f), 37 | kg(0.0f), 38 | A(1.0f), 39 | B(0.0f), 40 | Q(tQ), 41 | R(tR), 42 | H(1.0f) 43 | { 44 | } 45 | 46 | float ExtendedKalman::filterData(float dat) 47 | { 48 | xMid = A * xLast; 49 | pMid = A * pLast + Q; 50 | kg = pMid / (pMid + R); 51 | xNow = xMid + kg * (dat - xMid); 52 | pNow = (1 - kg) * pMid; 53 | pLast = pNow; 54 | xLast = xNow; 55 | return xNow; 56 | } 57 | 58 | float ExtendedKalman::getLastFiltered() const { return xLast; } 59 | 60 | void ExtendedKalman::reset() 61 | { 62 | xNow = 0.0f; 63 | xMid = 0.0f; 64 | xLast = 0.0f; 65 | pNow = 0.0f; 66 | pMid = 0.0f; 67 | pLast = 0.0f; 68 | } 69 | 70 | } // namespace algorithms 71 | 72 | } // namespace tap 73 | -------------------------------------------------------------------------------- /src/tap/display/sh1107_mock_impl.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_SH1107_HPP_ 21 | #error "Don't include this file directly, use 'sh1107.hpp' instead!" 22 | #endif 23 | 24 | template 25 | modm::ResumableResult tap::display::Sh1107:: 26 | updateNonblocking() 27 | { 28 | RF_BEGIN(0); 29 | // no-op 30 | RF_END_RETURN(false); 31 | } 32 | 33 | template 34 | void tap::display::Sh1107::update() 35 | { 36 | // no-op 37 | } 38 | 39 | template 40 | void tap::display::Sh1107::setInvert(bool invert) 41 | { 42 | // no-op 43 | } 44 | 45 | // ---------------------------------------------------------------------------- 46 | template 47 | void tap::display::Sh1107::initializeBlocking() 48 | { 49 | this->clear(); 50 | this->update(); 51 | } 52 | -------------------------------------------------------------------------------- /src/tap/communication/sensors/distance/analog_distance_sensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #include "analog_distance_sensor.hpp" 21 | 22 | #include "tap/drivers.hpp" 23 | 24 | namespace tap 25 | { 26 | namespace sensors 27 | { 28 | AnalogDistanceSensor::AnalogDistanceSensor( 29 | Drivers *drivers, 30 | float minDistance, 31 | float maxDistance, 32 | float m, 33 | float b, 34 | float offset, 35 | gpio::Analog::Pin pin) 36 | : DistanceSensor(minDistance, maxDistance), 37 | drivers(drivers), 38 | m(m), 39 | b(b), 40 | offset(offset), 41 | pin(pin) 42 | { 43 | } 44 | 45 | float AnalogDistanceSensor::read() 46 | { 47 | // Read analog pin and convert to volts 48 | float reading = drivers->analog.read(pin); 49 | 50 | // Linear model 51 | float linear = m * reading / 1000.0f + b; 52 | 53 | // Convert to cm distance 54 | distance = 1.0f / linear + offset; 55 | 56 | return validReading() ? distance : -1.0f; 57 | } 58 | 59 | bool AnalogDistanceSensor::validReading() const 60 | { 61 | return (distance > minDistance) && (distance < maxDistance); 62 | } 63 | } // namespace sensors 64 | 65 | } // namespace tap 66 | -------------------------------------------------------------------------------- /src/tap/motor/motorsim/can_serializer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_CAN_SERIALIZER_HPP_ 21 | #define TAPROOT_CAN_SERIALIZER_HPP_ 22 | 23 | #ifdef PLATFORM_HOSTED 24 | 25 | #include 26 | #include 27 | 28 | #include "tap/motor/dji_motor_ids.hpp" 29 | 30 | namespace modm::can 31 | { 32 | class Message; 33 | } 34 | 35 | namespace tap::motor::motorsim 36 | { 37 | class CanSerializer 38 | { 39 | public: 40 | /** 41 | * Parse a given CAN motor message into 4 motor input values. 42 | * Returns a 16-bit int array containing the 4 integer input values. 43 | */ 44 | static std::array parseMessage(const modm::can::Message* message); 45 | 46 | /** 47 | * Serialize the given motor feedback data into a CAN Message. 48 | */ 49 | static modm::can::Message serializeFeedback( 50 | int16_t angle, 51 | int16_t rpm, 52 | int16_t current, 53 | MotorId mid); 54 | 55 | private: 56 | /* Constants */ 57 | static constexpr uint8_t FEEDBACK_MESSAGE_SEND_LENGTH = 8; 58 | }; 59 | } // namespace tap::motor::motorsim 60 | 61 | #endif // PLATFORM_HOSTED 62 | 63 | #endif // TAPROOT_CAN_SERIALIZER_HPP_ 64 | -------------------------------------------------------------------------------- /test/tap/mock/abstract_imu_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_ABSTRACT_IMU_MOCK_HPP_ 21 | #define TAPROOT_ABSTRACT_IMU_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/communication/sensors/imu/abstract_imu.hpp" 26 | 27 | namespace tap::mock 28 | { 29 | class AbstractImuMock : public tap::communication::sensors::imu::AbstractIMU 30 | { 31 | public: 32 | AbstractImuMock(); 33 | virtual ~AbstractImuMock(); 34 | 35 | MOCK_METHOD(const char *, getName, (), (const override)); 36 | MOCK_METHOD(float, getTemp, (), (const override)); 37 | MOCK_METHOD(float, getAx, (), (const override)); 38 | MOCK_METHOD(float, getAy, (), (const override)); 39 | MOCK_METHOD(float, getAz, (), (const override)); 40 | MOCK_METHOD(float, getGx, (), (const override)); 41 | MOCK_METHOD(float, getGy, (), (const override)); 42 | MOCK_METHOD(float, getGz, (), (const override)); 43 | MOCK_METHOD(float, getYaw, (), (const override)); 44 | MOCK_METHOD(float, getPitch, (), (const override)); 45 | MOCK_METHOD(float, getRoll, (), (const override)); 46 | MOCK_METHOD(float, getAccelerationSensitivity, (), (const override)); 47 | }; 48 | } // namespace tap::mock 49 | 50 | #endif // TAPROOT_ABSTRACT_IMU_MOCK_HPP_ 51 | -------------------------------------------------------------------------------- /test/tap/mock/motor_interface_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_MOTOR_INTERFACE_MOCK_HPP_ 21 | #define TAPROOT_MOTOR_INTERFACE_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "tap/motor/motor_interface.hpp" 28 | 29 | #include "encoder_interface_mock.hpp" 30 | 31 | namespace tap::mock 32 | { 33 | class MotorInterfaceMock : public tap::motor::MotorInterface 34 | { 35 | public: 36 | MotorInterfaceMock(); 37 | virtual ~MotorInterfaceMock(); 38 | 39 | MOCK_METHOD(void, initialize, (), (override)); 40 | MOCK_METHOD(void, setDesiredOutput, (int32_t), (override)); 41 | MOCK_METHOD(bool, isMotorOnline, (), (const override)); 42 | MOCK_METHOD(int16_t, getOutputDesired, (), (const override)); 43 | MOCK_METHOD(int8_t, getTemperature, (), (const override)); 44 | MOCK_METHOD(int16_t, getTorque, (), (const override)); 45 | 46 | EncoderInterfaceMock* getEncoder() const override 47 | { 48 | return const_cast*>(&encoder); 49 | } 50 | 51 | private: 52 | testing::NiceMock encoder; 53 | }; 54 | 55 | } // namespace tap::mock 56 | 57 | #endif // TAPROOT_MOTOR_INTERFACE_MOCK_HPP_ 58 | -------------------------------------------------------------------------------- /test/tap/mock/dji_motor_encoder_mock.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_DJI_MOTOR_ENCODER_MOCK_HPP_ 21 | #define TAPROOT_DJI_MOTOR_ENCODER_MOCK_HPP_ 22 | 23 | #include 24 | 25 | #include "tap/motor/dji_motor_encoder.hpp" 26 | 27 | #include "modm/architecture/interface/can_message.hpp" 28 | 29 | namespace tap::mock 30 | { 31 | class DjiMotorEncoderMock : public tap::motor::DjiMotorEncoder 32 | { 33 | public: 34 | DjiMotorEncoderMock(bool isInverted, float gearRatio = 1, uint32_t encoderHomePosition = 0); 35 | virtual ~DjiMotorEncoderMock(); 36 | 37 | MOCK_METHOD(void, initialize, (), (override)); 38 | 39 | MOCK_METHOD(bool, isOnline, (), (const override)); 40 | 41 | MOCK_METHOD(tap::algorithms::WrappedFloat, getPosition, (), (const override)); 42 | 43 | MOCK_METHOD(float, getVelocity, (), (const override)); 44 | 45 | MOCK_METHOD(tap::algorithms::WrappedFloat, getEncoder, (), (const)); 46 | 47 | MOCK_METHOD(int16_t, getShaftRPM, (), (const override)); 48 | 49 | MOCK_METHOD(void, resetEncoderValue, (), (override)); 50 | 51 | MOCK_METHOD(void, processMessage, (const modm::can::Message& message), (override)); 52 | }; 53 | 54 | } // namespace tap::mock 55 | 56 | #endif // TAPROOT_DJI_MOTOR_ENCODER_MOCK_HPP_ 57 | -------------------------------------------------------------------------------- /src/tap/control/governor/command_governor_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Advanced Robotics at the University of Washington 3 | * 4 | * This file is part of Taproot. 5 | * 6 | * Taproot is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Taproot is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Taproot. If not, see . 18 | */ 19 | 20 | #ifndef TAPROOT_COMMAND_GOVERNOR_INTERFACE_HPP_ 21 | #define TAPROOT_COMMAND_GOVERNOR_INTERFACE_HPP_ 22 | 23 | namespace tap::control::governor 24 | { 25 | /** 26 | * An interface that is used to gate the execution of a Command. Override this interface to gate 27 | * various commands based on some conditional logic. For example, create a sub-class of this 28 | * interface and have isReady return true when the ref system indicates you have enough heat to 29 | * launch a projectile. Then, use a GovernorLimitedCommand to only run a command that launches 30 | * a projectile when the CommandGovernorInterface sub-object you created is true. 31 | */ 32 | class CommandGovernorInterface 33 | { 34 | public: 35 | /// Called once when the command associated with this governor is scheduled. 36 | virtual void onGovernedCommandInitialized() {} 37 | 38 | /// Returns true if the Command being governed by the governor may execute. 39 | virtual bool isReady() = 0; 40 | 41 | /// Returns true if the Command being governed by the governor should stop executing. 42 | virtual bool isFinished() = 0; 43 | }; 44 | } // namespace tap::control::governor 45 | 46 | #endif // TAPROOT_COMMAND_GOVERNOR_INTERFACE_HPP_ 47 | --------------------------------------------------------------------------------