Skip to content

Commit

Permalink
samer
Browse files Browse the repository at this point in the history
  • Loading branch information
SamerKhshiboun committed Dec 19, 2024
1 parent 16f96af commit 1104481
Show file tree
Hide file tree
Showing 19 changed files with 1,044 additions and 0 deletions.
4 changes: 4 additions & 0 deletions third-party/realdds/include/realdds/dds-device-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class dds_device_server
std::shared_ptr< dds_topic_reader > _control_reader;
std::shared_ptr< dds_topic_writer > _metadata_writer;
std::shared_ptr< dds_device_broadcaster > _broadcaster;

std::shared_ptr< dds_topic_reader > _get_control_value_reader;
std::shared_ptr< dds_topic_writer > _get_control_value_writer;

dispatcher _control_dispatcher;

set_option_callback _set_option_callback;
Expand Down
2 changes: 2 additions & 0 deletions third-party/realdds/include/realdds/topics/dds-topic-names.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ constexpr char const * NOTIFICATION_TOPIC_NAME = "/notification";
constexpr char const * CONTROL_TOPIC_NAME = "/control";
constexpr char const * METADATA_TOPIC_NAME = "/metadata";
constexpr char const * DFU_TOPIC_NAME = "/dfu";
constexpr char const * GET_CONTROL_VALUE_REQUEST_TOPIC = "rq/get_control_valueRequest";
constexpr char const * GET_CONTROL_VALUE_RESPONSE_TOPIC = "rr/get_control_valueReply";


namespace notification {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.

#pragma once

#include <realdds/dds-defines.h>
#include <realdds/topics/ros2/ros2getcontrolvalue-request.h>

#include <memory>

namespace realdds
{
namespace topics
{
class GetControlValueRequestPubSubType;
} // namespace msg
} // namespace sensor_msgs

namespace realdds
{

class dds_participant;
class dds_topic;
class dds_topic_reader;

namespace topics
{

class GetControlValueRequestMsg
{
public:
using type = realdds::topics::GetControlValueRequestPubSubType;

GetControlValueRequestMsg() = default;
~GetControlValueRequestMsg() = default;

uint64_t const get_control_id() const { return _data.get_control_id(); }
void set_control_id(uint64_t new_control_id) { _data.set_control_id(new_control_id); }

static std::shared_ptr<dds_topic> create_topic(std::shared_ptr<dds_participant> const &participant,
char const *topic_name);


private:
realdds::topics::GetControlValueRequest _data;
};

} // namespace topics
} // namespace realdds
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.

#pragma once

#include <realdds/dds-defines.h>
#include <realdds/topics/ros2/ros2getcontrolvalue-response.h>

#include <memory>

namespace realdds
{
namespace topics
{
class GetControlValueResponsePubSubType;
} // namespace msg
} // namespace sensor_msgs

namespace realdds
{

class dds_participant;
class dds_topic;
class dds_topic_reader;

namespace topics
{

class GetControlValueResponseMsg
{
public:
using type = realdds::topics::GetControlValueResponsePubSubType;

GetControlValueResponseMsg() = default;
~GetControlValueResponseMsg() = default;

long const get_result() const { return _data.get_result(); }
void set_result(uint64_t new_result) { _data.set_result(new_result); }

static std::shared_ptr<dds_topic> create_topic(std::shared_ptr<dds_participant> const &participant,
char const *topic_name);


private:
realdds::topics::GetControlValueResponse _data;
};

} // namespace topics
} // namespace realdds
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.

#ifndef _GET_CONTROL_VALUE_REQSPONSE_H_
#define _GET_CONTROL_VALUE_REQSPONSE_H_

#include <fastrtps/utils/fixed_size_string.hpp>
#include <stdint.h>

#include <array>
#include <string>
#include <vector>
#include <map>
#include <bitset>

#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec(dllexport)
#else
#define eProsima_user_DllExport
#endif // EPROSIMA_USER_DLL_EXPORT
#else
#define eProsima_user_DllExport
#endif // _WIN32

#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(GETCONTROLRESPONSE_SOURCE)
#define GETCONTROLRESPONSE_DllAPI __declspec(dllexport)
#else
#define GETCONTROLRESPONSE_DllAPI __declspec(dllimport)
#endif //
#else
#define GETCONTROLRESPONSE_DllAPI
#endif //
#else
#define GETCONTROLRESPONSE_DllAPI
#endif // _WIN32

namespace eprosima
{
namespace fastcdr
{
class Cdr;
} // namespace fastcdr
} // namespace eprosima

namespace realdds
{
namespace topics
{

class GetControlValueRequest
{
public:
// Default constructor
eProsima_user_DllExport GetControlValueRequest() = default;

// Default constructor
eProsima_user_DllExport ~GetControlValueRequest() = default;

eProsima_user_DllExport static size_t getMaxCdrSerializedSize(
size_t current_alignment = 0);

/*!
* @brief This function returns the serialized size of a data depending on the buffer alignment.
* @param data Data which is calculated its serialized size.
* @param current_alignment Buffer alignment.
* @return Serialized size.
*/
eProsima_user_DllExport static size_t getCdrSerializedSize(
const realdds::topics::GetControlValueRequest &data,
size_t current_alignment = 0);

/*!
* @brief This function serializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr &cdr) const;

/*!
* @brief This function deserializes an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr &cdr);

/*!
* @brief This function returns the maximum serialized size of the Key of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(
size_t current_alignment = 0);

/*!
* @brief This function tells you if the Key has been defined for this type
*/
eProsima_user_DllExport static bool isKeyDefined();

/*!
* @brief This function serializes the key members of an object using CDR serialization.
* @param cdr CDR serialization object.
*/
eProsima_user_DllExport void serializeKey(
eprosima::fastcdr::Cdr &cdr) const;

eProsima_user_DllExport void set_control_id(uint64_t new_control_id);
eProsima_user_DllExport uint64_t get_control_id() const;

private:
uint64_t control_id;
};

} // namespace topics
} // namespace realdds

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.


#ifndef _GET_CONTROL_VALUE_REQUEST_PUBSUBTYPES_H_
#define _GET_CONTROL_VALUE_REQUEST_PUBSUBTYPES_H_

#include <fastdds/dds/topic/TopicDataType.hpp>
#include <fastrtps/utils/md5.h>
#include "ros2getcontrolvalue-request.h"

#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
#error Generated Header is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
#endif // GEN_API_VER

namespace realdds
{
namespace topics
{

class GetControlValueRequestPubSubType : public eprosima::fastdds::dds::TopicDataType
{
public:
typedef GetControlValueRequest type;

eProsima_user_DllExport GetControlValueRequestPubSubType();
eProsima_user_DllExport virtual ~GetControlValueRequestPubSubType() override;

eProsima_user_DllExport bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
eProsima_user_DllExport bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(void *data) override;
eProsima_user_DllExport void *createData() override;
eProsima_user_DllExport void deleteData(void *data) override;
eProsima_user_DllExport bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *handle, bool force_md5 = false) override;

#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
eProsima_user_DllExport inline bool is_bounded() const override
{
return false;
}

#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED

#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
eProsima_user_DllExport inline bool is_plain() const override
{
return false;
}

#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN

#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
eProsima_user_DllExport inline bool construct_sample(
void *memory) const override
{
(void)memory;
return false;
}

#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE

private:
MD5 m_md5;
unsigned char *m_keyBuffer;
};

} // namespace topics
} // namespace realdds

#endif
Loading

0 comments on commit 1104481

Please sign in to comment.