mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 09:41:36 +08:00
control_allocator: add rover actuator effectiveness
This can be generalized later
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ActuatorEffectivenessRoverAckermann.hpp"
|
||||||
|
#include <ControlAllocation/ControlAllocation.hpp>
|
||||||
|
|
||||||
|
using namespace matrix;
|
||||||
|
|
||||||
|
bool
|
||||||
|
ActuatorEffectivenessRoverAckermann::getEffectivenessMatrix(Configuration &configuration, bool force)
|
||||||
|
{
|
||||||
|
if (!force) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration.addActuator(ActuatorType::MOTORS, Vector3f{}, Vector3f{1.f, 0.f, 0.f});
|
||||||
|
configuration.addActuator(ActuatorType::SERVOS, Vector3f{0.f, 0.f, 1.f}, Vector3f{});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ActuatorEffectiveness.hpp"
|
||||||
|
|
||||||
|
class ActuatorEffectivenessRoverAckermann : public ActuatorEffectiveness
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActuatorEffectivenessRoverAckermann() = default;
|
||||||
|
virtual ~ActuatorEffectivenessRoverAckermann() = default;
|
||||||
|
|
||||||
|
bool getEffectivenessMatrix(Configuration &configuration, bool force) override;
|
||||||
|
|
||||||
|
const char *name() const override { return "Rover (Ackermann)"; }
|
||||||
|
private:
|
||||||
|
};
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ActuatorEffectivenessRoverDifferential.hpp"
|
||||||
|
#include <ControlAllocation/ControlAllocation.hpp>
|
||||||
|
|
||||||
|
using namespace matrix;
|
||||||
|
|
||||||
|
bool
|
||||||
|
ActuatorEffectivenessRoverDifferential::getEffectivenessMatrix(Configuration &configuration, bool force)
|
||||||
|
{
|
||||||
|
if (!force) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration.addActuator(ActuatorType::MOTORS, Vector3f{0.f, 0.f, 0.5f}, Vector3f{0.5f, 0.f, 0.f});
|
||||||
|
configuration.addActuator(ActuatorType::MOTORS, Vector3f{0.f, 0.f, -0.5f}, Vector3f{0.5f, 0.f, 0.f});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ActuatorEffectiveness.hpp"
|
||||||
|
|
||||||
|
class ActuatorEffectivenessRoverDifferential: public ActuatorEffectiveness
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActuatorEffectivenessRoverDifferential() = default;
|
||||||
|
virtual ~ActuatorEffectivenessRoverDifferential() = default;
|
||||||
|
|
||||||
|
bool getEffectivenessMatrix(Configuration &configuration, bool force) override;
|
||||||
|
|
||||||
|
const char *name() const override { return "Rover (Differential)"; }
|
||||||
|
private:
|
||||||
|
};
|
||||||
@@ -44,6 +44,10 @@ px4_add_library(ActuatorEffectiveness
|
|||||||
ActuatorEffectivenessStandardVTOL.hpp
|
ActuatorEffectivenessStandardVTOL.hpp
|
||||||
ActuatorEffectivenessTiltrotorVTOL.cpp
|
ActuatorEffectivenessTiltrotorVTOL.cpp
|
||||||
ActuatorEffectivenessTiltrotorVTOL.hpp
|
ActuatorEffectivenessTiltrotorVTOL.hpp
|
||||||
|
ActuatorEffectivenessRoverAckermann.hpp
|
||||||
|
ActuatorEffectivenessRoverAckermann.cpp
|
||||||
|
ActuatorEffectivenessRoverDifferential.hpp
|
||||||
|
ActuatorEffectivenessRoverDifferential.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(ActuatorEffectiveness PRIVATE ${MAX_CUSTOM_OPT_LEVEL})
|
target_compile_options(ActuatorEffectiveness PRIVATE ${MAX_CUSTOM_OPT_LEVEL})
|
||||||
|
|||||||
@@ -191,6 +191,14 @@ ControlAllocator::update_effectiveness_source()
|
|||||||
tmp = new ActuatorEffectivenessTiltrotorVTOL(this);
|
tmp = new ActuatorEffectivenessTiltrotorVTOL(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EffectivenessSource::ROVER_ACKERMANN:
|
||||||
|
tmp = new ActuatorEffectivenessRoverAckermann();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectivenessSource::ROVER_DIFFERENTIAL:
|
||||||
|
tmp = new ActuatorEffectivenessRoverDifferential();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PX4_ERR("Unknown airframe");
|
PX4_ERR("Unknown airframe");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <ActuatorEffectivenessRotors.hpp>
|
#include <ActuatorEffectivenessRotors.hpp>
|
||||||
#include <ActuatorEffectivenessStandardVTOL.hpp>
|
#include <ActuatorEffectivenessStandardVTOL.hpp>
|
||||||
#include <ActuatorEffectivenessTiltrotorVTOL.hpp>
|
#include <ActuatorEffectivenessTiltrotorVTOL.hpp>
|
||||||
|
#include <ActuatorEffectivenessRoverAckermann.hpp>
|
||||||
|
#include <ActuatorEffectivenessRoverDifferential.hpp>
|
||||||
|
|
||||||
#include <ControlAllocation.hpp>
|
#include <ControlAllocation.hpp>
|
||||||
#include <ControlAllocationPseudoInverse.hpp>
|
#include <ControlAllocationPseudoInverse.hpp>
|
||||||
@@ -121,6 +123,8 @@ private:
|
|||||||
MULTIROTOR = 0,
|
MULTIROTOR = 0,
|
||||||
STANDARD_VTOL = 1,
|
STANDARD_VTOL = 1,
|
||||||
TILTROTOR_VTOL = 2,
|
TILTROTOR_VTOL = 2,
|
||||||
|
ROVER_ACKERMANN = 3,
|
||||||
|
ROVER_DIFFERENTIAL = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
EffectivenessSource _effectiveness_source_id{EffectivenessSource::NONE};
|
EffectivenessSource _effectiveness_source_id{EffectivenessSource::NONE};
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ parameters:
|
|||||||
0: Multirotor
|
0: Multirotor
|
||||||
1: Standard VTOL (WIP)
|
1: Standard VTOL (WIP)
|
||||||
2: Tiltrotor VTOL (WIP)
|
2: Tiltrotor VTOL (WIP)
|
||||||
|
3: Rover (Ackermann)
|
||||||
|
4: Rover (Differential)
|
||||||
default: 0
|
default: 0
|
||||||
|
|
||||||
CA_METHOD:
|
CA_METHOD:
|
||||||
@@ -470,5 +472,25 @@ mixer:
|
|||||||
- name: 'CA_SV_TL${i}_CT'
|
- name: 'CA_SV_TL${i}_CT'
|
||||||
label: 'Use for Control'
|
label: 'Use for Control'
|
||||||
|
|
||||||
|
3: # Rover (Ackermann)
|
||||||
|
actuators:
|
||||||
|
- actuator_type: 'motor'
|
||||||
|
instances:
|
||||||
|
- name: 'Throttle'
|
||||||
|
position: [ -1., 0, 0 ]
|
||||||
|
- actuator_type: 'servo'
|
||||||
|
instances:
|
||||||
|
- name: 'Steering'
|
||||||
|
position: [ 1., 0, 0 ]
|
||||||
|
|
||||||
|
4: # Rover (Differential)
|
||||||
|
actuators:
|
||||||
|
- actuator_type: 'motor'
|
||||||
|
instances:
|
||||||
|
- name: 'Left Motor'
|
||||||
|
position: [ 0, -1., 0 ]
|
||||||
|
- name: 'Right Motor'
|
||||||
|
position: [ 0, 1., 0 ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user