From 26f13ccd8603c2d0a24a774df207329bd3bcc6c5 Mon Sep 17 00:00:00 2001 From: jmaff Date: Tue, 5 Mar 2024 20:52:55 -0500 Subject: [PATCH 01/15] Add initial trapezoidal profile header --- src/esw/motor_library/motion_profile.cpp | 6 ++++++ src/esw/motor_library/motion_profile.hpp | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/esw/motor_library/motion_profile.cpp create mode 100644 src/esw/motor_library/motion_profile.hpp diff --git a/src/esw/motor_library/motion_profile.cpp b/src/esw/motor_library/motion_profile.cpp new file mode 100644 index 000000000..b7f7b285d --- /dev/null +++ b/src/esw/motor_library/motion_profile.cpp @@ -0,0 +1,6 @@ +#include "motion_profile.hpp" + +double TrapezoidalMotionProfile::velocity(double t) { + // TODO + return 0.0; +} \ No newline at end of file diff --git a/src/esw/motor_library/motion_profile.hpp b/src/esw/motor_library/motion_profile.hpp new file mode 100644 index 000000000..b613dd644 --- /dev/null +++ b/src/esw/motor_library/motion_profile.hpp @@ -0,0 +1,20 @@ +class TrapezoidalMotionProfile { +public: + // velocity of the profile at time t + double velocity(double t); + +private: + double mMaxVelocity; + double mMaxAcceleration; + + double mInitialPosition; + double mDesiredPosition; + + // TODO: figure out a good way to expose either cruise distance or time + // maybe an overloaded constructor based on units, although we should also templatize + // any valid base position unit (m -> m/s -> m/s^2, in -> in/s -> in/s^2) + + // distance/time that constant (maximum) velocity is maintained + double mCruiseDistance; + double mCruiseTime; +}; \ No newline at end of file From 40d46629b722c6e0cb51815f3957d4e6bb2158d1 Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 7 Mar 2024 19:44:45 -0500 Subject: [PATCH 02/15] Move profiling code, will move to fw --- src/esw/motor_library/motion/motion_profile.cpp | 11 +++++++++++ src/esw/motor_library/motion/motion_profile.hpp | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/esw/motor_library/motion/motion_profile.cpp create mode 100644 src/esw/motor_library/motion/motion_profile.hpp diff --git a/src/esw/motor_library/motion/motion_profile.cpp b/src/esw/motor_library/motion/motion_profile.cpp new file mode 100644 index 000000000..bbb29dea4 --- /dev/null +++ b/src/esw/motor_library/motion/motion_profile.cpp @@ -0,0 +1,11 @@ +#include "motion_profile.hpp" + +double TrapezoidalMotionProfile::velocity(double t) { + // TODO + double totalDistance = (mDesiredPosition - mInitialPosition); + + double accelerationTime = mMaxVelocity / mMaxAcceleration; + double totalTime = accelerationTime + totalDistance / mMaxVelocity; + + return 0.0; +} \ No newline at end of file diff --git a/src/esw/motor_library/motion/motion_profile.hpp b/src/esw/motor_library/motion/motion_profile.hpp new file mode 100644 index 000000000..d914c1444 --- /dev/null +++ b/src/esw/motor_library/motion/motion_profile.hpp @@ -0,0 +1,12 @@ +class TrapezoidalMotionProfile { +public: + // velocity of the profile at time t + double velocity(double t); + +private: + double mMaxVelocity; + double mMaxAcceleration; + + double mInitialPosition; + double mDesiredPosition; +}; \ No newline at end of file From 3dbdfe8e8858adfb5992ad8e6e3dbed556084a3b Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 7 Mar 2024 19:58:11 -0500 Subject: [PATCH 03/15] Add missing include statements --- src/esw/fw/bdcmc/Core/Inc/filtering.hpp | 1 + src/esw/fw/bdcmc/Core/Src/encoders/absolute_encoder.cpp | 1 + src/util/hardware.hpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/esw/fw/bdcmc/Core/Inc/filtering.hpp b/src/esw/fw/bdcmc/Core/Inc/filtering.hpp index be245ba52..67dc2a991 100644 --- a/src/esw/fw/bdcmc/Core/Inc/filtering.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/filtering.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace mrover { diff --git a/src/esw/fw/bdcmc/Core/Src/encoders/absolute_encoder.cpp b/src/esw/fw/bdcmc/Core/Src/encoders/absolute_encoder.cpp index d02cf4fa8..32a5ca893 100644 --- a/src/esw/fw/bdcmc/Core/Src/encoders/absolute_encoder.cpp +++ b/src/esw/fw/bdcmc/Core/Src/encoders/absolute_encoder.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace mrover { /* ABSOLUTE ENCODER PROCESS: diff --git a/src/util/hardware.hpp b/src/util/hardware.hpp index bb74039df..aee490358 100644 --- a/src/util/hardware.hpp +++ b/src/util/hardware.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include From aa5978813d1805eb22ead4445becdd9f4d836e3b Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 7 Mar 2024 20:01:08 -0500 Subject: [PATCH 04/15] Move motion profiling to bdcmc fw --- .../motion => fw/bdcmc/Core/Inc}/motion_profile.hpp | 0 .../bdcmc/Core/Src}/motion/motion_profile.cpp | 1 - 2 files changed, 1 deletion(-) rename src/esw/{motor_library/motion => fw/bdcmc/Core/Inc}/motion_profile.hpp (100%) rename src/esw/{motor_library => fw/bdcmc/Core/Src}/motion/motion_profile.cpp (96%) diff --git a/src/esw/motor_library/motion/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp similarity index 100% rename from src/esw/motor_library/motion/motion_profile.hpp rename to src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp diff --git a/src/esw/motor_library/motion/motion_profile.cpp b/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp similarity index 96% rename from src/esw/motor_library/motion/motion_profile.cpp rename to src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp index bbb29dea4..54f3cbb7d 100644 --- a/src/esw/motor_library/motion/motion_profile.cpp +++ b/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp @@ -1,7 +1,6 @@ #include "motion_profile.hpp" double TrapezoidalMotionProfile::velocity(double t) { - // TODO double totalDistance = (mDesiredPosition - mInitialPosition); double accelerationTime = mMaxVelocity / mMaxAcceleration; From bfc4aee4bb184eed2778ba59951f64bdf5b1cd6d Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 7 Mar 2024 20:24:40 -0500 Subject: [PATCH 05/15] Implement velocity function --- .../bdcmc/Core/Src/motion/motion_profile.cpp | 16 +- .../cmakeFiles-v1-0f7b750a945536a61daa.json | 140 ++ .../codemodel-v2-16a1cd19eeefc63ce8a9.json | 60 + .../reply/index-2024-03-08T01-01-34-0803.json | 108 ++ ...-bdcmc.elf-Debug-7666b1706c409ed2da7f.json | 1284 +++++++++++++++++ 5 files changed, 1605 insertions(+), 3 deletions(-) create mode 100644 src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0f7b750a945536a61daa.json create mode 100644 src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json create mode 100644 src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json create mode 100644 src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json diff --git a/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp b/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp index 54f3cbb7d..e851e272d 100644 --- a/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp +++ b/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp @@ -2,9 +2,19 @@ double TrapezoidalMotionProfile::velocity(double t) { double totalDistance = (mDesiredPosition - mInitialPosition); + double timeToAccelerate = mMaxVelocity / mMaxAcceleration; - double accelerationTime = mMaxVelocity / mMaxAcceleration; - double totalTime = accelerationTime + totalDistance / mMaxVelocity; + double tAccelerationDone = timeToAccelerate; + double tEnd = tAccelerationDone + totalDistance / mMaxVelocity; + double tCruiseDone = tEnd - tAccelerationDone; - return 0.0; + if (t >= 0 && t < tAccelerationDone) { + return mMaxAcceleration * t; + } else if (t >= tAccelerationDone && t < tCruiseDone) { + return mMaxVelocity; + } else if (t >= tCruiseDone && t <= tEnd) { + return -mMaxAcceleration * t + mMaxAcceleration * tEnd; + } else { + return 0.0; + } } \ No newline at end of file diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0f7b750a945536a61daa.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0f7b750a945536a61daa.json new file mode 100644 index 000000000..371729833 --- /dev/null +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-0f7b750a945536a61daa.json @@ -0,0 +1,140 @@ +{ + "inputs" : + [ + { + "path" : "CMakeLists.txt" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeSystem.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInitialize.cmake" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeCCompiler.cmake" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeCXXCompiler.cmake" + }, + { + "isGenerated" : true, + "path" : "cmake-build-debug/CMakeFiles/3.27.8/CMakeASMCompiler.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeSystemSpecificInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeGenericSystem.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeInitializeConfigs.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Generic.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeLanguageInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU-C.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/CMakeCommonCompilerMacros.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Generic.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCommonLanguageInclude.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCXXInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeLanguageInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU-CXX.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Platform/Generic.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeCommonLanguageInclude.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/CMakeASMInformation.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU-ASM.cmake" + }, + { + "isCMake" : true, + "isExternal" : true, + "path" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27/Modules/Compiler/GNU.cmake" + } + ], + "kind" : "cmakeFiles", + "paths" : + { + "build" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/cmake-build-debug", + "source" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc" + }, + "version" : + { + "major" : 1, + "minor" : 0 + } +} diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json new file mode 100644 index 000000000..94c785b37 --- /dev/null +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json @@ -0,0 +1,60 @@ +{ + "configurations" : + [ + { + "directories" : + [ + { + "build" : ".", + "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", + "minimumCMakeVersion" : + { + "string" : "3.27" + }, + "projectIndex" : 0, + "source" : ".", + "targetIndexes" : + [ + 0 + ] + } + ], + "name" : "Debug", + "projects" : + [ + { + "directoryIndexes" : + [ + 0 + ], + "name" : "bdcmc", + "targetIndexes" : + [ + 0 + ] + } + ], + "targets" : + [ + { + "directoryIndex" : 0, + "id" : "bdcmc.elf::@6890427a1f51a3e7e1df", + "jsonFile" : "target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json", + "name" : "bdcmc.elf", + "projectIndex" : 0 + } + ] + } + ], + "kind" : "codemodel", + "paths" : + { + "build" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/cmake-build-debug", + "source" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc" + }, + "version" : + { + "major" : 2, + "minor" : 6 + } +} diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json new file mode 100644 index 000000000..ba4197906 --- /dev/null +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json @@ -0,0 +1,108 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "Ninja" + }, + "paths" : + { + "cmake" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake", + "cpack" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cpack", + "ctest" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/ctest", + "root" : "/Users/jmaff/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.27" + }, + "version" : + { + "isDirty" : false, + "major" : 3, + "minor" : 27, + "patch" : 8, + "string" : "3.27.8", + "suffix" : "" + } + }, + "objects" : + [ + { + "jsonFile" : "codemodel-v2-16a1cd19eeefc63ce8a9.json", + "kind" : "codemodel", + "version" : + { + "major" : 2, + "minor" : 6 + } + }, + { + "jsonFile" : "cache-v2-3f9ce76b9cef89055e07.json", + "kind" : "cache", + "version" : + { + "major" : 2, + "minor" : 0 + } + }, + { + "jsonFile" : "cmakeFiles-v1-0f7b750a945536a61daa.json", + "kind" : "cmakeFiles", + "version" : + { + "major" : 1, + "minor" : 0 + } + }, + { + "jsonFile" : "toolchains-v1-770a5d28b945a2f53be9.json", + "kind" : "toolchains", + "version" : + { + "major" : 1, + "minor" : 0 + } + } + ], + "reply" : + { + "cache-v2" : + { + "jsonFile" : "cache-v2-3f9ce76b9cef89055e07.json", + "kind" : "cache", + "version" : + { + "major" : 2, + "minor" : 0 + } + }, + "cmakeFiles-v1" : + { + "jsonFile" : "cmakeFiles-v1-0f7b750a945536a61daa.json", + "kind" : "cmakeFiles", + "version" : + { + "major" : 1, + "minor" : 0 + } + }, + "codemodel-v2" : + { + "jsonFile" : "codemodel-v2-16a1cd19eeefc63ce8a9.json", + "kind" : "codemodel", + "version" : + { + "major" : 2, + "minor" : 6 + } + }, + "toolchains-v1" : + { + "jsonFile" : "toolchains-v1-770a5d28b945a2f53be9.json", + "kind" : "toolchains", + "version" : + { + "major" : 1, + "minor" : 0 + } + } + } +} diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json new file mode 100644 index 000000000..591459bef --- /dev/null +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json @@ -0,0 +1,1284 @@ +{ + "artifacts" : + [ + { + "path" : "bdcmc.elf" + } + ], + "backtrace" : 1, + "backtraceGraph" : + { + "commands" : + [ + "add_executable", + "add_link_options", + "add_compile_options", + "add_compile_definitions", + "add_definitions", + "include_directories" + ], + "files" : + [ + "CMakeLists.txt" + ], + "nodes" : + [ + { + "file" : 0 + }, + { + "command" : 0, + "file" : 0, + "line" : 65, + "parent" : 0 + }, + { + "command" : 1, + "file" : 0, + "line" : 24, + "parent" : 0 + }, + { + "command" : 1, + "file" : 0, + "line" : 61, + "parent" : 0 + }, + { + "command" : 1, + "file" : 0, + "line" : 62, + "parent" : 0 + }, + { + "command" : 1, + "file" : 0, + "line" : 63, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 23, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 29, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 30, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 33, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 36, + "parent" : 0 + }, + { + "command" : 2, + "file" : 0, + "line" : 50, + "parent" : 0 + }, + { + "command" : 3, + "file" : 0, + "line" : 22, + "parent" : 0 + }, + { + "command" : 4, + "file" : 0, + "line" : 55, + "parent" : 0 + }, + { + "command" : 5, + "file" : 0, + "line" : 53, + "parent" : 0 + } + ] + }, + "compileGroups" : + [ + { + "compileCommandFragments" : + [ + { + "fragment" : "-g -std=gnu++20 -fdiagnostics-color=always" + }, + { + "backtrace" : 6, + "fragment" : "-mfloat-abi=hard" + }, + { + "backtrace" : 6, + "fragment" : "-mfpu=fpv4-sp-d16" + }, + { + "backtrace" : 7, + "fragment" : "-mcpu=cortex-m4" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb-interwork" + }, + { + "backtrace" : 8, + "fragment" : "-ffunction-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fdata-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fno-common" + }, + { + "backtrace" : 8, + "fragment" : "-fmessage-length=0" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-attributes" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-volatile" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-psabi" + }, + { + "backtrace" : 11, + "fragment" : "-Og" + }, + { + "backtrace" : 11, + "fragment" : "-g" + } + ], + "defines" : + [ + { + "backtrace" : 12, + "define" : "ARM_MATH_CM4" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_MATRIX_CHECK" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_ROUNDING" + }, + { + "backtrace" : 13, + "define" : "DEBUG" + }, + { + "backtrace" : 13, + "define" : "STM32G431xx" + }, + { + "backtrace" : 13, + "define" : "USE_HAL_DRIVER" + } + ], + "includes" : + [ + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Core/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Device/ST/STM32G4xx/Include" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Include" + } + ], + "language" : "CXX", + "languageStandard" : + { + "backtraces" : + [ + 1 + ], + "standard" : "20" + }, + "sourceIndexes" : + [ + 13, + 14, + 15, + 16, + 18 + ] + }, + { + "compileCommandFragments" : + [ + { + "fragment" : "-g -fdiagnostics-color=always" + }, + { + "backtrace" : 6, + "fragment" : "-mfloat-abi=hard" + }, + { + "backtrace" : 6, + "fragment" : "-mfpu=fpv4-sp-d16" + }, + { + "backtrace" : 7, + "fragment" : "-mcpu=cortex-m4" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb-interwork" + }, + { + "backtrace" : 8, + "fragment" : "-ffunction-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fdata-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fno-common" + }, + { + "backtrace" : 8, + "fragment" : "-fmessage-length=0" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-attributes" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-psabi" + }, + { + "backtrace" : 11, + "fragment" : "-Og" + }, + { + "backtrace" : 11, + "fragment" : "-g" + } + ], + "defines" : + [ + { + "backtrace" : 12, + "define" : "ARM_MATH_CM4" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_MATRIX_CHECK" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_ROUNDING" + }, + { + "backtrace" : 13, + "define" : "DEBUG" + }, + { + "backtrace" : 13, + "define" : "STM32G431xx" + }, + { + "backtrace" : 13, + "define" : "USE_HAL_DRIVER" + } + ], + "includes" : + [ + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Core/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Device/ST/STM32G4xx/Include" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Include" + } + ], + "language" : "C", + "languageStandard" : + { + "backtraces" : + [ + 1 + ], + "standard" : "17" + }, + "sourceIndexes" : + [ + 17, + 19, + 20, + 21, + 22, + 23, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106 + ] + }, + { + "compileCommandFragments" : + [ + { + "fragment" : "-g" + }, + { + "backtrace" : 6, + "fragment" : "-mfloat-abi=hard" + }, + { + "backtrace" : 6, + "fragment" : "-mfpu=fpv4-sp-d16" + }, + { + "backtrace" : 7, + "fragment" : "-mcpu=cortex-m4" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb" + }, + { + "backtrace" : 7, + "fragment" : "-mthumb-interwork" + }, + { + "backtrace" : 8, + "fragment" : "-ffunction-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fdata-sections" + }, + { + "backtrace" : 8, + "fragment" : "-fno-common" + }, + { + "backtrace" : 8, + "fragment" : "-fmessage-length=0" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-attributes" + }, + { + "backtrace" : 9, + "fragment" : "-Wno-psabi" + }, + { + "backtrace" : 10, + "fragment" : "-x" + }, + { + "backtrace" : 10, + "fragment" : "assembler-with-cpp" + }, + { + "backtrace" : 11, + "fragment" : "-Og" + }, + { + "backtrace" : 11, + "fragment" : "-g" + } + ], + "defines" : + [ + { + "backtrace" : 12, + "define" : "ARM_MATH_CM4" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_MATRIX_CHECK" + }, + { + "backtrace" : 12, + "define" : "ARM_MATH_ROUNDING" + }, + { + "backtrace" : 13, + "define" : "DEBUG" + }, + { + "backtrace" : 13, + "define" : "STM32G431xx" + }, + { + "backtrace" : 13, + "define" : "USE_HAL_DRIVER" + } + ], + "includes" : + [ + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Core/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/STM32G4xx_HAL_Driver/Inc/Legacy" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Device/ST/STM32G4xx/Include" + }, + { + "backtrace" : 14, + "path" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/Drivers/CMSIS/Include" + } + ], + "language" : "ASM", + "sourceIndexes" : + [ + 24 + ] + } + ], + "id" : "bdcmc.elf::@6890427a1f51a3e7e1df", + "link" : + { + "commandFragments" : + [ + { + "fragment" : "-g", + "role" : "flags" + }, + { + "fragment" : "", + "role" : "flags" + }, + { + "backtrace" : 2, + "fragment" : "-mfloat-abi=hard", + "role" : "flags" + }, + { + "backtrace" : 2, + "fragment" : "-mfpu=fpv4-sp-d16", + "role" : "flags" + }, + { + "backtrace" : 3, + "fragment" : "-Wl,-gc-sections,--print-memory-usage,-Map=/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/cmake-build-debug/bdcmc.map", + "role" : "flags" + }, + { + "backtrace" : 4, + "fragment" : "-mcpu=cortex-m4", + "role" : "flags" + }, + { + "backtrace" : 4, + "fragment" : "-mthumb", + "role" : "flags" + }, + { + "backtrace" : 4, + "fragment" : "-mthumb-interwork", + "role" : "flags" + }, + { + "backtrace" : 5, + "fragment" : "-T", + "role" : "flags" + }, + { + "backtrace" : 5, + "fragment" : "/Users/jmaff/src/mrover/mrover-ros/src/esw/fw/bdcmc/STM32G431CBUX_FLASH.ld", + "role" : "flags" + } + ], + "language" : "CXX" + }, + "name" : "bdcmc.elf", + "nameOnDisk" : "bdcmc.elf", + "paths" : + { + "build" : ".", + "source" : "." + }, + "sourceGroups" : + [ + { + "name" : "Header Files", + "sourceIndexes" : + [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 25, + 26, + 27, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87 + ] + }, + { + "name" : "Source Files", + "sourceIndexes" : + [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106 + ] + }, + { + "name" : "", + "sourceIndexes" : + [ + 24, + 28, + 53, + 88, + 107 + ] + } + ], + "sources" : + [ + { + "backtrace" : 1, + "path" : "Core/Inc/controller.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/encoders.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/filtering.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/hardware.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/hardware_i2c.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/hbridge.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/main.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/messaging.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/motion_profile.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/pidf.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/stm32g4xx_hal_conf.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/stm32g4xx_it.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Core/Inc/testing.hpp", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Core/Src/controller.cpp", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Core/Src/encoders/absolute_encoder.cpp", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Core/Src/encoders/quadrature_encoder.cpp", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Core/Src/hbridge.cpp", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/main.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Core/Src/motion/motion_profile.cpp", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/stm32g4xx_hal_msp.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/stm32g4xx_it.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/syscalls.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/sysmem.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Core/Src/system_stm32g4xx.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 2, + "path" : "Core/Startup/startup_stm32g431cbux.s", + "sourceGroupIndex" : 2 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g431xx.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g4xx.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Device/ST/STM32G4xx/Include/system_stm32g4xx.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Device/ST/STM32G4xx/LICENSE.txt", + "sourceGroupIndex" : 2 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_armcc.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_armclang.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_armclang_ltm.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_compiler.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_gcc.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_iccarm.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/cmsis_version.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_armv81mml.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_armv8mbl.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_armv8mml.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm0.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm0plus.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm1.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm23.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm3.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm33.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm35p.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm4.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_cm7.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_sc000.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/core_sc300.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/mpu_armv7.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/mpu_armv8.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/Include/tz_context.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/CMSIS/LICENSE.txt", + "sourceGroupIndex" : 2 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h", + "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/LICENSE.txt", + "sourceGroupIndex" : 2 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 1, + "path" : "Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "path" : "STM32G431CBUX_FLASH.ld", + "sourceGroupIndex" : 2 + } + ], + "type" : "EXECUTABLE" +} From cb8330f967416e8c26237962498adb3ca098e1df Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 7 Mar 2024 20:41:32 -0500 Subject: [PATCH 06/15] Add MotionProfile base class --- src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 39 +++++++++++++++--- ...ile.cpp => trapezoidal_motion_profile.cpp} | 2 +- ...=> codemodel-v2-7708bee35485fa153138.json} | 2 +- ...on => index-2024-03-08T01-38-18-0515.json} | 4 +- ...bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json} | 2 +- .../motion/trapezoidal_motion_profile.cpp.obj | Bin 0 -> 7752 bytes 6 files changed, 38 insertions(+), 11 deletions(-) rename src/esw/fw/bdcmc/Core/Src/motion/{motion_profile.cpp => trapezoidal_motion_profile.cpp} (91%) rename src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/{codemodel-v2-16a1cd19eeefc63ce8a9.json => codemodel-v2-7708bee35485fa153138.json} (93%) rename src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/{index-2024-03-08T01-01-34-0803.json => index-2024-03-08T01-38-18-0515.json} (94%) rename src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/{target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json => target-bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json} (99%) create mode 100644 src/esw/fw/bdcmc/cmake-build-debug/CMakeFiles/bdcmc.elf.dir/Core/Src/motion/trapezoidal_motion_profile.cpp.obj diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index d914c1444..a07176eed 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -1,12 +1,39 @@ -class TrapezoidalMotionProfile { +class MotionProfile { public: + MotionProfile(double initialPosition, + double desiredPosition, + double maxVelocity, + double maxAcceleration) : mInitialPosition{initialPosition}, + mDesiredPosition{desiredPosition}, + mMaxVelocity{maxVelocity}, + mMaxAcceleration{maxAcceleration} {} + // velocity of the profile at time t - double velocity(double t); + [[nodiscard]] virtual double velocity(double t) const = 0; -private: - double mMaxVelocity; - double mMaxAcceleration; - + void update(double initialPosition, + double desiredPosition) { + mInitialPosition = initialPosition; + mDesiredPosition = desiredPosition; + } + + +protected: double mInitialPosition; double mDesiredPosition; + + double mMaxVelocity; + double mMaxAcceleration; +}; + +class TrapezoidalMotionProfile : public MotionProfile { +public: + TrapezoidalMotionProfile(double initialPosition, + double desiredPosition, + double maxVelocity, + double maxAcceleration) : MotionProfile(initialPosition, + desiredPosition, + maxVelocity, + maxAcceleration) {} + [[nodiscard]] double velocity(double t) const override; }; \ No newline at end of file diff --git a/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp b/src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp similarity index 91% rename from src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp rename to src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp index e851e272d..0a76f4c82 100644 --- a/src/esw/fw/bdcmc/Core/Src/motion/motion_profile.cpp +++ b/src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp @@ -1,6 +1,6 @@ #include "motion_profile.hpp" -double TrapezoidalMotionProfile::velocity(double t) { +double TrapezoidalMotionProfile::velocity(double t) const { double totalDistance = (mDesiredPosition - mInitialPosition); double timeToAccelerate = mMaxVelocity / mMaxAcceleration; diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-7708bee35485fa153138.json similarity index 93% rename from src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json rename to src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-7708bee35485fa153138.json index 94c785b37..d8371fcd3 100644 --- a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-16a1cd19eeefc63ce8a9.json +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-7708bee35485fa153138.json @@ -39,7 +39,7 @@ { "directoryIndex" : 0, "id" : "bdcmc.elf::@6890427a1f51a3e7e1df", - "jsonFile" : "target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json", + "jsonFile" : "target-bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json", "name" : "bdcmc.elf", "projectIndex" : 0 } diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-38-18-0515.json similarity index 94% rename from src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json rename to src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-38-18-0515.json index ba4197906..10c153a1e 100644 --- a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-01-34-0803.json +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/index-2024-03-08T01-38-18-0515.json @@ -26,7 +26,7 @@ "objects" : [ { - "jsonFile" : "codemodel-v2-16a1cd19eeefc63ce8a9.json", + "jsonFile" : "codemodel-v2-7708bee35485fa153138.json", "kind" : "codemodel", "version" : { @@ -86,7 +86,7 @@ }, "codemodel-v2" : { - "jsonFile" : "codemodel-v2-16a1cd19eeefc63ce8a9.json", + "jsonFile" : "codemodel-v2-7708bee35485fa153138.json", "kind" : "codemodel", "version" : { diff --git a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json similarity index 99% rename from src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json rename to src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json index 591459bef..bb4116ba5 100644 --- a/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-7666b1706c409ed2da7f.json +++ b/src/esw/fw/bdcmc/cmake-build-debug/.cmake/api/v1/reply/target-bdcmc.elf-Debug-079c3a58ef4b9d2cc771.json @@ -807,7 +807,7 @@ { "backtrace" : 1, "compileGroupIndex" : 0, - "path" : "Core/Src/motion/motion_profile.cpp", + "path" : "Core/Src/motion/trapezoidal_motion_profile.cpp", "sourceGroupIndex" : 1 }, { diff --git a/src/esw/fw/bdcmc/cmake-build-debug/CMakeFiles/bdcmc.elf.dir/Core/Src/motion/trapezoidal_motion_profile.cpp.obj b/src/esw/fw/bdcmc/cmake-build-debug/CMakeFiles/bdcmc.elf.dir/Core/Src/motion/trapezoidal_motion_profile.cpp.obj new file mode 100644 index 0000000000000000000000000000000000000000..3a17ef70c7754c4cbaae5a53e11b7e3ebd23329e GIT binary patch literal 7752 zcmbVRdvH|M89(>2n@u)Z@&Xb-+yvwy?B+q_9ZdpRKtzHB46QS9vwM@Q>?5z4{!wYc#<86`wT1qEchA|}Tmh}$ z1E7QxjW5 zXY>Pi9`{CeoUYvb>M4ERtEWuu+`rDA+Z)**dFYJyz#FH0-@h*M<;b?vb$;r-k!g|b zr|Xtrk3tet3e*}L>qR%*0&kDMtvaQuUf zWfLC^ml?;OJFOph?){1TkDSpCeDoJ_5<^oYj#taFEtz~GlkUl81`|n3_@uS9tv4GT zv2MvE;?d+(m!eNGkYsikLU@E`QmnWekA{dY#N#NO6-7Ru`8+cFd?mf`_n9U40sIws z%=jUE9!Cj~5n4HwbyZ-0j0%Imy(k6+eE~SvLrj~8RGQ)YEgWdq^h&XY_#IYzR#g+C zlv@8WMAw+*eXYn0c({}IJ_5rXkD9-@rikAtJ?Ln!{E?E33P`*P@LuR@uF zV%OK-q`h(gk5lBda)vTK0#Dy|lUTVr|>>Aa{lDNHvx zLNhoH?7>Xo`2bL74&wO^iihU9#Rkr?csW)nl%@ylMt(+<}#R_#}u`)0qrO) zDBi>HGpYFo%DvR=hQ>q9BPfTd`2=A~sQEd{v()t9;iKlyC~r~ocleZ2<43+yHen6~ zwnF1}(MV>!Vy*$Rgqj)q^Qh811IBiK5zJQlyrCGj$Bz6D zsS)N5a4hB+TE${6MO#_SXHb{L=d3m~zWyCAU$ZKJqNyS)aJ>=By)2BEDUE@5$1 z{o49;zzAT#rU`$8NxQdA7=hId+8Y0=hVo4{`plnn&BX9k*jim`SNdBU&;Z|j;rCzZ zX8?>HYnO$!tLlwFI=~#Q4cglJc#Q_VU)PL)zhTkp20KK_CAPM_;4PIN)^gOTsM0PA z)FAroz>b+!S|yqhn1d`xjvafNtm{XU{H%G6e@opZHLZT8#JXjJ>5FE-yXs=zY+yA8 z0Dd*HN7%}0yP#p8rdLX4#&m6y-R_w@Na|RFIj~H^+J>5VO_f&d?Wnt@p7CaR?EG!@ zasX#T_N}%XTO3p|0~6#C_MV4;BrhMPsMC7Py5-tVbNNxd?0d#zB6O_nm^eaXk)-Qv z-@%SU=E2TGraAj1&D(p(+yV9_?S0LQiX97%nD1+6i~6(LL0#z&>PL0ykD$IF9$|0a zA#>NELW{gBp)tjncjqDVdc-`gy{JjvJ}xh2M@^f&y#P~`$+%|O)0%#pFrU^=X!-*i z%@f)yltI25@%V+N^7G}x0s~Es4mSoxm0;A!*_+i-UG&3lh*x0IwNC;S0#^b11;9Jd zv?FI_b4@p;qJx7?xooT{mCcM{(qkLN}QME}@GJ{z8TY53|?al^Gcg6oznX>AU+EDN`WTY|04t;<@P zn^y%xslj9>nhzmb`*1WHr($HZeQ;!~EtDGx#aos`6N4s}$>y!`P^t}bet0xBpfH4! z%gXM_WOqXo&Blh?quJEh3M-UaGB^?p4cUKN0l9pCJkH4%H^U%Rw!wuhw{Vi&68u08cjkN%MT>`F%bRvn@6lkV>~f7 zDa2AEL;3TJ?fSNEc%5&^w_?QOnb84U)nMOz;fY&0W+gMRME>UP3rwCpt*K3EEP`mV zxES)oiJVYXCmR~Y5=d={j_;H~zxbOp`8GCv#{2X|Ue;JDy4wm3j3$!tP}~|A9TNF< z+0jJKTAxWF#h45h7jkk_Yt zB4zbvib*Yd2#X@$y{Yb*d^EW}k;_NZF-uH+VVvz5vV_>MZr$qOqRwn8$XBU1lS#&g zqlt9kb;?@Fmf)f;jzSP?KZJK|#p1>8SIxeTodan?zco-^A=av$8OV*gD=`1A(z|_M zFS*CN&$HjW*EpbmQ|k&W_4N2X+sZlvEA`vU0!zERJ>G4B`CWd|xeOKUeL!f7x$Uj! z4s8+Mijpm*dYQM{tktG#GmSc}UYn)O*5+t)wMK64Q^=_>#fRsdMgvEKlMKhfLcM|G z#7PE@;-FIjc^>4tViNoOEqWNPFB?OY+Wtic$WAhZ-(|<`!$Af{nE58De3Auch=9wE zOPGTUG0kP4=CHDUmCMd=rAaabE-?-=#B_(m`ZHW|;p18<4KYixHX4FQ`Xm`*?xX~0HnOdCG$3~i1yt|08$=z$@f5JE4bdP zu|A%ZcKSA8eqWF>zl$3%pTCzffj(-1&IVtF`J5}e#F?(b{PFWn5&ikiL@L-ZU!SoF z&d-ba?&DRRwNs7~?$EAHVv2}kM%62vPx8Q?+}}R$S<<`RwG-kb>fLl6-Og)Un)~}> z@Oz$!Mg6+OcZi5LA!UHLTy9(X zlEPJ4=jI90!%|*~yEWy@r5uv-B8hm7`J0!HMaa)=BHwHx-(VeIis+KiAuu%c>?d)B zMDG2Rw@KV7@oN(INqj=$a}s|k@okBJlK5YVyuLH;B@!1&3`y*h$csPy?vi-F#KRIF zlQ<#KtHU4THl4`$M0{QHla|;dahb%GMEG?|xm)7ZQomiw*Gs%X>MbcJB&MZ)kCeY6 zaj(?xm-2lQA0(ok- zoF{Ri#HA9OCGy85`md6BrNl0Y8zgR)*dvj@;jtc18us%_iT6q5_b&A(CB7%Iobw1h zPhcI#68A>R_BsasLCUp696NkJX&2$#&8d8J0GQ7fa9DBp9LS3>@9ZKxkjsfM?m=NH z!=L}E9PYesOBhw61OInTW-HWA#K-^t+8H(+E&cTNYWE{sw0~-=4NuxGwwb!aTx3IZ zxn6AVv|a71w!Nie{CVx}j}8oEt+B!s6g2o6N#brRr$u^Yqv;`QiYl8P`jlHTfy=uL zjL8;ZeuP=LU^|izW}_)MaRQ?Gd^RyKnrGmlY-V%>%jWYE_YLPQia#83@12Ljy^}v> zu(1=Ai6R!mBPz7@P(MG~iW4GtC{BD9D>p1iB zj-!ZuBH?JUZ?zp1K;t+-ct>JCSeJdJ?~N#|uG%~7hy}H6BR*2#NA92iq95z4b}%04 zFbZ$e9Vny;cg%***x zd23PMjt3oS9|X>&B9-?lm*1n18Ap-wTLZnbzdmf3+|!tsw|bTLCRaTEw0^#Lyhl3Y z1rbm6gX>qt`<9Fcl}#rg?=qA$Id2cR;x!}QK8z9D$Gu&}`>reAbnM9wL#IfwPr3Y_ z!~&S5jBr-$6JVVE_$khUm9R4}?=ULwZ(Q+S#xI6J*cGXGzjDQ!kY@|yalBQ$w_Nf5 zhIl+{6sdS`xZ<% Date: Thu, 7 Mar 2024 21:05:52 -0500 Subject: [PATCH 07/15] Remove inheritance, templatize with units --- src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 77 +++++++++++-------- .../Src/motion/trapezoidal_motion_profile.cpp | 20 ----- 2 files changed, 44 insertions(+), 53 deletions(-) delete mode 100644 src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index a07176eed..ea6c025be 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -1,39 +1,50 @@ -class MotionProfile { -public: - MotionProfile(double initialPosition, - double desiredPosition, - double maxVelocity, - double maxAcceleration) : mInitialPosition{initialPosition}, - mDesiredPosition{desiredPosition}, - mMaxVelocity{maxVelocity}, - mMaxAcceleration{maxAcceleration} {} +#include "units/units.hpp" - // velocity of the profile at time t - [[nodiscard]] virtual double velocity(double t) const = 0; +namespace mrover { + template + class TrapezoidalMotionProfile { + using VelocityUnit = compound_unit>; + using AccelerationUnit = compound_unit>; + public: + TrapezoidalMotionProfile(PositionUnit initialPosition, + PositionUnit desiredPosition, + VelocityUnit maxVelocity, + AccelerationUnit maxAcceleration) : mInitialPosition{initialPosition}, + mDesiredPosition{desiredPosition}, + mMaxVelocity{maxVelocity}, + mMaxAcceleration{maxAcceleration} {} - void update(double initialPosition, - double desiredPosition) { - mInitialPosition = initialPosition; - mDesiredPosition = desiredPosition; - } + void update(PositionUnit initialPosition, + PositionUnit desiredPosition) { + mInitialPosition = initialPosition; + mDesiredPosition = desiredPosition; + } + // TODO: build in way to keep track of start time to class + [[nodiscard]] double velocity(TimeUnit t) const override { + double totalDistance = (mDesiredPosition - mInitialPosition); + double timeToAccelerate = mMaxVelocity / mMaxAcceleration; -protected: - double mInitialPosition; - double mDesiredPosition; + double tAccelerationDone = timeToAccelerate; + double tEnd = tAccelerationDone + totalDistance / mMaxVelocity; + double tCruiseDone = tEnd - tAccelerationDone; - double mMaxVelocity; - double mMaxAcceleration; -}; + if (t >= 0 && t < tAccelerationDone) { + return mMaxAcceleration * t; + } else if (t >= tAccelerationDone && t < tCruiseDone) { + return mMaxVelocity; + } else if (t >= tCruiseDone && t <= tEnd) { + return -mMaxAcceleration * t + mMaxAcceleration * tEnd; + } else { + return 0.0; + } + } -class TrapezoidalMotionProfile : public MotionProfile { -public: - TrapezoidalMotionProfile(double initialPosition, - double desiredPosition, - double maxVelocity, - double maxAcceleration) : MotionProfile(initialPosition, - desiredPosition, - maxVelocity, - maxAcceleration) {} - [[nodiscard]] double velocity(double t) const override; -}; \ No newline at end of file + protected: + PositionUnit mInitialPosition; + PositionUnit mDesiredPosition; + + VelocityUnit mMaxVelocity; + AccelerationUnit mMaxAcceleration; + }; +} \ No newline at end of file diff --git a/src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp b/src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp deleted file mode 100644 index 0a76f4c82..000000000 --- a/src/esw/fw/bdcmc/Core/Src/motion/trapezoidal_motion_profile.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "motion_profile.hpp" - -double TrapezoidalMotionProfile::velocity(double t) const { - double totalDistance = (mDesiredPosition - mInitialPosition); - double timeToAccelerate = mMaxVelocity / mMaxAcceleration; - - double tAccelerationDone = timeToAccelerate; - double tEnd = tAccelerationDone + totalDistance / mMaxVelocity; - double tCruiseDone = tEnd - tAccelerationDone; - - if (t >= 0 && t < tAccelerationDone) { - return mMaxAcceleration * t; - } else if (t >= tAccelerationDone && t < tCruiseDone) { - return mMaxVelocity; - } else if (t >= tCruiseDone && t <= tEnd) { - return -mMaxAcceleration * t + mMaxAcceleration * tEnd; - } else { - return 0.0; - } -} \ No newline at end of file From 8762b61dfb1b9bd4d5a8180591585e05858e3578 Mon Sep 17 00:00:00 2001 From: jmaff Date: Tue, 12 Mar 2024 20:53:54 -0400 Subject: [PATCH 08/15] [mopro] Add timer 8 for profile following --- src/esw/fw/bdcmc/Core/Src/main.c | 50 ++ src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c | 22 + src/esw/fw/bdcmc/bdcmc.ioc | 712 +++++++++--------- 3 files changed, 431 insertions(+), 353 deletions(-) diff --git a/src/esw/fw/bdcmc/Core/Src/main.c b/src/esw/fw/bdcmc/Core/Src/main.c index 3a51135d8..d430bd76d 100644 --- a/src/esw/fw/bdcmc/Core/Src/main.c +++ b/src/esw/fw/bdcmc/Core/Src/main.c @@ -52,6 +52,7 @@ TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim4; TIM_HandleTypeDef htim7; +TIM_HandleTypeDef htim8; TIM_HandleTypeDef htim15; TIM_HandleTypeDef htim16; TIM_HandleTypeDef htim17; @@ -74,6 +75,7 @@ static void MX_TIM16_Init(void); static void MX_TIM2_Init(void); static void MX_TIM1_Init(void); static void MX_TIM17_Init(void); +static void MX_TIM8_Init(void); /* USER CODE BEGIN PFP */ void HAL_PostInit(); /* USER CODE END PFP */ @@ -150,6 +152,7 @@ int main(void) MX_TIM2_Init(); MX_TIM1_Init(); MX_TIM17_Init(); + MX_TIM8_Init(); /* USER CODE BEGIN 2 */ HAL_PostInit(); @@ -557,6 +560,53 @@ static void MX_TIM7_Init(void) } +/** + * @brief TIM8 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM8_Init(void) +{ + + /* USER CODE BEGIN TIM8_Init 0 */ + + /* USER CODE END TIM8_Init 0 */ + + TIM_ClockConfigTypeDef sClockSourceConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM8_Init 1 */ + + /* USER CODE END TIM8_Init 1 */ + htim8.Instance = TIM8; + htim8.Init.Prescaler = 7; + htim8.Init.CounterMode = TIM_COUNTERMODE_UP; + htim8.Init.Period = 17500; + htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim8.Init.RepetitionCounter = 0; + htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_Base_Init(&htim8) != HAL_OK) + { + Error_Handler(); + } + sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; + if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM8_Init 2 */ + + /* USER CODE END TIM8_Init 2 */ + +} + /** * @brief TIM15 Initialization Function * @param None diff --git a/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c b/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c index 12d98f61d..6f3797e7f 100644 --- a/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c +++ b/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c @@ -355,6 +355,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM7_MspInit 1 */ } + else if(htim_base->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspInit 0 */ + + /* USER CODE END TIM8_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM8_CLK_ENABLE(); + /* USER CODE BEGIN TIM8_MspInit 1 */ + + /* USER CODE END TIM8_MspInit 1 */ + } else if(htim_base->Instance==TIM16) { /* USER CODE BEGIN TIM16_MspInit 0 */ @@ -590,6 +601,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM7_MspDeInit 1 */ } + else if(htim_base->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspDeInit 0 */ + + /* USER CODE END TIM8_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM8_CLK_DISABLE(); + /* USER CODE BEGIN TIM8_MspDeInit 1 */ + + /* USER CODE END TIM8_MspDeInit 1 */ + } else if(htim_base->Instance==TIM16) { /* USER CODE BEGIN TIM16_MspDeInit 0 */ diff --git a/src/esw/fw/bdcmc/bdcmc.ioc b/src/esw/fw/bdcmc/bdcmc.ioc index c94c505ae..33540cc67 100644 --- a/src/esw/fw/bdcmc/bdcmc.ioc +++ b/src/esw/fw/bdcmc/bdcmc.ioc @@ -1,353 +1,359 @@ -#MicroXplorer Configuration settings - do not modify -CAD.formats= -CAD.pinconfig= -CAD.provider= -Dma.I2C1_RX.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.I2C1_RX.0.EventEnable=DISABLE -Dma.I2C1_RX.0.Instance=DMA1_Channel1 -Dma.I2C1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.I2C1_RX.0.MemInc=DMA_MINC_ENABLE -Dma.I2C1_RX.0.Mode=DMA_NORMAL -Dma.I2C1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.I2C1_RX.0.PeriphInc=DMA_PINC_DISABLE -Dma.I2C1_RX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.I2C1_RX.0.Priority=DMA_PRIORITY_MEDIUM -Dma.I2C1_RX.0.RequestNumber=1 -Dma.I2C1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.I2C1_RX.0.SignalID=NONE -Dma.I2C1_RX.0.SyncEnable=DISABLE -Dma.I2C1_RX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.I2C1_RX.0.SyncRequestNumber=1 -Dma.I2C1_RX.0.SyncSignalID=NONE -Dma.I2C1_TX.1.Direction=DMA_MEMORY_TO_PERIPH -Dma.I2C1_TX.1.EventEnable=DISABLE -Dma.I2C1_TX.1.Instance=DMA1_Channel2 -Dma.I2C1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.I2C1_TX.1.MemInc=DMA_MINC_ENABLE -Dma.I2C1_TX.1.Mode=DMA_NORMAL -Dma.I2C1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.I2C1_TX.1.PeriphInc=DMA_PINC_DISABLE -Dma.I2C1_TX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.I2C1_TX.1.Priority=DMA_PRIORITY_MEDIUM -Dma.I2C1_TX.1.RequestNumber=1 -Dma.I2C1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.I2C1_TX.1.SignalID=NONE -Dma.I2C1_TX.1.SyncEnable=DISABLE -Dma.I2C1_TX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.I2C1_TX.1.SyncRequestNumber=1 -Dma.I2C1_TX.1.SyncSignalID=NONE -Dma.Request0=I2C1_RX -Dma.Request1=I2C1_TX -Dma.RequestsNb=2 -FDCAN1.AutoRetransmission=ENABLE -FDCAN1.CalculateBaudRateNominal=1000000 -FDCAN1.CalculateTimeBitNominal=1000 -FDCAN1.CalculateTimeQuantumNominal=7.142857142857143 -FDCAN1.DataPrescaler=1 -FDCAN1.DataSyncJumpWidth=13 -FDCAN1.DataTimeSeg1=14 -FDCAN1.DataTimeSeg2=13 -FDCAN1.FrameFormat=FDCAN_FRAME_FD_NO_BRS -FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalSyncJumpWidth,DataPrescaler,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,Mode,AutoRetransmission -FDCAN1.Mode=FDCAN_MODE_NORMAL -FDCAN1.NominalPrescaler=1 -FDCAN1.NominalSyncJumpWidth=19 -FDCAN1.NominalTimeSeg1=120 -FDCAN1.NominalTimeSeg2=19 -File.Version=6 -I2C1.IPParameters=Timing -I2C1.Timing=0x20B0CCFF -KeepUserPlacement=false -Mcu.CPN=STM32G431CBU3 -Mcu.Family=STM32G4 -Mcu.IP0=DMA -Mcu.IP1=FDCAN1 -Mcu.IP10=TIM7 -Mcu.IP11=TIM15 -Mcu.IP12=TIM16 -Mcu.IP13=TIM17 -Mcu.IP2=I2C1 -Mcu.IP3=NVIC -Mcu.IP4=RCC -Mcu.IP5=SYS -Mcu.IP6=TIM1 -Mcu.IP7=TIM2 -Mcu.IP8=TIM3 -Mcu.IP9=TIM4 -Mcu.IPNb=14 -Mcu.Name=STM32G431C(6-8-B)Ux -Mcu.Package=UFQFPN48 -Mcu.Pin0=PC13 -Mcu.Pin1=PC14-OSC32_IN -Mcu.Pin10=PB0 -Mcu.Pin11=PB1 -Mcu.Pin12=PB2 -Mcu.Pin13=PB14 -Mcu.Pin14=PB15 -Mcu.Pin15=PC6 -Mcu.Pin16=PA8 -Mcu.Pin17=PA11 -Mcu.Pin18=PA12 -Mcu.Pin19=PA13 -Mcu.Pin2=PC15-OSC32_OUT -Mcu.Pin20=PA14 -Mcu.Pin21=PA15 -Mcu.Pin22=PB6 -Mcu.Pin23=PB7 -Mcu.Pin24=PB8-BOOT0 -Mcu.Pin25=PB9 -Mcu.Pin26=VP_SYS_VS_Systick -Mcu.Pin27=VP_SYS_VS_DBSignals -Mcu.Pin28=VP_TIM2_VS_ClockSourceINT -Mcu.Pin29=VP_TIM7_VS_ClockSourceINT -Mcu.Pin3=PF0-OSC_IN -Mcu.Pin30=VP_TIM16_VS_ClockSourceINT -Mcu.Pin31=VP_TIM17_VS_ClockSourceINT -Mcu.Pin32=VP_TIM17_VS_no_output1 -Mcu.Pin4=PA1 -Mcu.Pin5=PA2 -Mcu.Pin6=PA3 -Mcu.Pin7=PA4 -Mcu.Pin8=PA6 -Mcu.Pin9=PC4 -Mcu.PinsNb=33 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G431CBUx -MxCube.Version=6.10.0 -MxDb.Version=DB.6.0.100 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -NVIC.DMA1_Channel2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN1_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.I2C1_ER_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.I2C1_EV_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:false -NVIC.TIM1_TRG_COM_TIM17_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.TIM1_UP_TIM16_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true -NVIC.TIM2_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true -NVIC.TIM7_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA1.GPIOParameters=GPIO_Label -PA1.GPIO_Label=DEBUG LED 0 -PA1.Locked=true -PA1.Signal=GPIO_Output -PA11.GPIOParameters=GPIO_Speed -PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PA11.Mode=FDCAN_Activate -PA11.Signal=FDCAN1_RX -PA12.GPIOParameters=GPIO_Speed -PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PA12.Locked=true -PA12.Mode=FDCAN_Activate -PA12.Signal=FDCAN1_TX -PA13.Mode=Serial_Wire -PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire -PA14.Signal=SYS_JTCK-SWCLK -PA15.GPIOParameters=GPIO_Label -PA15.GPIO_Label=CAN STANDBY -PA15.Locked=true -PA15.Signal=GPIO_Output -PA2.GPIOParameters=GPIO_Label -PA2.GPIO_Label=DEBUG LED 1 -PA2.Locked=true -PA2.Signal=GPIO_Output -PA3.GPIOParameters=GPIO_Label -PA3.GPIO_Label=DEBUG LED 2 -PA3.Locked=true -PA3.Signal=GPIO_Output -PA4.GPIOParameters=GPIO_Label -PA4.GPIO_Label=QUAD 1 B -PA4.Signal=S_TIM3_CH2 -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=QUAD 1 A -PA6.Signal=S_TIM3_CH1 -PA8.GPIOParameters=GPIO_Label -PA8.GPIO_Label=MOTOR 1 PWM -PA8.Signal=S_TIM1_CH1 -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=LIMIT 1-1 -PB0.Locked=true -PB0.Signal=GPIO_Input -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=LIMIT 1-2 -PB1.Locked=true -PB1.Signal=GPIO_Input -PB14.GPIOParameters=GPIO_Label -PB14.GPIO_Label=MOTOR 0 PWM -PB14.Locked=true -PB14.Signal=S_TIM15_CH1 -PB15.GPIOParameters=GPIO_Label -PB15.GPIO_Label=MOTOR 0 DIR -PB15.Locked=true -PB15.Signal=GPIO_Output -PB2.GPIOParameters=GPIO_Label -PB2.GPIO_Label=LIMIT 1-3 -PB2.Locked=true -PB2.Signal=GPIO_Input -PB6.GPIOParameters=GPIO_Label -PB6.GPIO_Label=QUAD 0 A -PB6.Signal=S_TIM4_CH1 -PB7.GPIOParameters=GPIO_Label -PB7.GPIO_Label=QUAD 0 B -PB7.Signal=S_TIM4_CH2 -PB8-BOOT0.Locked=true -PB8-BOOT0.Mode=I2C -PB8-BOOT0.Signal=I2C1_SCL -PB9.Mode=I2C -PB9.Signal=I2C1_SDA -PC13.GPIOParameters=GPIO_Label -PC13.GPIO_Label=LIMIT 0-0 -PC13.Locked=true -PC13.Signal=GPIO_Input -PC14-OSC32_IN.GPIOParameters=GPIO_Label -PC14-OSC32_IN.GPIO_Label=LIMIT 0-1 -PC14-OSC32_IN.Locked=true -PC14-OSC32_IN.Signal=GPIO_Input -PC15-OSC32_OUT.GPIOParameters=GPIO_Label -PC15-OSC32_OUT.GPIO_Label=LIMIT 0-2 -PC15-OSC32_OUT.Locked=true -PC15-OSC32_OUT.Signal=GPIO_Input -PC4.GPIOParameters=GPIO_Label -PC4.GPIO_Label=LIMIT 1-0 -PC4.Locked=true -PC4.Signal=GPIO_Input -PC6.GPIOParameters=GPIO_Label -PC6.GPIO_Label=MOTOR 1 DIR -PC6.Locked=true -PC6.Signal=GPIO_Output -PF0-OSC_IN.GPIOParameters=GPIO_Label -PF0-OSC_IN.GPIO_Label=LIMIT 0-3 -PF0-OSC_IN.Locked=true -PF0-OSC_IN.Signal=GPIO_Input -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=false -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G431CBUx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.5.1 -ProjectManager.FreePins=false -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=false -ProjectManager.LibraryCopy=1 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain=STM32CubeIDE -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=bdcmc.ioc -ProjectManager.ProjectName=bdcmc -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=STM32CubeIDE -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=true -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN1_Init-FDCAN1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_TIM15_Init-TIM15-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_TIM16_Init-TIM16-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_TIM17_Init-TIM17-false-HAL-true -RCC.ADC12Freq_Value=140000000 -RCC.AHBFreq_Value=140000000 -RCC.APB1Freq_Value=140000000 -RCC.APB1TimFreq_Value=140000000 -RCC.APB2Freq_Value=140000000 -RCC.APB2TimFreq_Value=140000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=140000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.FCLKCortexFreq_Value=140000000 -RCC.FDCANFreq_Value=140000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=140000000 -RCC.HSE_VALUE=8000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=140000000 -RCC.I2C2Freq_Value=140000000 -RCC.I2C3Freq_Value=140000000 -RCC.I2SFreq_Value=140000000 -RCC.IPParameters=ADC12Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLM,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=140000000 -RCC.LPUART1Freq_Value=140000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLM=RCC_PLLM_DIV2 -RCC.PLLN=35 -RCC.PLLPoutputFreq_Value=140000000 -RCC.PLLQoutputFreq_Value=140000000 -RCC.PLLRCLKFreq_Value=140000000 -RCC.PWRFreq_Value=140000000 -RCC.RNGFreq_Value=140000000 -RCC.SAI1Freq_Value=140000000 -RCC.SYSCLKFreq_VALUE=140000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.USART1Freq_Value=140000000 -RCC.USART2Freq_Value=140000000 -RCC.USART3Freq_Value=140000000 -RCC.USBFreq_Value=140000000 -RCC.VCOInputFreq_Value=8000000 -RCC.VCOOutputFreq_Value=280000000 -SH.S_TIM15_CH1.0=TIM15_CH1,PWM Generation1 CH1 -SH.S_TIM15_CH1.ConfNb=1 -SH.S_TIM1_CH1.0=TIM1_CH1,Output Compare1 CH1 -SH.S_TIM1_CH1.ConfNb=1 -SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface -SH.S_TIM3_CH1.ConfNb=1 -SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -SH.S_TIM3_CH2.ConfNb=1 -SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface -SH.S_TIM4_CH1.ConfNb=1 -SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface -SH.S_TIM4_CH2.ConfNb=1 -TIM1.Channel-Output\ Compare1\ CH1=TIM_CHANNEL_1 -TIM1.IPParameters=Channel-Output Compare1 CH1 -TIM15.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -TIM15.IPParameters=Prescaler,PeriodNoDither,Channel-PWM Generation1 CH1 -TIM15.PeriodNoDither=99 -TIM15.Prescaler=63 -TIM16.IPParameters=Prescaler,PeriodNoDither -TIM16.PeriodNoDither=54580 -TIM16.Prescaler=512 -TIM17.Channel=TIM_CHANNEL_1 -TIM17.IPParameters=Channel -TIM2.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE -TIM2.IPParameters=Prescaler,PeriodNoDither,AutoReloadPreload -TIM2.PeriodNoDither=58333 -TIM2.Prescaler=119 -TIM7.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE -TIM7.IPParameters=AutoReloadPreload,PeriodNoDither,Prescaler -TIM7.PeriodNoDither=49999 -TIM7.Prescaler=139 -VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals -VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT -VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT -VP_TIM17_VS_no_output1.Mode=Output Compare1 No Output -VP_TIM17_VS_no_output1.Signal=TIM17_VS_no_output1 -VP_TIM2_VS_ClockSourceINT.Mode=Internal -VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT -VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT -board=custom -isbadioc=false +#MicroXplorer Configuration settings - do not modify +CAD.formats= +CAD.pinconfig= +CAD.provider= +Dma.I2C1_RX.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.I2C1_RX.0.EventEnable=DISABLE +Dma.I2C1_RX.0.Instance=DMA1_Channel1 +Dma.I2C1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.I2C1_RX.0.MemInc=DMA_MINC_ENABLE +Dma.I2C1_RX.0.Mode=DMA_NORMAL +Dma.I2C1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.I2C1_RX.0.PeriphInc=DMA_PINC_DISABLE +Dma.I2C1_RX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.I2C1_RX.0.Priority=DMA_PRIORITY_MEDIUM +Dma.I2C1_RX.0.RequestNumber=1 +Dma.I2C1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.I2C1_RX.0.SignalID=NONE +Dma.I2C1_RX.0.SyncEnable=DISABLE +Dma.I2C1_RX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.I2C1_RX.0.SyncRequestNumber=1 +Dma.I2C1_RX.0.SyncSignalID=NONE +Dma.I2C1_TX.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.I2C1_TX.1.EventEnable=DISABLE +Dma.I2C1_TX.1.Instance=DMA1_Channel2 +Dma.I2C1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.I2C1_TX.1.MemInc=DMA_MINC_ENABLE +Dma.I2C1_TX.1.Mode=DMA_NORMAL +Dma.I2C1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.I2C1_TX.1.PeriphInc=DMA_PINC_DISABLE +Dma.I2C1_TX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.I2C1_TX.1.Priority=DMA_PRIORITY_MEDIUM +Dma.I2C1_TX.1.RequestNumber=1 +Dma.I2C1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.I2C1_TX.1.SignalID=NONE +Dma.I2C1_TX.1.SyncEnable=DISABLE +Dma.I2C1_TX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.I2C1_TX.1.SyncRequestNumber=1 +Dma.I2C1_TX.1.SyncSignalID=NONE +Dma.Request0=I2C1_RX +Dma.Request1=I2C1_TX +Dma.RequestsNb=2 +FDCAN1.AutoRetransmission=ENABLE +FDCAN1.CalculateBaudRateNominal=1000000 +FDCAN1.CalculateTimeBitNominal=1000 +FDCAN1.CalculateTimeQuantumNominal=7.142857142857143 +FDCAN1.DataPrescaler=1 +FDCAN1.DataSyncJumpWidth=13 +FDCAN1.DataTimeSeg1=14 +FDCAN1.DataTimeSeg2=13 +FDCAN1.FrameFormat=FDCAN_FRAME_FD_NO_BRS +FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalSyncJumpWidth,DataPrescaler,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,Mode,AutoRetransmission +FDCAN1.Mode=FDCAN_MODE_NORMAL +FDCAN1.NominalPrescaler=1 +FDCAN1.NominalSyncJumpWidth=19 +FDCAN1.NominalTimeSeg1=120 +FDCAN1.NominalTimeSeg2=19 +File.Version=6 +I2C1.IPParameters=Timing +I2C1.Timing=0x20B0CCFF +KeepUserPlacement=false +Mcu.CPN=STM32G431CBU3 +Mcu.Family=STM32G4 +Mcu.IP0=DMA +Mcu.IP1=FDCAN1 +Mcu.IP10=TIM7 +Mcu.IP11=TIM8 +Mcu.IP12=TIM15 +Mcu.IP13=TIM16 +Mcu.IP14=TIM17 +Mcu.IP2=I2C1 +Mcu.IP3=NVIC +Mcu.IP4=RCC +Mcu.IP5=SYS +Mcu.IP6=TIM1 +Mcu.IP7=TIM2 +Mcu.IP8=TIM3 +Mcu.IP9=TIM4 +Mcu.IPNb=15 +Mcu.Name=STM32G431C(6-8-B)Ux +Mcu.Package=UFQFPN48 +Mcu.Pin0=PC13 +Mcu.Pin1=PC14-OSC32_IN +Mcu.Pin10=PB0 +Mcu.Pin11=PB1 +Mcu.Pin12=PB2 +Mcu.Pin13=PB14 +Mcu.Pin14=PB15 +Mcu.Pin15=PC6 +Mcu.Pin16=PA8 +Mcu.Pin17=PA11 +Mcu.Pin18=PA12 +Mcu.Pin19=PA13 +Mcu.Pin2=PC15-OSC32_OUT +Mcu.Pin20=PA14 +Mcu.Pin21=PA15 +Mcu.Pin22=PB6 +Mcu.Pin23=PB7 +Mcu.Pin24=PB8-BOOT0 +Mcu.Pin25=PB9 +Mcu.Pin26=VP_SYS_VS_Systick +Mcu.Pin27=VP_SYS_VS_DBSignals +Mcu.Pin28=VP_TIM2_VS_ClockSourceINT +Mcu.Pin29=VP_TIM7_VS_ClockSourceINT +Mcu.Pin3=PF0-OSC_IN +Mcu.Pin30=VP_TIM8_VS_ClockSourceINT +Mcu.Pin31=VP_TIM16_VS_ClockSourceINT +Mcu.Pin32=VP_TIM17_VS_ClockSourceINT +Mcu.Pin33=VP_TIM17_VS_no_output1 +Mcu.Pin4=PA1 +Mcu.Pin5=PA2 +Mcu.Pin6=PA3 +Mcu.Pin7=PA4 +Mcu.Pin8=PA6 +Mcu.Pin9=PC4 +Mcu.PinsNb=34 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32G431CBUx +MxCube.Version=6.10.0 +MxDb.Version=DB.6.0.100 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true +NVIC.DMA1_Channel2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.FDCAN1_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.I2C1_ER_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.I2C1_EV_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:false +NVIC.TIM1_TRG_COM_TIM17_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.TIM1_UP_TIM16_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true +NVIC.TIM2_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true +NVIC.TIM7_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=DEBUG LED 0 +PA1.Locked=true +PA1.Signal=GPIO_Output +PA11.GPIOParameters=GPIO_Speed +PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA11.Mode=FDCAN_Activate +PA11.Signal=FDCAN1_RX +PA12.GPIOParameters=GPIO_Speed +PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA12.Locked=true +PA12.Mode=FDCAN_Activate +PA12.Signal=FDCAN1_TX +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA15.GPIOParameters=GPIO_Label +PA15.GPIO_Label=CAN STANDBY +PA15.Locked=true +PA15.Signal=GPIO_Output +PA2.GPIOParameters=GPIO_Label +PA2.GPIO_Label=DEBUG LED 1 +PA2.Locked=true +PA2.Signal=GPIO_Output +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=DEBUG LED 2 +PA3.Locked=true +PA3.Signal=GPIO_Output +PA4.GPIOParameters=GPIO_Label +PA4.GPIO_Label=QUAD 1 B +PA4.Signal=S_TIM3_CH2 +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=QUAD 1 A +PA6.Signal=S_TIM3_CH1 +PA8.GPIOParameters=GPIO_Label +PA8.GPIO_Label=MOTOR 1 PWM +PA8.Signal=S_TIM1_CH1 +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=LIMIT 1-1 +PB0.Locked=true +PB0.Signal=GPIO_Input +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=LIMIT 1-2 +PB1.Locked=true +PB1.Signal=GPIO_Input +PB14.GPIOParameters=GPIO_Label +PB14.GPIO_Label=MOTOR 0 PWM +PB14.Locked=true +PB14.Signal=S_TIM15_CH1 +PB15.GPIOParameters=GPIO_Label +PB15.GPIO_Label=MOTOR 0 DIR +PB15.Locked=true +PB15.Signal=GPIO_Output +PB2.GPIOParameters=GPIO_Label +PB2.GPIO_Label=LIMIT 1-3 +PB2.Locked=true +PB2.Signal=GPIO_Input +PB6.GPIOParameters=GPIO_Label +PB6.GPIO_Label=QUAD 0 A +PB6.Signal=S_TIM4_CH1 +PB7.GPIOParameters=GPIO_Label +PB7.GPIO_Label=QUAD 0 B +PB7.Signal=S_TIM4_CH2 +PB8-BOOT0.Locked=true +PB8-BOOT0.Mode=I2C +PB8-BOOT0.Signal=I2C1_SCL +PB9.Mode=I2C +PB9.Signal=I2C1_SDA +PC13.GPIOParameters=GPIO_Label +PC13.GPIO_Label=LIMIT 0-0 +PC13.Locked=true +PC13.Signal=GPIO_Input +PC14-OSC32_IN.GPIOParameters=GPIO_Label +PC14-OSC32_IN.GPIO_Label=LIMIT 0-1 +PC14-OSC32_IN.Locked=true +PC14-OSC32_IN.Signal=GPIO_Input +PC15-OSC32_OUT.GPIOParameters=GPIO_Label +PC15-OSC32_OUT.GPIO_Label=LIMIT 0-2 +PC15-OSC32_OUT.Locked=true +PC15-OSC32_OUT.Signal=GPIO_Input +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=LIMIT 1-0 +PC4.Locked=true +PC4.Signal=GPIO_Input +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=MOTOR 1 DIR +PC6.Locked=true +PC6.Signal=GPIO_Output +PF0-OSC_IN.GPIOParameters=GPIO_Label +PF0-OSC_IN.GPIO_Label=LIMIT 0-3 +PF0-OSC_IN.Locked=true +PF0-OSC_IN.Signal=GPIO_Input +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32G431CBUx +ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.5.1 +ProjectManager.FreePins=false +ProjectManager.HalAssertFull=false +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=false +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Core/Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=STM32CubeIDE +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=bdcmc.ioc +ProjectManager.ProjectName=bdcmc +ProjectManager.ProjectStructure= +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=STM32CubeIDE +ProjectManager.ToolChainLocation= +ProjectManager.UAScriptAfterPath= +ProjectManager.UAScriptBeforePath= +ProjectManager.UnderRoot=true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN1_Init-FDCAN1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_TIM15_Init-TIM15-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_TIM16_Init-TIM16-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_TIM17_Init-TIM17-false-HAL-true +RCC.ADC12Freq_Value=140000000 +RCC.AHBFreq_Value=140000000 +RCC.APB1Freq_Value=140000000 +RCC.APB1TimFreq_Value=140000000 +RCC.APB2Freq_Value=140000000 +RCC.APB2TimFreq_Value=140000000 +RCC.CRSFreq_Value=48000000 +RCC.CortexFreq_Value=140000000 +RCC.EXTERNAL_CLOCK_VALUE=12288000 +RCC.FCLKCortexFreq_Value=140000000 +RCC.FDCANFreq_Value=140000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=140000000 +RCC.HSE_VALUE=8000000 +RCC.HSI48_VALUE=48000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=140000000 +RCC.I2C2Freq_Value=140000000 +RCC.I2C3Freq_Value=140000000 +RCC.I2SFreq_Value=140000000 +RCC.IPParameters=ADC12Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLM,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value +RCC.LPTIM1Freq_Value=140000000 +RCC.LPUART1Freq_Value=140000000 +RCC.LSCOPinFreq_Value=32000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO1PinFreq_Value=16000000 +RCC.PLLM=RCC_PLLM_DIV2 +RCC.PLLN=35 +RCC.PLLPoutputFreq_Value=140000000 +RCC.PLLQoutputFreq_Value=140000000 +RCC.PLLRCLKFreq_Value=140000000 +RCC.PWRFreq_Value=140000000 +RCC.RNGFreq_Value=140000000 +RCC.SAI1Freq_Value=140000000 +RCC.SYSCLKFreq_VALUE=140000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.USART1Freq_Value=140000000 +RCC.USART2Freq_Value=140000000 +RCC.USART3Freq_Value=140000000 +RCC.USBFreq_Value=140000000 +RCC.VCOInputFreq_Value=8000000 +RCC.VCOOutputFreq_Value=280000000 +SH.S_TIM15_CH1.0=TIM15_CH1,PWM Generation1 CH1 +SH.S_TIM15_CH1.ConfNb=1 +SH.S_TIM1_CH1.0=TIM1_CH1,Output Compare1 CH1 +SH.S_TIM1_CH1.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +SH.S_TIM3_CH1.ConfNb=1 +SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface +SH.S_TIM3_CH2.ConfNb=1 +SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface +SH.S_TIM4_CH1.ConfNb=1 +SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface +SH.S_TIM4_CH2.ConfNb=1 +TIM1.Channel-Output\ Compare1\ CH1=TIM_CHANNEL_1 +TIM1.IPParameters=Channel-Output Compare1 CH1 +TIM15.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM15.IPParameters=Prescaler,PeriodNoDither,Channel-PWM Generation1 CH1 +TIM15.PeriodNoDither=99 +TIM15.Prescaler=63 +TIM16.IPParameters=Prescaler,PeriodNoDither +TIM16.PeriodNoDither=54580 +TIM16.Prescaler=512 +TIM17.Channel=TIM_CHANNEL_1 +TIM17.IPParameters=Channel +TIM2.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE +TIM2.IPParameters=Prescaler,PeriodNoDither,AutoReloadPreload +TIM2.PeriodNoDither=58333 +TIM2.Prescaler=119 +TIM7.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE +TIM7.IPParameters=AutoReloadPreload,PeriodNoDither,Prescaler +TIM7.PeriodNoDither=49999 +TIM7.Prescaler=139 +TIM8.IPParameters=PeriodNoDither,Prescaler +TIM8.PeriodNoDither=17500 +TIM8.Prescaler=7 +VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals +VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT +VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT +VP_TIM17_VS_no_output1.Mode=Output Compare1 No Output +VP_TIM17_VS_no_output1.Signal=TIM17_VS_no_output1 +VP_TIM2_VS_ClockSourceINT.Mode=Internal +VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT +VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT +VP_TIM8_VS_ClockSourceINT.Mode=Internal +VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT +board=custom From 4f8170571ab9b9635b6347f913bf759c45ef4886 Mon Sep 17 00:00:00 2001 From: jmaff Date: Tue, 12 Mar 2024 20:54:43 -0400 Subject: [PATCH 09/15] [mopro] Use time delta --- src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index ea6c025be..ef9bded78 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -14,14 +14,19 @@ namespace mrover { mMaxVelocity{maxVelocity}, mMaxAcceleration{maxAcceleration} {} - void update(PositionUnit initialPosition, + void reset () { + mT = 0; + } + + void reset(PositionUnit initialPosition, PositionUnit desiredPosition) { mInitialPosition = initialPosition; mDesiredPosition = desiredPosition; + reset(); } - // TODO: build in way to keep track of start time to class - [[nodiscard]] double velocity(TimeUnit t) const override { + auto velocity(TimeUnit dt) -> VelocityUnit { + mT += dt; double totalDistance = (mDesiredPosition - mInitialPosition); double timeToAccelerate = mMaxVelocity / mMaxAcceleration; @@ -29,22 +34,24 @@ namespace mrover { double tEnd = tAccelerationDone + totalDistance / mMaxVelocity; double tCruiseDone = tEnd - tAccelerationDone; - if (t >= 0 && t < tAccelerationDone) { - return mMaxAcceleration * t; - } else if (t >= tAccelerationDone && t < tCruiseDone) { + if (mT >= 0 && mT < tAccelerationDone) { + return mMaxAcceleration * mT; + } else if (mT >= tAccelerationDone && mT < tCruiseDone) { return mMaxVelocity; - } else if (t >= tCruiseDone && t <= tEnd) { - return -mMaxAcceleration * t + mMaxAcceleration * tEnd; + } else if (mT >= tCruiseDone && mT <= tEnd) { + return -mMaxAcceleration * mT + mMaxAcceleration * tEnd; } else { return 0.0; } } - protected: + private: PositionUnit mInitialPosition; PositionUnit mDesiredPosition; VelocityUnit mMaxVelocity; AccelerationUnit mMaxAcceleration; + + TimeUnit mT = 0; }; } \ No newline at end of file From 5e948cfcd77120d62d5fe6120f5b640a1dfb40b5 Mon Sep 17 00:00:00 2001 From: jmaff Date: Tue, 12 Mar 2024 21:12:58 -0400 Subject: [PATCH 10/15] [mopro] Separate time tracking from profile values --- src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index ef9bded78..6be0a2080 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -25,8 +25,11 @@ namespace mrover { reset(); } - auto velocity(TimeUnit dt) -> VelocityUnit { + void update(TimeUnit dt) { mT += dt; + } + + auto velocity() -> VelocityUnit { double totalDistance = (mDesiredPosition - mInitialPosition); double timeToAccelerate = mMaxVelocity / mMaxAcceleration; From df1a0b9f55ee378894d128a7eac69c4bb8829ffc Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 21 Mar 2024 20:41:47 -0400 Subject: [PATCH 11/15] [mopro] Begin profile command implementation --- src/esw/fw/bdcmc/Core/Inc/controller.hpp | 54 ++++++++++++++++++++ src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 54 ++++++++++---------- src/esw/fw/bdcmc/Core/Inc/timer.hpp | 20 ++++++++ 3 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 src/esw/fw/bdcmc/Core/Inc/timer.hpp diff --git a/src/esw/fw/bdcmc/Core/Inc/controller.hpp b/src/esw/fw/bdcmc/Core/Inc/controller.hpp index 90adcc4b0..e2db54a94 100644 --- a/src/esw/fw/bdcmc/Core/Inc/controller.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/controller.hpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include "timer.hpp" #include #include "encoders.hpp" @@ -27,6 +29,7 @@ namespace mrover { }; using Mode = std::variant; + using MotionProfile = TrapezoidalMotionProfile; /* ==================== Hardware ==================== */ FDCAN m_fdcan; @@ -49,6 +52,9 @@ namespace mrover { std::optional m_velocity; BDCMCErrorInfo m_error = BDCMCErrorInfo::DEFAULT_START_UP_NOT_CONFIGURED; + std::optional m_profile; + Timer m_profile_timer; + struct StateAfterConfig { Dimensionless gear_ratio; Radians min_position; @@ -253,6 +259,54 @@ namespace mrover { m_error = BDCMCErrorInfo::NO_ERROR; } + auto process_command(PositionCommandProfiled const& message, PositionMode& mode) -> void { + if (!m_state_after_config) { + m_error = BDCMCErrorInfo::RECEIVING_COMMANDS_WHEN_NOT_CONFIGURED; + return; + } + if (!m_state_after_calib) { + m_error = BDCMCErrorInfo::RECEIVING_POSITION_COMMANDS_WHEN_NOT_CALIBRATED; + return; + } + + if (!m_uncalib_position) { + m_error = BDCMCErrorInfo::RECEIVING_PID_COMMANDS_WHEN_NO_READER_EXISTS; + return; + } + + if (!m_velocity) { + m_error = BDCMCErrorInfo::RECEIVING_PID_COMMANDS_WHEN_NO_READER_EXISTS; + return; + } + + Radians current_position = m_uncalib_position.value() - m_state_after_calib->offset_position; + + if (m_profile) { + m_profile->update(m_profile_timer.seconds()); + } else { + m_profile = MotionProfile{current_position, message.position, idk, message.max_acceleration}; + m_profile_timer.reset(); + } + + mode.pidf.with_p(message.p); + mode.pidf.with_d(message.d); + mode.pidf.with_ff(message.ff); + mode.pidf.with_output_bound(-1.0, 1.0); + + RadiansPerSecond current_velocity = m_velocity.value(); + RadiansPerSecond target_velocity = m_profile->velocity(); + + m_desired_output = mode.pidf.calculate(current_velocity, target_velocity, m_profile_timer.seconds()); + m_error = BDCMCErrorInfo::NO_ERROR; + + m_fdcan.broadcast(OutBoundMessage{DebugState{ + .f1 = m_profile.value().t().get(), + .f2 = target_velocity.get(), + .f3 = current_position.get(), + .f4 = message.position.get() + }}); + } + struct detail { template struct command_to_mode; diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index 6be0a2080..3566d778d 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -9,52 +9,52 @@ namespace mrover { TrapezoidalMotionProfile(PositionUnit initialPosition, PositionUnit desiredPosition, VelocityUnit maxVelocity, - AccelerationUnit maxAcceleration) : mInitialPosition{initialPosition}, - mDesiredPosition{desiredPosition}, - mMaxVelocity{maxVelocity}, - mMaxAcceleration{maxAcceleration} {} + AccelerationUnit maxAcceleration) : mMaxVelocity{maxVelocity}, + mMaxAcceleration{maxAcceleration}, + mTotalDistance{initialPosition - desiredPosition}, + mTAccelerationDone{mMaxVelocity / mMaxAcceleration}, + mTEnd{mTAccelerationDone + mTotalDistance / mMaxVelocity}, + mTCruiseDone{mTEnd - mTAccelerationDone} + {} void reset () { mT = 0; } - void reset(PositionUnit initialPosition, - PositionUnit desiredPosition) { - mInitialPosition = initialPosition; - mDesiredPosition = desiredPosition; - reset(); - } - void update(TimeUnit dt) { mT += dt; } auto velocity() -> VelocityUnit { - double totalDistance = (mDesiredPosition - mInitialPosition); - double timeToAccelerate = mMaxVelocity / mMaxAcceleration; - - double tAccelerationDone = timeToAccelerate; - double tEnd = tAccelerationDone + totalDistance / mMaxVelocity; - double tCruiseDone = tEnd - tAccelerationDone; - - if (mT >= 0 && mT < tAccelerationDone) { + if (mT >= 0 && mT < mTAccelerationDone) { return mMaxAcceleration * mT; - } else if (mT >= tAccelerationDone && mT < tCruiseDone) { + } else if (mT >= mTAccelerationDone && mT < mTCruiseDone) { return mMaxVelocity; - } else if (mT >= tCruiseDone && mT <= tEnd) { - return -mMaxAcceleration * mT + mMaxAcceleration * tEnd; + } else if (mT >= mTCruiseDone && mT <= mTEnd) { + return -mMaxAcceleration * mT + mMaxAcceleration * mTEnd; } else { return 0.0; } } + auto is_finished() -> bool { + return mT >= mTEnd; + } + + auto t() -> TimeUnit { + return mT; + } + private: - PositionUnit mInitialPosition; - PositionUnit mDesiredPosition; + const VelocityUnit mMaxVelocity{}; + const AccelerationUnit mMaxAcceleration{}; + + TimeUnit mT{0}; - VelocityUnit mMaxVelocity; - AccelerationUnit mMaxAcceleration; + const PositionUnit mTotalDistance{}; + const TimeUnit mTAccelerationDone{}; + const TimeUnit mTEnd{}; + const TimeUnit mTCruiseDone{}; - TimeUnit mT = 0; }; } \ No newline at end of file diff --git a/src/esw/fw/bdcmc/Core/Inc/timer.hpp b/src/esw/fw/bdcmc/Core/Inc/timer.hpp new file mode 100644 index 000000000..54906ed3a --- /dev/null +++ b/src/esw/fw/bdcmc/Core/Inc/timer.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "units/units.hpp" + +namespace mrover { + + class Timer { + public: + Seconds seconds() { + return Seconds{0.0}; // TODO + } + + void reset() { + // TODO + } + + // TODO: add timer handler + }; + +} \ No newline at end of file From 52d98097332819fe5bcc84e624b8151607138367 Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 28 Mar 2024 20:11:11 -0400 Subject: [PATCH 12/15] [mopro] Fix unit issues --- src/esw/fw/bdcmc/Core/Inc/controller.hpp | 6 ++++-- src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp | 17 ++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/esw/fw/bdcmc/Core/Inc/controller.hpp b/src/esw/fw/bdcmc/Core/Inc/controller.hpp index e2db54a94..d9a211429 100644 --- a/src/esw/fw/bdcmc/Core/Inc/controller.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/controller.hpp @@ -259,7 +259,7 @@ namespace mrover { m_error = BDCMCErrorInfo::NO_ERROR; } - auto process_command(PositionCommandProfiled const& message, PositionMode& mode) -> void { + auto process_command(PositionCommandProfiled const& message, VelocityMode& mode) -> void { if (!m_state_after_config) { m_error = BDCMCErrorInfo::RECEIVING_COMMANDS_WHEN_NOT_CONFIGURED; return; @@ -284,7 +284,9 @@ namespace mrover { if (m_profile) { m_profile->update(m_profile_timer.seconds()); } else { - m_profile = MotionProfile{current_position, message.position, idk, message.max_acceleration}; + // TODO: grab max velocity from somewhere +// m_profile = MotionProfile{current_position, message.position, RadiansPerSecond{0.0}, message.max_acceleration}; + m_profile.emplace(current_position, message.position, RadiansPerSecond {0.0}, message.max_acceleration); m_profile_timer.reset(); } diff --git a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp index 3566d778d..f0ed9e59f 100644 --- a/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/motion_profile.hpp @@ -26,14 +26,14 @@ namespace mrover { } auto velocity() -> VelocityUnit { - if (mT >= 0 && mT < mTAccelerationDone) { + if (mT >= TimeUnit{0} && mT < mTAccelerationDone) { return mMaxAcceleration * mT; } else if (mT >= mTAccelerationDone && mT < mTCruiseDone) { return mMaxVelocity; } else if (mT >= mTCruiseDone && mT <= mTEnd) { return -mMaxAcceleration * mT + mMaxAcceleration * mTEnd; } else { - return 0.0; + return VelocityUnit{0}; } } @@ -46,15 +46,14 @@ namespace mrover { } private: - const VelocityUnit mMaxVelocity{}; - const AccelerationUnit mMaxAcceleration{}; + VelocityUnit mMaxVelocity{}; + AccelerationUnit mMaxAcceleration{}; TimeUnit mT{0}; - const PositionUnit mTotalDistance{}; - const TimeUnit mTAccelerationDone{}; - const TimeUnit mTEnd{}; - const TimeUnit mTCruiseDone{}; - + PositionUnit mTotalDistance{}; + TimeUnit mTAccelerationDone{}; + TimeUnit mTEnd{}; + TimeUnit mTCruiseDone{}; }; } \ No newline at end of file From 0b90d767f0ca3e30775c79200a806e1c55253f39 Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 28 Mar 2024 20:46:20 -0400 Subject: [PATCH 13/15] [mopro] Integrate timer into profile --- src/esw/fw/bdcmc/Core/Inc/controller.hpp | 19 ++++++++++++------- src/esw/fw/bdcmc/Core/Inc/timer.hpp | 20 -------------------- src/esw/fw/bdcmc/Core/Src/controller.cpp | 3 +++ 3 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 src/esw/fw/bdcmc/Core/Inc/timer.hpp diff --git a/src/esw/fw/bdcmc/Core/Inc/controller.hpp b/src/esw/fw/bdcmc/Core/Inc/controller.hpp index d9a211429..0442d75f8 100644 --- a/src/esw/fw/bdcmc/Core/Inc/controller.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/controller.hpp @@ -8,9 +8,8 @@ #include #include -#include #include -#include "timer.hpp" +#include #include #include "encoders.hpp" @@ -31,10 +30,14 @@ namespace mrover { using Mode = std::variant; using MotionProfile = TrapezoidalMotionProfile; + // TODO: maybe pull this from htim directly, I was too lazy to figure that out + static constexpr double SECONDS_PER_PROFILE_TIMER_TICK = 1 / (140'000'000.0 / 8.0); + /* ==================== Hardware ==================== */ FDCAN m_fdcan; HBridge m_motor_driver; TIM_HandleTypeDef* m_watchdog_timer{}; + TIM_HandleTypeDef* m_profile_timer{}; bool m_watchdog_enabled{}; TIM_HandleTypeDef* m_encoder_timer{}; TIM_HandleTypeDef* m_encoder_elapsed_timer{}; @@ -53,7 +56,6 @@ namespace mrover { BDCMCErrorInfo m_error = BDCMCErrorInfo::DEFAULT_START_UP_NOT_CONFIGURED; std::optional m_profile; - Timer m_profile_timer; struct StateAfterConfig { Dimensionless gear_ratio; @@ -281,13 +283,15 @@ namespace mrover { Radians current_position = m_uncalib_position.value() - m_state_after_calib->offset_position; + Seconds time_elapsed{0}; + if (m_profile) { - m_profile->update(m_profile_timer.seconds()); + time_elapsed = Seconds{m_profile_timer->Instance->CNT * SECONDS_PER_PROFILE_TIMER_TICK}; } else { // TODO: grab max velocity from somewhere // m_profile = MotionProfile{current_position, message.position, RadiansPerSecond{0.0}, message.max_acceleration}; m_profile.emplace(current_position, message.position, RadiansPerSecond {0.0}, message.max_acceleration); - m_profile_timer.reset(); + m_profile_timer->Instance->CNT = 0; } mode.pidf.with_p(message.p); @@ -298,7 +302,7 @@ namespace mrover { RadiansPerSecond current_velocity = m_velocity.value(); RadiansPerSecond target_velocity = m_profile->velocity(); - m_desired_output = mode.pidf.calculate(current_velocity, target_velocity, m_profile_timer.seconds()); + m_desired_output = mode.pidf.calculate(current_velocity, target_velocity, time_elapsed); m_error = BDCMCErrorInfo::NO_ERROR; m_fdcan.broadcast(OutBoundMessage{DebugState{ @@ -333,10 +337,11 @@ namespace mrover { public: Controller() = default; - Controller(TIM_HandleTypeDef* hbridge_output, Pin hbridge_forward_pin, Pin hbridge_backward_pin, FDCAN const& fdcan, TIM_HandleTypeDef* watchdog_timer, TIM_HandleTypeDef* encoder_tick_timer, TIM_HandleTypeDef* encoder_elapsed_timer, I2C_HandleTypeDef* absolute_encoder_i2c, std::array const& limit_switches) + Controller(TIM_HandleTypeDef* hbridge_output, Pin hbridge_forward_pin, Pin hbridge_backward_pin, FDCAN const& fdcan, TIM_HandleTypeDef* watchdog_timer, TIM_HandleTypeDef* profile_timer, TIM_HandleTypeDef* encoder_tick_timer, TIM_HandleTypeDef* encoder_elapsed_timer, I2C_HandleTypeDef* absolute_encoder_i2c, std::array const& limit_switches) : m_fdcan{fdcan}, m_motor_driver{HBridge(hbridge_output, hbridge_forward_pin, hbridge_backward_pin)}, m_watchdog_timer{watchdog_timer}, + m_profile_timer{profile_timer}, m_encoder_timer{encoder_tick_timer}, m_encoder_elapsed_timer{encoder_elapsed_timer}, m_absolute_encoder_i2c{absolute_encoder_i2c}, diff --git a/src/esw/fw/bdcmc/Core/Inc/timer.hpp b/src/esw/fw/bdcmc/Core/Inc/timer.hpp deleted file mode 100644 index 54906ed3a..000000000 --- a/src/esw/fw/bdcmc/Core/Inc/timer.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "units/units.hpp" - -namespace mrover { - - class Timer { - public: - Seconds seconds() { - return Seconds{0.0}; // TODO - } - - void reset() { - // TODO - } - - // TODO: add timer handler - }; - -} \ No newline at end of file diff --git a/src/esw/fw/bdcmc/Core/Src/controller.cpp b/src/esw/fw/bdcmc/Core/Src/controller.cpp index e80c52490..391a2d2a4 100644 --- a/src/esw/fw/bdcmc/Core/Src/controller.cpp +++ b/src/esw/fw/bdcmc/Core/Src/controller.cpp @@ -26,6 +26,7 @@ extern TIM_HandleTypeDef htim4; extern TIM_HandleTypeDef htim3; extern TIM_HandleTypeDef htim6; extern TIM_HandleTypeDef htim7; +extern TIM_HandleTypeDef htim8; extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim16; extern TIM_HandleTypeDef htim17; @@ -38,6 +39,7 @@ extern TIM_HandleTypeDef htim17; #define SEND_TIMER &htim7 // 20 Hz FDCAN repeating timer #define PWM_TIMER_1 &htim15 // H-Bridge PWM #define FDCAN_WATCHDOG_TIMER &htim16 // FDCAN watchdog timer that needs to be reset every time a message is received +#define MOTION_PROFILE_TIMER &htim7 // timer for keeping track of motion profile state namespace mrover { @@ -58,6 +60,7 @@ namespace mrover { Pin{GPIOC, GPIO_PIN_6}, fdcan_bus, FDCAN_WATCHDOG_TIMER, + MOTION_PROFILE_TIMER, QUADRATURE_TICK_TIMER_1, QUADRATURE_ELAPSED_TIMER_1, ABSOLUTE_I2C, From ca94727f0c42720d1370645073475bef015e7894 Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 11 Apr 2024 19:30:54 -0400 Subject: [PATCH 14/15] [mopro] Add profiled position command --- src/util/messaging.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/messaging.hpp b/src/util/messaging.hpp index 3cd8516ba..88e6c6e5b 100644 --- a/src/util/messaging.hpp +++ b/src/util/messaging.hpp @@ -86,6 +86,13 @@ namespace mrover { float p{}, i{}, d{}; }; + using RadiansPerSecondPerSecond = compound_unit>; + struct PositionCommandProfiled : BaseCommand { + Radians position; + float p{}, i{}, d{}, ff{}; + RadiansPerSecondPerSecond max_acceleration; + }; + struct ControllerDataState { Radians position; RadiansPerSecond velocity; From ebfbab0f7d337d553326df79998c171a3d9b04f8 Mon Sep 17 00:00:00 2001 From: jmaff Date: Thu, 11 Apr 2024 20:07:36 -0400 Subject: [PATCH 15/15] Switch profile timer to TIM4 --- src/esw/fw/bdcmc/.mxproject | 2 +- src/esw/fw/bdcmc/Core/Inc/controller.hpp | 4 +- src/esw/fw/bdcmc/Core/Src/controller.cpp | 5 +- src/esw/fw/bdcmc/Core/Src/main.c | 48 +++++++++++++++++++ src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c | 22 +++++++++ src/esw/fw/bdcmc/bdcmc.ioc | 36 ++++++++------ 6 files changed, 97 insertions(+), 20 deletions(-) diff --git a/src/esw/fw/bdcmc/.mxproject b/src/esw/fw/bdcmc/.mxproject index 39d7f8d4a..2d747f22f 100644 --- a/src/esw/fw/bdcmc/.mxproject +++ b/src/esw/fw/bdcmc/.mxproject @@ -1,5 +1,5 @@ [PreviousLibFiles] -LibFiles=Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g431xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/system_stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/cmsis_armclang.h; +LibFiles=Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_fdcan.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_def.h;Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_rcc_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_bus.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_rcc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_system.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_utils.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_crs.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_flash_ramfunc.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_gpio_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_gpio.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_exti.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_dma_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dmamux.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_pwr_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_pwr.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_cortex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_i2c.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_i2c_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_tim_ex.h;Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g431xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Include/system_stm32g4xx.h;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h; [PreviousUsedCubeIDEFiles] SourceFiles=Core/Src/main.c;Core/Src/stm32g4xx_it.c;Core/Src/stm32g4xx_hal_msp.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c;Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c;Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c;Core/Src/system_stm32g4xx.c;;; diff --git a/src/esw/fw/bdcmc/Core/Inc/controller.hpp b/src/esw/fw/bdcmc/Core/Inc/controller.hpp index 8e11db26d..0986708d8 100644 --- a/src/esw/fw/bdcmc/Core/Inc/controller.hpp +++ b/src/esw/fw/bdcmc/Core/Inc/controller.hpp @@ -366,17 +366,17 @@ namespace mrover { Controller(TIM_HandleTypeDef* hbridge_output, Pin hbridge_forward_pin, Pin hbridge_backward_pin, FDCAN const& fdcan, TIM_HandleTypeDef* watchdog_timer, TIM_HandleTypeDef* encoder_tick_timer, - TIM_HandleTypeDef* encoder_elapsed_timer, TIM_HandleTypeDef* throttle_timer, TIM_HandleTypeDef* pid_timer, + TIM_HandleTypeDef* encoder_elapsed_timer, TIM_HandleTypeDef* throttle_timer, TIM_HandleTypeDef* pid_timer, TIM_HandleTypeDef* profile_timer, I2C_HandleTypeDef* absolute_encoder_i2c, std::array const& limit_switches) : m_fdcan{fdcan}, m_motor_driver{HBridge(hbridge_output, hbridge_forward_pin, hbridge_backward_pin)}, m_watchdog_timer{watchdog_timer}, - m_profile_timer{profile_timer}, m_encoder_timer{encoder_tick_timer}, m_encoder_elapsed_timer{encoder_elapsed_timer}, m_throttle_timer{throttle_timer}, m_pidf_timer{pid_timer}, + m_profile_timer{profile_timer}, m_absolute_encoder_i2c{absolute_encoder_i2c}, m_limit_switches{limit_switches} { } diff --git a/src/esw/fw/bdcmc/Core/Src/controller.cpp b/src/esw/fw/bdcmc/Core/Src/controller.cpp index 37ebe99e6..460db86dd 100644 --- a/src/esw/fw/bdcmc/Core/Src/controller.cpp +++ b/src/esw/fw/bdcmc/Core/Src/controller.cpp @@ -23,6 +23,7 @@ extern I2C_HandleTypeDef hi2c1; extern TIM_HandleTypeDef htim2; extern TIM_HandleTypeDef htim3; +extern TIM_HandleTypeDef htim4; extern TIM_HandleTypeDef htim6; extern TIM_HandleTypeDef htim7; extern TIM_HandleTypeDef htim8; @@ -31,7 +32,7 @@ extern TIM_HandleTypeDef htim16; extern TIM_HandleTypeDef htim17; #define QUADRATURE_TICK_TIMER_1 &htim3 // Special encoder timer which externally reads quadrature encoder ticks -// #define QUADRATURE_TIMER_2 &htim4 +#define MOTION_PROFILE_TIMER &htim4 // Mesasures time since last motion profile update #define QUADRATURE_ELAPSED_TIMER_1 &htim17 // Measures time since the lsat quadrature tick reading #define ABSOLUTE_ENCODER_TIMER &htim2 // 20 Hz repeating timer to kick off I2C transactions with the absolute encoder #define THROTTLE_LIMIT_TIMER &htim6 // Measures time since the last throttle command @@ -53,11 +54,11 @@ namespace mrover { Pin{GPIOC, GPIO_PIN_6}, fdcan_bus, FDCAN_WATCHDOG_TIMER, - MOTION_PROFILE_TIMER, QUADRATURE_TICK_TIMER_1, QUADRATURE_ELAPSED_TIMER_1, THROTTLE_LIMIT_TIMER, PIDF_TIMER, + MOTION_PROFILE_TIMER, ABSOLUTE_I2C, { LimitSwitch{Pin{LIMIT_0_0_GPIO_Port, LIMIT_0_0_Pin}}, diff --git a/src/esw/fw/bdcmc/Core/Src/main.c b/src/esw/fw/bdcmc/Core/Src/main.c index 2b17a80ae..cbd8bd1d3 100644 --- a/src/esw/fw/bdcmc/Core/Src/main.c +++ b/src/esw/fw/bdcmc/Core/Src/main.c @@ -49,6 +49,7 @@ DMA_HandleTypeDef hdma_i2c1_tx; TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim3; +TIM_HandleTypeDef htim4; TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim7; TIM_HandleTypeDef htim8; @@ -74,6 +75,7 @@ static void MX_TIM2_Init(void); static void MX_TIM17_Init(void); static void MX_TIM6_Init(void); static void MX_TIM8_Init(void); +static void MX_TIM4_Init(void); /* USER CODE BEGIN PFP */ void HAL_PostInit(); /* USER CODE END PFP */ @@ -151,6 +153,7 @@ int main(void) MX_TIM17_Init(); MX_TIM6_Init(); MX_TIM8_Init(); + MX_TIM4_Init(); /* USER CODE BEGIN 2 */ HAL_PostInit(); @@ -399,6 +402,51 @@ static void MX_TIM3_Init(void) } +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_ClockConfigTypeDef sClockSourceConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 7; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 17500; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_Base_Init(&htim4) != HAL_OK) + { + Error_Handler(); + } + sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; + if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + +} + /** * @brief TIM6 Initialization Function * @param None diff --git a/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c b/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c index 1ebcf1654..ce5687a0a 100644 --- a/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c +++ b/src/esw/fw/bdcmc/Core/Src/stm32g4xx_hal_msp.c @@ -318,6 +318,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM2_MspInit 1 */ } + else if(htim_base->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } else if(htim_base->Instance==TIM6) { /* USER CODE BEGIN TIM6_MspInit 0 */ @@ -494,6 +505,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM2_MspDeInit 1 */ } + else if(htim_base->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } else if(htim_base->Instance==TIM6) { /* USER CODE BEGIN TIM6_MspDeInit 0 */ diff --git a/src/esw/fw/bdcmc/bdcmc.ioc b/src/esw/fw/bdcmc/bdcmc.ioc index cc4874ff7..8387b3759 100644 --- a/src/esw/fw/bdcmc/bdcmc.ioc +++ b/src/esw/fw/bdcmc/bdcmc.ioc @@ -63,19 +63,20 @@ Mcu.CPN=STM32G431CBU3 Mcu.Family=STM32G4 Mcu.IP0=DMA Mcu.IP1=FDCAN1 -Mcu.IP10=TIM8 -Mcu.IP11=TIM15 -Mcu.IP12=TIM16 -Mcu.IP13=TIM17 +Mcu.IP10=TIM7 +Mcu.IP11=TIM8 +Mcu.IP12=TIM15 +Mcu.IP13=TIM16 +Mcu.IP14=TIM17 Mcu.IP2=I2C1 Mcu.IP3=NVIC Mcu.IP4=RCC Mcu.IP5=SYS Mcu.IP6=TIM2 Mcu.IP7=TIM3 -Mcu.IP8=TIM6 -Mcu.IP9=TIM7 -Mcu.IPNb=14 +Mcu.IP8=TIM4 +Mcu.IP9=TIM6 +Mcu.IPNb=15 Mcu.Name=STM32G431C(6-8-B)Ux Mcu.Package=UFQFPN48 Mcu.Pin0=PC13 @@ -97,20 +98,21 @@ Mcu.Pin22=PB9 Mcu.Pin23=VP_SYS_VS_Systick Mcu.Pin24=VP_SYS_VS_DBSignals Mcu.Pin25=VP_TIM2_VS_ClockSourceINT -Mcu.Pin26=VP_TIM6_VS_ClockSourceINT -Mcu.Pin27=VP_TIM7_VS_ClockSourceINT -Mcu.Pin28=VP_TIM8_VS_ClockSourceINT -Mcu.Pin29=VP_TIM16_VS_ClockSourceINT +Mcu.Pin26=VP_TIM4_VS_ClockSourceINT +Mcu.Pin27=VP_TIM6_VS_ClockSourceINT +Mcu.Pin28=VP_TIM7_VS_ClockSourceINT +Mcu.Pin29=VP_TIM8_VS_ClockSourceINT Mcu.Pin3=PF0-OSC_IN -Mcu.Pin30=VP_TIM17_VS_ClockSourceINT -Mcu.Pin31=VP_TIM17_VS_no_output1 +Mcu.Pin30=VP_TIM16_VS_ClockSourceINT +Mcu.Pin31=VP_TIM17_VS_ClockSourceINT +Mcu.Pin32=VP_TIM17_VS_no_output1 Mcu.Pin4=PA1 Mcu.Pin5=PA2 Mcu.Pin6=PA3 Mcu.Pin7=PA4 Mcu.Pin8=PA6 Mcu.Pin9=PC4 -Mcu.PinsNb=32 +Mcu.PinsNb=33 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32G431CBUx @@ -332,6 +334,9 @@ TIM2.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM2.IPParameters=Prescaler,PeriodNoDither,AutoReloadPreload TIM2.PeriodNoDither=58333 TIM2.Prescaler=119 +TIM4.IPParameters=Prescaler,PeriodNoDither +TIM4.PeriodNoDither=17500 +TIM4.Prescaler=7 TIM7.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM7.IPParameters=AutoReloadPreload,PeriodNoDither,Prescaler TIM7.PeriodNoDither=49999 @@ -348,6 +353,8 @@ VP_TIM17_VS_no_output1.Mode=Output Compare1 No Output VP_TIM17_VS_no_output1.Signal=TIM17_VS_no_output1 VP_TIM2_VS_ClockSourceINT.Mode=Internal VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT +VP_TIM4_VS_ClockSourceINT.Mode=Internal +VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer @@ -355,4 +362,3 @@ VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT VP_TIM8_VS_ClockSourceINT.Mode=Internal VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT board=custom -isbadioc=false