mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 15:03:34 +08:00
FixedwingPositionControl: Add support for figure 8 loitering.
The command is sent by a dedicated mavlink command and forwarded to the fixed wing position controller. The pattern is defined by the radius of the major axis, the radius of the minor axis and the orientation. The pattern is then defined by: The upper part of the pattern consist of a clockwise circle with radius defined by the minor axis. The center of the circle is defined by the major axis minus the minor axis away from the pattern center. The lower part of the pattern consist of a counter-clockwise circle with the same definitions as above. In between, the circles are connected with straight lines in a cross configuration. The lines are always tangetial to the circles. The orientation rotates the major axis around the NED down axis. The loitering logic is defined inside its own class used by the fixed wing position control module. It defines which segment (one of the circles or lines) is active and uses the path controller (npfg or l1-control) to determine the desired roll angle. A feedback mavlink message is send with the executed pattern parameters.
This commit is contained in:
@@ -1444,6 +1444,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("DEBUG_VECT", 1.0f);
|
||||
configure_stream_local("NAMED_VALUE_FLOAT", 1.0f);
|
||||
configure_stream_local("LINK_NODE_STATUS", 1.0f);
|
||||
configure_stream_local("FIGURE_EIGHT_EXECUTION_STATUS", 5.0f);
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
|
||||
break;
|
||||
@@ -1509,6 +1510,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("DEBUG_VECT", 10.0f);
|
||||
configure_stream_local("NAMED_VALUE_FLOAT", 10.0f);
|
||||
configure_stream_local("LINK_NODE_STATUS", 1.0f);
|
||||
configure_stream_local("FIGURE_EIGHT_EXECUTION_STATUS", 5.0f);
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
|
||||
break;
|
||||
@@ -1570,6 +1572,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("DEBUG_VECT", 1.0f);
|
||||
configure_stream_local("NAMED_VALUE_FLOAT", 1.0f);
|
||||
configure_stream_local("LINK_NODE_STATUS", 1.0f);
|
||||
configure_stream_local("FIGURE_EIGHT_EXECUTION_STATUS", 2.0f);
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
|
||||
break;
|
||||
@@ -1663,6 +1666,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("DEBUG_VECT", 50.0f);
|
||||
configure_stream_local("NAMED_VALUE_FLOAT", 50.0f);
|
||||
configure_stream_local("LINK_NODE_STATUS", 1.0f);
|
||||
configure_stream_local("FIGURE_EIGHT_EXECUTION_STATUS", 5.0f);
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
|
||||
break;
|
||||
@@ -1740,6 +1744,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("DEBUG_FLOAT_ARRAY", 1.0f);
|
||||
configure_stream_local("DEBUG_VECT", 1.0f);
|
||||
configure_stream_local("NAMED_VALUE_FLOAT", 1.0f);
|
||||
configure_stream_local("FIGURE_EIGHT_EXECUTION_STATUS", 5.0f);
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
break;
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
#include "streams/VFR_HUD.hpp"
|
||||
#include "streams/VIBRATION.hpp"
|
||||
#include "streams/WIND_COV.hpp"
|
||||
#include "streams/FIGURE_EIGHT_EXECUTION_STATUS.hpp"
|
||||
|
||||
#if !defined(CONSTRAINED_FLASH)
|
||||
# include "streams/ADSB_VEHICLE.hpp"
|
||||
@@ -431,6 +432,9 @@ static const StreamListItem streams_list[] = {
|
||||
#if defined(ORBIT_EXECUTION_STATUS_HPP)
|
||||
create_stream_list_item<MavlinkStreamOrbitStatus>(),
|
||||
#endif // ORBIT_EXECUTION_STATUS_HPP
|
||||
#if defined(FIGURE_EIGHT_EXECUTION_STATUS_HPP)
|
||||
create_stream_list_item<MavlinkStreamFigureEightStatus>(),
|
||||
#endif // FIGURE_EIGHT_EXECUTION_STATUS_HPP
|
||||
#if defined(OBSTACLE_DISTANCE_HPP)
|
||||
create_stream_list_item<MavlinkStreamObstacleDistance>(),
|
||||
#endif // OBSTACLE_DISTANCE_HPP
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef FIGURE_EIGHT_EXECUTION_STATUS_HPP
|
||||
#define FIGURE_EIGHT_EXECUTION_STATUS_HPP
|
||||
|
||||
#include <uORB/topics/figure_eight_status.h>
|
||||
#include <mavlink.h>
|
||||
#include <mavlink/mavlink_stream.h>
|
||||
|
||||
class MavlinkStreamFigureEightStatus : public MavlinkStream
|
||||
{
|
||||
public:
|
||||
static MavlinkStream *new_instance(Mavlink *mavlink) { return new MavlinkStreamFigureEightStatus(mavlink); }
|
||||
|
||||
static constexpr const char *get_name_static() { return "FIGURE_EIGHT_EXECUTION_STATUS"; }
|
||||
static constexpr uint16_t get_id_static() { return MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS; }
|
||||
|
||||
const char *get_name() const override { return get_name_static(); }
|
||||
uint16_t get_id() override { return get_id_static(); }
|
||||
|
||||
unsigned get_size() override
|
||||
{
|
||||
return _figure_eight_status_subs.advertised() ? MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN +
|
||||
MAVLINK_NUM_NON_PAYLOAD_BYTES : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MavlinkStreamFigureEightStatus(Mavlink *mavlink) : MavlinkStream(mavlink) {}
|
||||
|
||||
uORB::Subscription _figure_eight_status_subs{ORB_ID::figure_eight_status};
|
||||
|
||||
bool send() override
|
||||
{
|
||||
figure_eight_status_s figure_eight_status;
|
||||
|
||||
if ((_mavlink->get_free_tx_buf() >= get_size()) && _figure_eight_status_subs.update(&figure_eight_status)) {
|
||||
mavlink_figure_eight_execution_status_t msg_figure_eight_execution_status{};
|
||||
|
||||
msg_figure_eight_execution_status.time_usec = figure_eight_status.timestamp;
|
||||
msg_figure_eight_execution_status.major_radius = figure_eight_status.major_radius;
|
||||
msg_figure_eight_execution_status.minor_radius = figure_eight_status.minor_radius;
|
||||
msg_figure_eight_execution_status.frame = figure_eight_status.frame;
|
||||
msg_figure_eight_execution_status.orientation = figure_eight_status.orientation;
|
||||
msg_figure_eight_execution_status.x = figure_eight_status.x;
|
||||
msg_figure_eight_execution_status.y = figure_eight_status.y;
|
||||
msg_figure_eight_execution_status.z = figure_eight_status.z;
|
||||
|
||||
mavlink_msg_figure_eight_execution_status_send_struct(_mavlink->get_channel(), &msg_figure_eight_execution_status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // FIGURE_EIGHT_EXECUTION_STATUS_HPP
|
||||
Reference in New Issue
Block a user