mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:23:33 +08:00
[uxrce_dds_client] add services (repliers) and basic VehicleCommand service
Signed-off-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
This commit is contained in:
committed by
Daniel Agar
parent
4555c4e5cc
commit
58d2badf9f
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2022 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2022-2023 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
|
||||
@@ -40,6 +40,10 @@
|
||||
|
||||
#include <lib/timesync/Timesync.hpp>
|
||||
|
||||
#include "srv_base.h"
|
||||
|
||||
#define MAX_NUM_REPLIERS 5
|
||||
|
||||
class UxrceddsClient : public ModuleBase<UxrceddsClient>, public ModuleParams
|
||||
{
|
||||
public:
|
||||
@@ -71,6 +75,34 @@ public:
|
||||
/** @see ModuleBase::print_status() */
|
||||
int print_status() override;
|
||||
|
||||
/**
|
||||
* @brief Method to add a new replyer to the replier array.
|
||||
* @param replier pointer to the new replier.
|
||||
* @return Returns false iff successful, otherwise false.
|
||||
*/
|
||||
bool add_replier(SrvBase *replier);
|
||||
|
||||
/**
|
||||
* @brief Method to process new incoming requests and dispatch them to the appropriate server.
|
||||
* @param object_id replier object id
|
||||
* @param sample_id pointer to specific request.
|
||||
* @param time_offset_us time offset between agent and client.
|
||||
* @param ub pointer to the received request data
|
||||
*/
|
||||
void process_requests(uxrObjectId object_id, SampleIdentity *sample_id, ucdrBuffer *ub, const int64_t time_offset_us);
|
||||
|
||||
/**
|
||||
* @brief Method to process the available replies.
|
||||
* @return Returns false iff successful, otherwise false.
|
||||
*/
|
||||
void process_replies();
|
||||
|
||||
/**
|
||||
* @brief Method to delete all repliers.
|
||||
* @return Returns false iff successful, otherwise false.
|
||||
*/
|
||||
void delete_repliers();
|
||||
|
||||
private:
|
||||
int setBaudrate(int fd, unsigned baud);
|
||||
|
||||
@@ -79,7 +111,6 @@ private:
|
||||
const char *_client_namespace;
|
||||
const bool _synchronize_timestamps;
|
||||
|
||||
|
||||
// max port characters (5+'\0')
|
||||
static const uint8_t PORT_MAX_LENGTH = 6;
|
||||
// max agent ip characters (15+'\0')
|
||||
@@ -93,6 +124,9 @@ private:
|
||||
SendTopicsSubs *_subs{nullptr};
|
||||
RcvTopicsPubs *_pubs{nullptr};
|
||||
|
||||
SrvBase *repliers_[MAX_NUM_REPLIERS];
|
||||
uint8_t num_of_repliers{0};
|
||||
|
||||
uxrSerialTransport *_transport_serial{nullptr};
|
||||
uxrUDPTransport *_transport_udp{nullptr};
|
||||
uxrCommunication *_comm{nullptr};
|
||||
|
||||
Reference in New Issue
Block a user