2023-03-12 23:18:29 -03:00
|
|
|
#pragma once
|
|
|
|
|
2024-03-05 07:22:24 -04:00
|
|
|
#include "AP_DDS_config.h"
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
#if AP_DDS_ENABLED
|
|
|
|
|
|
|
|
#include "uxr/client/client.h"
|
|
|
|
#include "ucdr/microcdr.h"
|
2023-12-07 02:49:01 -04:00
|
|
|
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_GLOBAL_POS_CTRL_ENABLED
|
2023-12-07 02:49:01 -04:00
|
|
|
#include "ardupilot_msgs/msg/GlobalPosition.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_GLOBAL_POS_CTRL_ENABLED
|
|
|
|
#if AP_DDS_TIME_PUB_ENABLED
|
2023-04-05 10:23:19 -03:00
|
|
|
#include "builtin_interfaces/msg/Time.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_TIME_PUB_ENABLED
|
|
|
|
#if AP_DDS_NAVSATFIX_PUB_ENABLED
|
2023-04-05 10:23:19 -03:00
|
|
|
#include "sensor_msgs/msg/NavSatFix.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_NAVSATFIX_PUB_ENABLED
|
|
|
|
#if AP_DDS_NEEDS_TRANSFORMS
|
2023-04-05 10:23:19 -03:00
|
|
|
#include "tf2_msgs/msg/TFMessage.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_NEEDS_TRANSFORMS
|
|
|
|
#if AP_DDS_BATTERY_STATE_PUB_ENABLED
|
2023-03-30 13:05:17 -03:00
|
|
|
#include "sensor_msgs/msg/BatteryState.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_BATTERY_STATE_PUB_ENABLED
|
2024-09-13 20:02:38 -03:00
|
|
|
#if AP_DDS_IMU_PUB_ENABLED
|
2024-02-20 13:58:48 -04:00
|
|
|
#include "sensor_msgs/msg/Imu.h"
|
2024-09-13 20:02:38 -03:00
|
|
|
#endif // AP_DDS_IMU_PUB_ENABLED
|
2024-10-29 12:06:50 -03:00
|
|
|
#if AP_DDS_STATUS_PUB_ENABLED
|
|
|
|
#include "ardupilot_msgs/msg/Status.h"
|
|
|
|
#endif // AP_DDS_STATUS_PUB_ENABLED
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_JOY_SUB_ENABLED
|
2023-05-21 20:50:51 -03:00
|
|
|
#include "sensor_msgs/msg/Joy.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_JOY_SUB_ENABLED
|
|
|
|
#if AP_DDS_LOCAL_POSE_PUB_ENABLED
|
2023-04-13 22:51:35 -03:00
|
|
|
#include "geometry_msgs/msg/PoseStamped.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_LOCAL_POSE_PUB_ENABLED
|
|
|
|
#if AP_DDS_NEEDS_TWIST
|
2023-04-18 17:52:39 -03:00
|
|
|
#include "geometry_msgs/msg/TwistStamped.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_NEEDS_TWIST
|
|
|
|
#if AP_DDS_GPS_GLOBAL_ORIGIN_PUB_ENABLED
|
2024-03-05 15:26:39 -04:00
|
|
|
#include "geographic_msgs/msg/GeoPointStamped.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_GPS_GLOBAL_ORIGIN_PUB_ENABLED
|
2024-10-08 12:58:31 -03:00
|
|
|
#if AP_DDS_AIRSPEED_PUB_ENABLED
|
|
|
|
#include "geometry_msgs/msg/Vector3Stamped.h"
|
|
|
|
#endif // AP_DDS_AIRSPEED_PUB_ENABLED
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_GEOPOSE_PUB_ENABLED
|
2023-04-18 14:23:03 -03:00
|
|
|
#include "geographic_msgs/msg/GeoPoseStamped.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_GEOPOSE_PUB_ENABLED
|
|
|
|
#if AP_DDS_CLOCK_PUB_ENABLED
|
2023-05-10 06:35:29 -03:00
|
|
|
#include "rosgraph_msgs/msg/Clock.h"
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_CLOCK_PUB_ENABLED
|
2024-10-03 16:57:57 -03:00
|
|
|
#if AP_DDS_PARAMETER_SERVER_ENABLED
|
|
|
|
#include "rcl_interfaces/srv/SetParameters.h"
|
|
|
|
#include "rcl_interfaces/msg/Parameter.h"
|
|
|
|
#include "rcl_interfaces/msg/SetParametersResult.h"
|
|
|
|
#include "rcl_interfaces/msg/ParameterValue.h"
|
|
|
|
#include "rcl_interfaces/msg/ParameterType.h"
|
|
|
|
#include "rcl_interfaces/srv/GetParameters.h"
|
|
|
|
#endif //AP_DDS_PARAMETER_SERVER_ENABLED
|
2023-03-12 23:18:29 -03:00
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#include <AP_HAL/Scheduler.h>
|
|
|
|
#include <AP_HAL/Semaphores.h>
|
|
|
|
|
|
|
|
#include "fcntl.h"
|
|
|
|
|
|
|
|
#include <AP_Param/AP_Param.h>
|
2023-04-24 02:13:32 -03:00
|
|
|
|
2023-07-18 17:20:03 -03:00
|
|
|
#define DDS_MTU 512
|
|
|
|
#define DDS_STREAM_HISTORY 8
|
|
|
|
#define DDS_BUFFER_SIZE DDS_MTU * DDS_STREAM_HISTORY
|
2023-04-24 02:13:32 -03:00
|
|
|
|
|
|
|
#if AP_DDS_UDP_ENABLED
|
|
|
|
#include <AP_HAL/utility/Socket.h>
|
2023-11-12 21:59:59 -04:00
|
|
|
#include <AP_Networking/AP_Networking_address.h>
|
2023-04-24 02:13:32 -03:00
|
|
|
#endif
|
2023-03-12 23:18:29 -03:00
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
|
|
|
class AP_DDS_Client
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2023-04-24 02:13:32 -03:00
|
|
|
AP_Int8 enabled;
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
// Serial Allocation
|
|
|
|
uxrSession session; //Session
|
2023-04-24 02:13:32 -03:00
|
|
|
bool is_using_serial; // true when using serial transport
|
2023-03-12 23:18:29 -03:00
|
|
|
|
2023-04-24 02:13:32 -03:00
|
|
|
// input and output stream
|
|
|
|
uint8_t *input_reliable_stream;
|
|
|
|
uint8_t *output_reliable_stream;
|
2023-03-12 23:18:29 -03:00
|
|
|
uxrStreamId reliable_in;
|
|
|
|
uxrStreamId reliable_out;
|
|
|
|
|
2023-06-28 00:43:59 -03:00
|
|
|
// Outgoing Sensor and AHRS data
|
2024-09-21 01:27:52 -03:00
|
|
|
|
|
|
|
#if AP_DDS_TIME_PUB_ENABLED
|
2023-03-12 23:18:29 -03:00
|
|
|
builtin_interfaces_msg_Time time_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a Time message
|
|
|
|
uint64_t last_time_time_ms;
|
|
|
|
//! @brief Serialize the current time state and publish to the IO stream(s)
|
|
|
|
void write_time_topic();
|
|
|
|
static void update_topic(builtin_interfaces_msg_Time& msg);
|
|
|
|
#endif // AP_DDS_TIME_PUB_ENABLED
|
|
|
|
|
|
|
|
#if AP_DDS_GPS_GLOBAL_ORIGIN_PUB_ENABLED
|
2024-03-05 15:26:39 -04:00
|
|
|
geographic_msgs_msg_GeoPointStamped gps_global_origin_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a gps global origin message
|
|
|
|
uint64_t last_gps_global_origin_time_ms;
|
|
|
|
//! @brief Serialize the current gps global origin and publish to the IO stream(s)
|
|
|
|
void write_gps_global_origin_topic();
|
|
|
|
static void update_topic(geographic_msgs_msg_GeoPointStamped& msg);
|
|
|
|
# endif // AP_DDS_GPS_GLOBAL_ORIGIN_PUB_ENABLED
|
|
|
|
|
2024-10-29 18:04:53 -03:00
|
|
|
#if AP_DDS_GOAL_PUB_ENABLED
|
|
|
|
geographic_msgs_msg_GeoPointStamped goal_topic;
|
|
|
|
// The last ms timestamp AP_DDS wrote a goal message
|
|
|
|
uint64_t last_goal_time_ms;
|
|
|
|
//! @brief Serialize the current goal and publish to the IO stream(s)
|
|
|
|
void write_goal_topic();
|
|
|
|
bool update_topic_goal(geographic_msgs_msg_GeoPointStamped& msg);
|
|
|
|
geographic_msgs_msg_GeoPointStamped prev_goal_msg;
|
|
|
|
# endif // AP_DDS_GOAL_PUB_ENABLED
|
|
|
|
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_GEOPOSE_PUB_ENABLED
|
2023-06-28 00:43:59 -03:00
|
|
|
geographic_msgs_msg_GeoPoseStamped geo_pose_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a GeoPose message
|
|
|
|
uint64_t last_geo_pose_time_ms;
|
|
|
|
//! @brief Serialize the current geo_pose and publish to the IO stream(s)
|
|
|
|
void write_geo_pose_topic();
|
|
|
|
static void update_topic(geographic_msgs_msg_GeoPoseStamped& msg);
|
|
|
|
#endif // AP_DDS_GEOPOSE_PUB_ENABLED
|
|
|
|
|
|
|
|
#if AP_DDS_LOCAL_POSE_PUB_ENABLED
|
2023-04-13 22:51:35 -03:00
|
|
|
geometry_msgs_msg_PoseStamped local_pose_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a Local Pose message
|
|
|
|
uint64_t last_local_pose_time_ms;
|
|
|
|
//! @brief Serialize the current local_pose and publish to the IO stream(s)
|
|
|
|
void write_local_pose_topic();
|
|
|
|
static void update_topic(geometry_msgs_msg_PoseStamped& msg);
|
|
|
|
#endif // AP_DDS_LOCAL_POSE_PUB_ENABLED
|
|
|
|
|
|
|
|
#if AP_DDS_LOCAL_VEL_PUB_ENABLED
|
2023-08-02 00:22:27 -03:00
|
|
|
geometry_msgs_msg_TwistStamped tx_local_velocity_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a Local Velocity message
|
|
|
|
uint64_t last_local_velocity_time_ms;
|
|
|
|
//! @brief Serialize the current local velocity and publish to the IO stream(s)
|
|
|
|
void write_tx_local_velocity_topic();
|
|
|
|
static void update_topic(geometry_msgs_msg_TwistStamped& msg);
|
|
|
|
#endif // AP_DDS_LOCAL_VEL_PUB_ENABLED
|
|
|
|
|
2024-10-08 12:58:31 -03:00
|
|
|
#if AP_DDS_AIRSPEED_PUB_ENABLED
|
|
|
|
geometry_msgs_msg_Vector3Stamped tx_local_airspeed_topic;
|
|
|
|
// The last ms timestamp AP_DDS wrote a airspeed message
|
|
|
|
uint64_t last_airspeed_time_ms;
|
|
|
|
//! @brief Serialize the current local airspeed and publish to the IO stream(s)
|
|
|
|
void write_tx_local_airspeed_topic();
|
|
|
|
static bool update_topic(geometry_msgs_msg_Vector3Stamped& msg);
|
|
|
|
#endif //AP_DDS_AIRSPEED_PUB_ENABLED
|
|
|
|
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_BATTERY_STATE_PUB_ENABLED
|
2023-06-28 00:43:59 -03:00
|
|
|
sensor_msgs_msg_BatteryState battery_state_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a BatteryState message
|
|
|
|
uint64_t last_battery_state_time_ms;
|
|
|
|
//! @brief Serialize the current nav_sat_fix state and publish it to the IO stream(s)
|
|
|
|
void write_battery_state_topic();
|
|
|
|
static void update_topic(sensor_msgs_msg_BatteryState& msg, const uint8_t instance);
|
|
|
|
#endif // AP_DDS_BATTERY_STATE_PUB_ENABLED
|
|
|
|
|
|
|
|
#if AP_DDS_NAVSATFIX_PUB_ENABLED
|
2023-06-28 00:43:59 -03:00
|
|
|
sensor_msgs_msg_NavSatFix nav_sat_fix_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a NavSatFix message
|
|
|
|
uint64_t last_nav_sat_fix_time_ms;
|
|
|
|
//! @brief Serialize the current nav_sat_fix state and publish to the IO stream(s)
|
|
|
|
void write_nav_sat_fix_topic();
|
|
|
|
bool update_topic(sensor_msgs_msg_NavSatFix& msg, const uint8_t instance) WARN_IF_UNUSED;
|
|
|
|
#endif // AP_DDS_NAVSATFIX_PUB_ENABLED
|
|
|
|
|
2024-09-13 20:02:38 -03:00
|
|
|
#if AP_DDS_IMU_PUB_ENABLED
|
2024-02-20 13:58:48 -04:00
|
|
|
sensor_msgs_msg_Imu imu_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote an IMU message
|
|
|
|
uint64_t last_imu_time_ms;
|
|
|
|
static void update_topic(sensor_msgs_msg_Imu& msg);
|
|
|
|
//! @brief Serialize the current IMU data and publish to the IO stream(s)
|
|
|
|
void write_imu_topic();
|
2024-09-13 20:02:38 -03:00
|
|
|
#endif // AP_DDS_IMU_PUB_ENABLED
|
2024-09-21 01:27:52 -03:00
|
|
|
|
|
|
|
#if AP_DDS_CLOCK_PUB_ENABLED
|
2023-05-10 06:35:29 -03:00
|
|
|
rosgraph_msgs_msg_Clock clock_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
// The last ms timestamp AP_DDS wrote a Clock message
|
|
|
|
uint64_t last_clock_time_ms;
|
|
|
|
//! @brief Serialize the current clock and publish to the IO stream(s)
|
|
|
|
void write_clock_topic();
|
|
|
|
static void update_topic(rosgraph_msgs_msg_Clock& msg);
|
|
|
|
#endif // AP_DDS_CLOCK_PUB_ENABLED
|
|
|
|
|
2024-10-29 12:06:50 -03:00
|
|
|
#if AP_DDS_STATUS_PUB_ENABLED
|
|
|
|
ardupilot_msgs_msg_Status status_topic;
|
|
|
|
bool update_topic(ardupilot_msgs_msg_Status& msg);
|
|
|
|
// The last ms timestamp AP_DDS wrote/checked a status message
|
|
|
|
uint64_t last_status_check_time_ms;
|
|
|
|
// last status values;
|
|
|
|
ardupilot_msgs_msg_Status last_status_msg_;
|
|
|
|
//! @brief Serialize the current status and publish to the IO stream(s)
|
|
|
|
void write_status_topic();
|
|
|
|
#endif // AP_DDS_STATUS_PUB_ENABLED
|
|
|
|
|
2024-09-21 01:27:52 -03:00
|
|
|
#if AP_DDS_STATIC_TF_PUB_ENABLED
|
|
|
|
// outgoing transforms
|
|
|
|
tf2_msgs_msg_TFMessage tx_static_transforms_topic;
|
|
|
|
//! @brief Serialize the static transforms and publish to the IO stream(s)
|
|
|
|
void write_static_transforms();
|
|
|
|
static void populate_static_transforms(tf2_msgs_msg_TFMessage& msg);
|
|
|
|
#endif // AP_DDS_STATIC_TF_PUB_ENABLED
|
|
|
|
|
|
|
|
#if AP_DDS_JOY_SUB_ENABLED
|
2023-06-28 00:43:59 -03:00
|
|
|
// incoming joystick data
|
|
|
|
static sensor_msgs_msg_Joy rx_joy_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_JOY_SUB_ENABLED
|
|
|
|
#if AP_DDS_VEL_CTRL_ENABLED
|
2023-08-02 00:22:27 -03:00
|
|
|
// incoming REP147 velocity control
|
|
|
|
static geometry_msgs_msg_TwistStamped rx_velocity_control_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_VEL_CTRL_ENABLED
|
|
|
|
#if AP_DDS_GLOBAL_POS_CTRL_ENABLED
|
2023-12-07 02:49:01 -04:00
|
|
|
// incoming REP147 goal interface global position
|
|
|
|
static ardupilot_msgs_msg_GlobalPosition rx_global_position_control_topic;
|
2024-09-21 01:27:52 -03:00
|
|
|
#endif // AP_DDS_GLOBAL_POS_CTRL_ENABLED
|
2024-10-19 23:21:00 -03:00
|
|
|
#if AP_DDS_DYNAMIC_TF_SUB_ENABLED
|
2023-06-28 00:43:59 -03:00
|
|
|
// incoming transforms
|
|
|
|
static tf2_msgs_msg_TFMessage rx_dynamic_transforms_topic;
|
2024-10-19 23:21:00 -03:00
|
|
|
#endif // AP_DDS_DYNAMIC_TF_SUB_ENABLED
|
2023-03-12 23:18:29 -03:00
|
|
|
HAL_Semaphore csem;
|
|
|
|
|
2024-10-03 16:57:57 -03:00
|
|
|
#if AP_DDS_PARAMETER_SERVER_ENABLED
|
|
|
|
static rcl_interfaces_srv_SetParameters_Request set_parameter_request;
|
|
|
|
static rcl_interfaces_srv_SetParameters_Response set_parameter_response;
|
|
|
|
static rcl_interfaces_srv_GetParameters_Request get_parameters_request;
|
|
|
|
static rcl_interfaces_srv_GetParameters_Response get_parameters_response;
|
|
|
|
static rcl_interfaces_msg_Parameter param;
|
|
|
|
#endif
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
// connection parametrics
|
2023-10-10 16:14:05 -03:00
|
|
|
bool status_ok{false};
|
|
|
|
bool connected{false};
|
2023-03-12 23:18:29 -03:00
|
|
|
|
2023-05-21 20:50:51 -03:00
|
|
|
// subscription callback function
|
2023-06-27 03:46:06 -03:00
|
|
|
static void on_topic_trampoline(uxrSession* session, uxrObjectId object_id, uint16_t request_id, uxrStreamId stream_id, struct ucdrBuffer* ub, uint16_t length, void* args);
|
|
|
|
void on_topic(uxrSession* session, uxrObjectId object_id, uint16_t request_id, uxrStreamId stream_id, struct ucdrBuffer* ub, uint16_t length);
|
|
|
|
|
|
|
|
// service replier callback function
|
|
|
|
static void on_request_trampoline(uxrSession* session, uxrObjectId object_id, uint16_t request_id, SampleIdentity* sample_id, ucdrBuffer* ub, uint16_t length, void* args);
|
|
|
|
void on_request(uxrSession* session, uxrObjectId object_id, uint16_t request_id, SampleIdentity* sample_id, ucdrBuffer* ub, uint16_t length);
|
2023-05-21 20:50:51 -03:00
|
|
|
|
|
|
|
// delivery control parameters
|
|
|
|
uxrDeliveryControl delivery_control {
|
|
|
|
.max_samples = UXR_MAX_SAMPLES_UNLIMITED,
|
|
|
|
.max_elapsed_time = 0,
|
|
|
|
.max_bytes_per_second = 0,
|
|
|
|
.min_pace_period = 0
|
|
|
|
};
|
|
|
|
|
2023-04-24 02:13:32 -03:00
|
|
|
// functions for serial transport
|
|
|
|
bool ddsSerialInit();
|
|
|
|
static bool serial_transport_open(uxrCustomTransport* args);
|
|
|
|
static bool serial_transport_close(uxrCustomTransport* transport);
|
|
|
|
static size_t serial_transport_write(uxrCustomTransport* transport, const uint8_t* buf, size_t len, uint8_t* error);
|
|
|
|
static size_t serial_transport_read(uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* error);
|
|
|
|
struct {
|
|
|
|
AP_HAL::UARTDriver *port;
|
|
|
|
uxrCustomTransport transport;
|
|
|
|
} serial;
|
|
|
|
|
|
|
|
#if AP_DDS_UDP_ENABLED
|
|
|
|
// functions for udp transport
|
|
|
|
bool ddsUdpInit();
|
|
|
|
static bool udp_transport_open(uxrCustomTransport* args);
|
|
|
|
static bool udp_transport_close(uxrCustomTransport* transport);
|
|
|
|
static size_t udp_transport_write(uxrCustomTransport* transport, const uint8_t* buf, size_t len, uint8_t* error);
|
|
|
|
static size_t udp_transport_read(uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* error);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
AP_Int32 port;
|
|
|
|
// UDP endpoint
|
2023-11-12 21:59:59 -04:00
|
|
|
AP_Networking_IPV4 ip{AP_DDS_DEFAULT_UDP_IP_ADDR};
|
2023-04-24 02:13:32 -03:00
|
|
|
// UDP Allocation
|
|
|
|
uxrCustomTransport transport;
|
|
|
|
SocketAPM *socket;
|
|
|
|
} udp;
|
|
|
|
#endif
|
2023-10-10 16:14:05 -03:00
|
|
|
// pointer to transport's communication structure
|
|
|
|
uxrCommunication *comm{nullptr};
|
2023-04-24 02:13:32 -03:00
|
|
|
|
|
|
|
// client key we present
|
2023-10-10 16:14:05 -03:00
|
|
|
static constexpr uint32_t key = 0xAAAABBBB;
|
2023-03-12 23:18:29 -03:00
|
|
|
|
2024-10-29 12:06:50 -03:00
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
public:
|
2023-10-10 16:14:05 -03:00
|
|
|
~AP_DDS_Client();
|
|
|
|
|
2023-04-24 02:13:32 -03:00
|
|
|
bool start(void);
|
2023-03-12 23:18:29 -03:00
|
|
|
void main_loop(void);
|
|
|
|
|
2023-10-10 16:14:05 -03:00
|
|
|
//! @brief Initialize the client's transport
|
|
|
|
//! @return True on successful initialization, false on failure
|
|
|
|
bool init_transport() WARN_IF_UNUSED;
|
|
|
|
|
|
|
|
//! @brief Initialize the client's uxr session and IO stream(s)
|
2023-03-12 23:18:29 -03:00
|
|
|
//! @return True on successful initialization, false on failure
|
2023-10-10 16:14:05 -03:00
|
|
|
bool init_session() WARN_IF_UNUSED;
|
2023-03-12 23:18:29 -03:00
|
|
|
|
|
|
|
//! @brief Set up the client's participants, data read/writes,
|
|
|
|
// publishers, subscribers
|
|
|
|
//! @return True on successful creation, false on failure
|
|
|
|
bool create() WARN_IF_UNUSED;
|
|
|
|
|
|
|
|
//! @brief Update the internally stored DDS messages with latest data
|
|
|
|
void update();
|
|
|
|
|
2023-07-14 18:38:43 -03:00
|
|
|
//! @brief GCS message prefix
|
|
|
|
static constexpr const char* msg_prefix = "DDS:";
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
//! @brief Parameter storage
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
2024-06-04 14:22:20 -03:00
|
|
|
//! @brief ROS_DOMAIN_ID
|
|
|
|
AP_Int32 domain_id;
|
|
|
|
|
2024-09-23 11:01:52 -03:00
|
|
|
//! @brief Timeout in milliseconds when pinging the XRCE agent
|
|
|
|
AP_Int32 ping_timeout_ms;
|
|
|
|
|
|
|
|
//! @brief Maximum number of attempts to ping the XRCE agent before exiting
|
|
|
|
AP_Int8 ping_max_retry;
|
|
|
|
|
2024-05-23 10:34:27 -03:00
|
|
|
//! @brief Enum used to mark a topic as a data reader or writer
|
|
|
|
enum class Topic_rw : uint8_t {
|
|
|
|
DataReader = 0,
|
|
|
|
DataWriter = 1,
|
|
|
|
};
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
//! @brief Convenience grouping for a single "channel" of data
|
|
|
|
struct Topic_table {
|
|
|
|
const uint8_t topic_id;
|
|
|
|
const uint8_t pub_id;
|
2023-05-21 20:50:51 -03:00
|
|
|
const uint8_t sub_id; // added sub_id fields to avoid confusion
|
2023-03-11 14:42:42 -04:00
|
|
|
const uxrObjectId dw_id;
|
2023-05-21 20:50:51 -03:00
|
|
|
const uxrObjectId dr_id; // added dr_id fields to avoid confusion
|
2024-05-23 10:34:27 -03:00
|
|
|
const Topic_rw topic_rw;
|
|
|
|
const char* topic_name;
|
|
|
|
const char* type_name;
|
|
|
|
const uxrQoS_t qos;
|
2023-03-12 23:18:29 -03:00
|
|
|
};
|
|
|
|
static const struct Topic_table topics[];
|
|
|
|
|
2024-05-23 10:34:27 -03:00
|
|
|
//! @brief Enum used to mark a service as a requester or replier
|
|
|
|
enum class Service_rr : uint8_t {
|
|
|
|
Requester = 0,
|
|
|
|
Replier = 1,
|
|
|
|
};
|
|
|
|
|
2023-06-27 03:46:06 -03:00
|
|
|
//! @brief Convenience grouping for a single "channel" of services
|
|
|
|
struct Service_table {
|
|
|
|
//! @brief Request ID for the service
|
|
|
|
const uint8_t req_id;
|
|
|
|
|
|
|
|
//! @brief Reply ID for the service
|
|
|
|
const uint8_t rep_id;
|
2023-03-12 23:18:29 -03:00
|
|
|
|
2024-05-23 10:34:27 -03:00
|
|
|
//! @brief Service is requester or replier
|
|
|
|
const Service_rr service_rr;
|
|
|
|
|
|
|
|
//! @brief Service name as it appears in ROS
|
|
|
|
const char* service_name;
|
|
|
|
|
|
|
|
//! @brief Service requester message type
|
|
|
|
const char* request_type;
|
|
|
|
|
|
|
|
//! @brief Service replier message type
|
|
|
|
const char* reply_type;
|
|
|
|
|
|
|
|
//! @brief Service requester topic name
|
|
|
|
const char* request_topic_name;
|
|
|
|
|
|
|
|
//! @brief Service replier topic name
|
|
|
|
const char* reply_topic_name;
|
2023-06-27 03:46:06 -03:00
|
|
|
|
2024-05-23 10:34:27 -03:00
|
|
|
//! @brief QoS for the service
|
|
|
|
const uxrQoS_t qos;
|
2023-06-27 03:46:06 -03:00
|
|
|
};
|
|
|
|
static const struct Service_table services[];
|
2023-03-12 23:18:29 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AP_DDS_ENABLED
|
|
|
|
|
|
|
|
|