Move gimbal flight mode manager utility to library

This commit is contained in:
Pernilla
2025-02-03 17:44:41 +01:00
parent babea4bffa
commit fe4e3ffe00
5 changed files with 62 additions and 5 deletions
+1
View File
@@ -52,6 +52,7 @@ add_subdirectory(dataman_client EXCLUDE_FROM_ALL)
add_subdirectory(drivers EXCLUDE_FROM_ALL)
add_subdirectory(field_sensor_bias_estimator EXCLUDE_FROM_ALL)
add_subdirectory(geo EXCLUDE_FROM_ALL)
add_subdirectory(gimbal_control EXCLUDE_FROM_ALL)
add_subdirectory(heatshrink EXCLUDE_FROM_ALL)
add_subdirectory(hysteresis EXCLUDE_FROM_ALL)
add_subdirectory(l1 EXCLUDE_FROM_ALL)
+34
View File
@@ -0,0 +1,34 @@
############################################################################
#
# Copyright (c) 2025 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.
#
############################################################################
px4_add_library(gimbal_control Gimbal.cpp)
@@ -124,3 +124,15 @@ void Gimbal::publishGimbalManagerSetAttitude(const uint16_t gimbal_flags,
gimbal_setpoint.timestamp = hrt_absolute_time();
_gimbal_manager_set_attitude_pub.publish(gimbal_setpoint);
}
void Gimbal::setNeutral()
{
vehicle_command_s vehicle_command = {};
vehicle_command.command = vehicle_command_s::VEHICLE_CMD_DO_GIMBAL_MANAGER_PITCHYAW;
vehicle_command.param1 = NAN;
vehicle_command.param2 = NAN;
vehicle_command.param3 = NAN;
vehicle_command.param4 = NAN;
vehicle_command.param5 = gimbal_manager_set_attitude_s::GIMBAL_MANAGER_FLAGS_NEUTRAL;
_vehicle_command_pub.publish(vehicle_command);
}
@@ -33,7 +33,7 @@
/**
* @file Gimbal.hpp
* @brief Gimbal interface with flight tasks
* @brief Gimbal library to interface with other units
* @author Pernilla Wikström <pernilla@auterion.com>
*/
@@ -47,9 +47,9 @@
#include <uORB/topics/gimbal_device_attitude_status.h>
#include <uORB/topics/vehicle_command.h>
#include "Sticks.hpp"
/**
* Fore more information on gimbal v2, see https://mavlink.io/en/services/gimbal_v2.html
**/
class Gimbal : public ModuleParams
{
public:
@@ -60,8 +60,19 @@ public:
void publishGimbalManagerSetAttitude(const uint16_t gimbal_flags,
const matrix::Quatf &q_gimbal_setpoint,
const matrix::Vector3f &gimbal_rates);
/**
* Acquire Gimbal Control Authority to restrict other modules / Ground station
* to control the gimbal until the gimbal is released.
*/
void acquireGimbalControlIfNeeded();
/**
* Releases Gimbal Control Authority, to allow other modules / Ground station
* to control the gimbal.
*/
void releaseGimbalControlIfNeeded();
void setNeutral();
float getTelemetryYaw() { return _telemetry_yaw; }
bool allAxesLockedConfirmed() { return _telemetry_flags == FLAGS_ALL_AXES_LOCKED; }
@@ -36,7 +36,6 @@ px4_add_library(FlightTaskUtility
StickAccelerationXY.cpp
StickTiltXY.cpp
StickYaw.cpp
Gimbal.cpp
)
target_link_libraries(FlightTaskUtility PUBLIC FlightTask hysteresis bezier SlewRate motion_planning mathlib)