From 2cda9059a655e672d826787847f7fd6dd6fb58e6 Mon Sep 17 00:00:00 2001 From: Pedro-Roque Date: Tue, 28 Jan 2025 23:59:33 +0100 Subject: [PATCH] fix: removed unnecessary files and vscode extras --- .vscode/settings.json | 1 - .../control_allocation/CMakeLists.txt | 3 - .../ControlAllocationMetric.cpp | 81 ------------------- .../ControlAllocationMetric.hpp | 74 ----------------- .../ControlAllocationMetricTest.cpp | 70 ---------------- 5 files changed, 229 deletions(-) delete mode 100644 src/lib/control_allocation/control_allocation/ControlAllocationMetric.cpp delete mode 100644 src/lib/control_allocation/control_allocation/ControlAllocationMetric.hpp delete mode 100644 src/lib/control_allocation/control_allocation/ControlAllocationMetricTest.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json index 0192c81e86..1e799721ce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -129,5 +129,4 @@ "yaml.schemas": { "${workspaceFolder}/validation/module_schema.yaml": "${workspaceFolder}/src/modules/*/module.yaml" }, - "ros.distro": "humble" } diff --git a/src/lib/control_allocation/control_allocation/CMakeLists.txt b/src/lib/control_allocation/control_allocation/CMakeLists.txt index d78e23c770..d65bd11fa0 100644 --- a/src/lib/control_allocation/control_allocation/CMakeLists.txt +++ b/src/lib/control_allocation/control_allocation/CMakeLists.txt @@ -34,8 +34,6 @@ px4_add_library(ControlAllocation ControlAllocation.cpp ControlAllocation.hpp - ControlAllocationMetric.cpp - ControlAllocationMetric.hpp ControlAllocationPseudoInverse.cpp ControlAllocationPseudoInverse.hpp ControlAllocationSequentialDesaturation.cpp @@ -46,5 +44,4 @@ target_include_directories(ControlAllocation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(ControlAllocation PRIVATE mathlib) px4_add_unit_gtest(SRC ControlAllocationPseudoInverseTest.cpp LINKLIBS ControlAllocation) -px4_add_unit_gtest(SRC ControlAllocationMetricTest.cpp LINKLIBS ControlAllocation) # px4_add_functional_gtest(SRC ControlAllocationSequentialDesaturationTest.cpp LINKLIBS ControlAllocation ActuatorEffectiveness) diff --git a/src/lib/control_allocation/control_allocation/ControlAllocationMetric.cpp b/src/lib/control_allocation/control_allocation/ControlAllocationMetric.cpp deleted file mode 100644 index 888e1337fe..0000000000 --- a/src/lib/control_allocation/control_allocation/ControlAllocationMetric.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2024 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file ControlAllocationMetric.hpp - * - * Control allocation with metric units. - * - * @author Pedro Roque - */ - -#include "ControlAllocationMetric.hpp" -#include - -/* - * ControlAllocationMetric - * - * Note that the effectiveness matrix is in metric units and that - * 'update_normalization_scale' is ignored. - */ -void -ControlAllocationMetric::setEffectivenessMatrix( - const matrix::Matrix &effectiveness, - const ActuatorVector &actuator_trim, const ActuatorVector &linearization_point, int num_actuators, - bool update_normalization_scale) -{ - ControlAllocation::setEffectivenessMatrix(effectiveness, actuator_trim, linearization_point, num_actuators, - false); - _mix_update_needed = true; -} - -void -ControlAllocationMetric::updatePseudoInverse() -{ - if (_mix_update_needed) { - matrix::geninv(_effectiveness, _mix); - _mix_update_needed = false; - } -} - -void -ControlAllocationMetric::allocate() -{ - //Compute new gains if needed - updatePseudoInverse(); - - _prev_actuator_sp = _actuator_sp; - - // Allocate - _actuator_sp = _actuator_trim + _mix * (_control_sp - _control_trim); -} diff --git a/src/lib/control_allocation/control_allocation/ControlAllocationMetric.hpp b/src/lib/control_allocation/control_allocation/ControlAllocationMetric.hpp deleted file mode 100644 index 19d82e1bf0..0000000000 --- a/src/lib/control_allocation/control_allocation/ControlAllocationMetric.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2024 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file ControlAllocationMetric.hpp - * - * Control allocation with metric units. - * - * The metric allocation takes into account maximum thrust and torque - * provided by the actuators to calculate setpoints that allow to allocate - * specific body force and torque, keeping the scale of the target setpoints. - * No normalization is done in this case. Note that, similarly to the PseudoInverse - * allocation, saturation is handled by clipping. - * - * @author Pedro Roque - */ - -#pragma once - -#include "ControlAllocation.hpp" - -class ControlAllocationMetric: public ControlAllocation -{ -public: - ControlAllocationMetric() = default; - virtual ~ControlAllocationMetric() = default; - - void allocate() override; - void setEffectivenessMatrix(const matrix::Matrix &effectiveness, - const ActuatorVector &actuator_trim, const ActuatorVector &linearization_point, int num_actuators, - bool update_normalization_scale) override; - -protected: - matrix::Matrix _mix; - - bool _mix_update_needed{false}; - - /** - * Recalculate pseudo inverse if required. - * - */ - void updatePseudoInverse(); - -}; diff --git a/src/lib/control_allocation/control_allocation/ControlAllocationMetricTest.cpp b/src/lib/control_allocation/control_allocation/ControlAllocationMetricTest.cpp deleted file mode 100644 index cd9fa2ff93..0000000000 --- a/src/lib/control_allocation/control_allocation/ControlAllocationMetricTest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2024 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file ControlAllocationTest.cpp - * - * Tests for Control Allocation metric class - * - * @author Pedro Roque - */ - -#include -#include "ControlAllocationMetric.hpp" -#include - -using namespace matrix; - -TEST(ControlAllocationMetricTest, AllZeroCase) -{ - ControlAllocationMetric method; - - matrix::Vector control_sp; - matrix::Vector control_allocated; - matrix::Vector control_allocated_expected; - matrix::Matrix effectiveness; - matrix::Vector actuator_sp; - matrix::Vector actuator_trim; - matrix::Vector linearization_point; - matrix::Vector actuator_sp_expected; - - method.setEffectivenessMatrix(effectiveness, actuator_trim, linearization_point, 16, false); - method.setControlSetpoint(control_sp); - method.allocate(); - method.clipActuatorSetpoint(); - actuator_sp = method.getActuatorSetpoint(); - control_allocated_expected = method.getAllocatedControl(); - - EXPECT_EQ(actuator_sp, actuator_sp_expected); - EXPECT_EQ(control_allocated, control_allocated_expected); -}