QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FemtoPlan.cc
Go to the documentation of this file.
1#include "Femto/FemtoPlan.h"
2
3#include <QtCore/QByteArrayView>
4
5#include "GPSProtocolMath.h"
6#include "GPSReceiverConfig.h"
7
8namespace Femto::Plan {
9
10namespace {
11
12GPSCommandSequence::RawReply reply(std::string_view accepted)
13{
14 return {QByteArrayView(accepted).toByteArray(), QByteArrayView(REJECTED).toByteArray()};
15}
16
17GPSCommandSequence::Command command(const Command& entry)
18{
19 return gpsCommand(QByteArrayView(entry.line).toByteArray(), RESPONSE_TIMEOUT, reply(entry.accepted));
20}
21
22} // namespace
23
24GPSCommandSequence sequence(std::span<const Command> commands)
25{
26 GPSCommandSequence result;
27 for (const Command& entry : commands) {
28 result.steps.emplace_back(command(entry));
29 }
30 return result;
31}
32
34{
35 const QByteArray line = "FIX POSITION " + gpsFixedDecimal(position.latitudeDegrees, 8) + ' ' +
36 gpsFixedDecimal(position.longitudeDegrees, 8) + ' ' +
37 gpsFixedDecimal(position.altitudeMeters, 5) + "\r\n";
38 return {
39 {command(ELLIPSOID_HEIGHTS),
40 gpsCommand(line, RESPONSE_TIMEOUT, reply(FIX_POSITION_ACCEPTED), {.label = "FIX POSITION (fixed position)"}),
41 command(GGA_OUTPUT)}};
42}
43
44} // namespace Femto::Plan
GPSCommandSequence::Command gpsCommand(QByteArray wire, std::chrono::milliseconds timeout, std::variant< GPSTextMatcher, GPSCommandSequence::RawReply > reply, GPSCommandOptions options={})
Definition GPSCommand.h:162
QByteArray gpsFixedDecimal(double value, int decimals)
constexpr std::string_view REJECTED
Definition FemtoPlan.h:26
constexpr std::string_view FIX_POSITION_ACCEPTED
Definition FemtoPlan.h:59
GPSCommandSequence sequence(std::span< const Command > commands)
Definition FemtoPlan.cc:24
constexpr Command GGA_OUTPUT
GGA output; the base station uses it only to observe the survey-in.
Definition FemtoPlan.h:43
GPSCommandSequence fixedBase(const GPSEllipsoidPosition &position)
ELLIPSOID_HEIGHTS, FIX_POSITION for position, then GGA_OUTPUT.
Definition FemtoPlan.cc:33
constexpr Command ELLIPSOID_HEIGHTS
Definition FemtoPlan.h:55
constexpr std::chrono::milliseconds RESPONSE_TIMEOUT
Per attempt, for every command.
Definition FemtoPlan.h:25
Matched in the raw received bytes, for replies that need not be complete frames (see GPSRawAckMatcher...
Definition GPSCommand.h:125
std::vector< Command > steps
Definition GPSCommand.h:150
WGS84 geodetic position with ellipsoid height, not mean-sea-level altitude.