Browse Source
Set uavcan publisher priorities Switch to ardupilot rtcm message and add heading accuracymaster
alexklimaj
3 years ago
committed by
Daniel Agar
23 changed files with 328 additions and 66 deletions
@ -1,6 +1,9 @@
@@ -1,6 +1,9 @@
|
||||
uint64 timestamp # time since system start (microseconds) |
||||
|
||||
uint32 device_id # unique device ID for the sensor that does not change between power cycles |
||||
|
||||
uint8 len # length of data |
||||
uint8 flags # LSB: 1=fragmented |
||||
uint8[182] data # data to write to GPS device (RTCM message) |
||||
uint8[300] data # data to write to GPS device (RTCM message) |
||||
|
||||
uint8 ORB_QUEUE_LENGTH = 8 |
||||
|
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 6fcf06894973240d45dc49d3b31565917dc8f2f6 |
||||
Subproject commit bd72eb6794e8fb4f2ed3e47311a14c2cec69f60b |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* 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 "UavcanPublisherBase.hpp" |
||||
|
||||
#include <ardupilot/gnss/MovingBaselineData.hpp> |
||||
|
||||
#include <uORB/SubscriptionCallback.hpp> |
||||
#include <uORB/topics/gps_inject_data.h> |
||||
|
||||
namespace uavcannode |
||||
{ |
||||
|
||||
class MovingBaselineDataPub : |
||||
public UavcanPublisherBase, |
||||
public uORB::SubscriptionCallbackWorkItem, |
||||
private uavcan::Publisher<ardupilot::gnss::MovingBaselineData> |
||||
{ |
||||
public: |
||||
MovingBaselineDataPub(px4::WorkItem *work_item, uavcan::INode &node) : |
||||
UavcanPublisherBase(ardupilot::gnss::MovingBaselineData::DefaultDataTypeID), |
||||
uORB::SubscriptionCallbackWorkItem(work_item, ORB_ID(gps_inject_data)), |
||||
uavcan::Publisher<ardupilot::gnss::MovingBaselineData>(node) |
||||
{ |
||||
this->setPriority(uavcan::TransferPriority::NumericallyMax); |
||||
} |
||||
|
||||
void PrintInfo() override |
||||
{ |
||||
if (uORB::SubscriptionCallbackWorkItem::advertised()) { |
||||
printf("\t%s -> %s:%d\n", |
||||
uORB::SubscriptionCallbackWorkItem::get_topic()->o_name, |
||||
ardupilot::gnss::MovingBaselineData::getDataTypeFullName(), |
||||
id()); |
||||
} |
||||
} |
||||
|
||||
void BroadcastAnyUpdates() override |
||||
{ |
||||
using ardupilot::gnss::MovingBaselineData; |
||||
|
||||
// gps_inject_data -> ardupilot::gnss::MovingBaselineData
|
||||
gps_inject_data_s inject_data; |
||||
|
||||
if (uORB::SubscriptionCallbackWorkItem::update(&inject_data)) { |
||||
// Prevent republishing rtcm data we received from uavcan
|
||||
if (inject_data.device_id > uavcan::NodeID::Max) { |
||||
ardupilot::gnss::MovingBaselineData movingbaselinedata{}; |
||||
|
||||
const size_t capacity = movingbaselinedata.data.capacity(); |
||||
size_t written = 0; |
||||
int result = 0; |
||||
|
||||
while ((result >= 0) && written < inject_data.len) { |
||||
size_t chunk_size = inject_data.len - written; |
||||
|
||||
if (chunk_size > capacity) { |
||||
chunk_size = capacity; |
||||
} |
||||
|
||||
for (size_t i = 0; i < chunk_size; ++i) { |
||||
movingbaselinedata.data.push_back(inject_data.data[written]); |
||||
written += 1; |
||||
} |
||||
|
||||
result = uavcan::Publisher<ardupilot::gnss::MovingBaselineData>::broadcast(movingbaselinedata); |
||||
|
||||
// ensure callback is registered
|
||||
uORB::SubscriptionCallbackWorkItem::registerCallback(); |
||||
|
||||
movingbaselinedata.data.clear(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} // namespace uavcannode
|
Loading…
Reference in new issue