-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #13715 from Eran: adapter ROS2 node & parameters
- Loading branch information
Showing
91 changed files
with
17,343 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
third-party/realdds/include/realdds/topics/ros2/describe-parameters-msg.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2025 Intel Corporation. All Rights Reserved. | ||
#pragma once | ||
|
||
#include <realdds/dds-defines.h> | ||
|
||
#include <realdds/topics/ros2/rcl_interfaces/srv/DescribeParameters.h> | ||
#include <realdds/topics/ros2/rcl_interfaces/msg/ParameterDescriptor.h> | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <vector> | ||
|
||
|
||
namespace rcl_interfaces { | ||
namespace srv { | ||
class DescribeParameters_RequestPubSubType; | ||
class DescribeParameters_ResponsePubSubType; | ||
} // namespace srv | ||
} // namespace rcl_interfaces | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
class dds_participant; | ||
class dds_topic; | ||
class dds_topic_reader; | ||
class dds_topic_writer; | ||
|
||
|
||
namespace topics { | ||
namespace ros2 { | ||
|
||
|
||
class describe_parameters_request_msg | ||
{ | ||
rcl_interfaces::srv::DescribeParameters_Request _raw; | ||
|
||
public: | ||
using type = rcl_interfaces::srv::DescribeParameters_RequestPubSubType; | ||
|
||
void clear() { _raw.names().clear(); } | ||
std::vector< std::string > const & names() const { return _raw.names(); } | ||
void add( std::string const & name ) { _raw.names().push_back( name ); } | ||
|
||
bool is_valid() const { return ! names().empty(); } | ||
void invalidate() { clear(); } | ||
|
||
|
||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
char const * topic_name ); | ||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
std::string const & topic_name ) | ||
{ | ||
return create_topic( participant, topic_name.c_str() ); | ||
} | ||
|
||
// This helper method will take the next sample from a reader. | ||
// | ||
// Returns true if successful. Make sure you still check is_valid() in case the sample info isn't! | ||
// Returns false if no more data is available. | ||
// Will throw if an unexpected error occurs. | ||
// | ||
//Note - copies the data. | ||
//TODO - add an API for a function that loans the data and enables the user to free it later. | ||
bool take_next( dds_topic_reader &, dds_sample * optional_sample = nullptr ); | ||
}; | ||
|
||
|
||
class describe_parameters_response_msg | ||
{ | ||
rcl_interfaces::srv::DescribeParameters_Response _raw; | ||
|
||
public: | ||
using type = rcl_interfaces::srv::DescribeParameters_ResponsePubSubType; | ||
|
||
using descriptor_type = rcl_interfaces::msg::ParameterDescriptor; | ||
|
||
std::vector< descriptor_type > const & descriptors() const { return _raw.descriptors(); } | ||
bool is_valid() const { return ! descriptors().empty(); } | ||
void invalidate() { _raw.descriptors().clear(); } | ||
|
||
void add( descriptor_type const & descriptor ) | ||
{ | ||
_raw.descriptors().push_back( descriptor ); | ||
} | ||
|
||
|
||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
char const * topic_name ); | ||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
std::string const & topic_name ) | ||
{ | ||
return create_topic( participant, topic_name.c_str() ); | ||
} | ||
|
||
// Sends out the response to the given writer | ||
// The request sample is needed for ROS2 request-response mechanism to connect the two | ||
// Returns a unique (to the writer) identifier for the sample that was sent, or 0 if unsuccessful | ||
dds_sequence_number respond_to( dds_sample const & request_sample, dds_topic_writer & ) const; | ||
|
||
// This helper method will take the next sample from a reader. | ||
// | ||
// Returns true if successful. Make sure you still check is_valid() in case the sample info isn't! | ||
// Returns false if no more data is available. | ||
// Will throw if an unexpected error occurs. | ||
// | ||
//Note - copies the data. | ||
//TODO - add an API for a function that loans the data and enables the user to free it later. | ||
bool take_next( dds_topic_reader &, dds_sample * optional_sample = nullptr ); | ||
}; | ||
|
||
|
||
} // namespace ros2 | ||
} // namespace topics | ||
} // namespace realdds |
112 changes: 112 additions & 0 deletions
112
third-party/realdds/include/realdds/topics/ros2/get-parameters-msg.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2025 Intel Corporation. All Rights Reserved. | ||
#pragma once | ||
|
||
#include <realdds/dds-defines.h> | ||
|
||
#include <realdds/topics/ros2/rcl_interfaces/srv/GetParameters.h> | ||
#include <realdds/topics/ros2/rcl_interfaces/msg/ParameterValue.h> | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <vector> | ||
|
||
|
||
namespace rcl_interfaces { | ||
namespace srv { | ||
class GetParameters_RequestPubSubType; | ||
class GetParameters_ResponsePubSubType; | ||
} // namespace srv | ||
} // namespace rcl_interfaces | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
class dds_participant; | ||
class dds_topic; | ||
class dds_topic_reader; | ||
class dds_topic_writer; | ||
|
||
|
||
namespace topics { | ||
namespace ros2 { | ||
|
||
|
||
class get_parameters_request_msg | ||
{ | ||
rcl_interfaces::srv::GetParameters_Request _raw; | ||
|
||
public: | ||
using type = rcl_interfaces::srv::GetParameters_RequestPubSubType; | ||
|
||
void clear() { _raw.names().clear(); } | ||
std::vector< std::string > const & names() const { return _raw.names(); } | ||
void add( std::string const & name ) { _raw.names().push_back( name ); } | ||
|
||
bool is_valid() const { return ! names().empty(); } | ||
void invalidate() { clear(); } | ||
|
||
|
||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
char const * topic_name ); | ||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
std::string const & topic_name ) | ||
{ | ||
return create_topic( participant, topic_name.c_str() ); | ||
} | ||
|
||
// This helper method will take the next sample from a reader. | ||
// | ||
// Returns true if successful. Make sure you still check is_valid() in case the sample info isn't! | ||
// Returns false if no more data is available. | ||
// Will throw if an unexpected error occurs. | ||
// | ||
//Note - copies the data. | ||
//TODO - add an API for a function that loans the data and enables the user to free it later. | ||
bool take_next( dds_topic_reader &, dds_sample * optional_sample = nullptr ); | ||
}; | ||
|
||
|
||
class get_parameters_response_msg | ||
{ | ||
rcl_interfaces::srv::GetParameters_Response _raw; | ||
|
||
public: | ||
using type = rcl_interfaces::srv::GetParameters_ResponsePubSubType; | ||
|
||
using value_type = rcl_interfaces::msg::ParameterValue; | ||
|
||
std::vector< value_type > const & values() const { return _raw.values(); } | ||
void add( value_type const & value ) { _raw.values().push_back( value ); } | ||
bool is_valid() const { return ! values().empty(); } | ||
void invalidate() { _raw.values().clear(); } | ||
|
||
// Sends out the response to the given writer | ||
// The request sample is needed for ROS2 request-response mechanism to connect the two | ||
// Returns a unique (to the writer) identifier for the sample that was sent, or 0 if unsuccessful | ||
dds_sequence_number respond_to( dds_sample const & request_sample, dds_topic_writer & ) const; | ||
|
||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
char const * topic_name ); | ||
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant, | ||
std::string const & topic_name ) | ||
{ | ||
return create_topic( participant, topic_name.c_str() ); | ||
} | ||
|
||
// This helper method will take the next sample from a reader. | ||
// | ||
// Returns true if successful. Make sure you still check is_valid() in case the sample info isn't! | ||
// Returns false if no more data is available. | ||
// Will throw if an unexpected error occurs. | ||
// | ||
//Note - copies the data. | ||
//TODO - add an API for a function that loans the data and enables the user to free it later. | ||
bool take_next( dds_topic_reader &, dds_sample * optional_sample = nullptr ); | ||
}; | ||
|
||
|
||
} // namespace ros2 | ||
} // namespace topics | ||
} // namespace realdds |
Oops, something went wrong.