Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System test cleanup #61

Merged
merged 47 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
16ee2e5
RmwAllocateFree
lij-oci Jan 18, 2021
177bb42
init
lij-oci Jan 18, 2021
c8d7aae
code review changes
lij-oci Jan 21, 2021
8c2b3f5
typo
lij-oci Jan 21, 2021
12d2ae7
Merge pull request #53 from lij-oci/rmw_allocate_free
adamsj-ros Jan 21, 2021
c683d11
Merge pull request #55 from oci-labs/master
adamsj-ros Jan 22, 2021
ed6a198
node, publiser
lij-oci Jan 23, 2021
a70c4d6
Merge branch 'system_test_cleanup' into node
lij-oci Jan 23, 2021
21425d3
Update azure-pipelines.yml
adamsj-ros Jan 25, 2021
2877e0d
code review changes
lij-oci Jan 25, 2021
dd95cd2
code review changes2
lij-oci Jan 25, 2021
6920785
Merge pull request #56 from lij-oci/node
lij-oci Jan 27, 2021
1a5a4d1
subscriber
lij-oci Feb 3, 2021
f33cbf4
gid
lij-oci Feb 3, 2021
1a0c286
code review changes
lij-oci Feb 5, 2021
590c813
code review changes2
lij-oci Feb 8, 2021
db93c80
Merge pull request #57 from lij-oci/subscription
lij-oci Feb 8, 2021
6ef3e49
service related changes
lij-oci Feb 16, 2021
c78d74a
remove unwanted dependencies
lij-oci Feb 17, 2021
f967509
node name and namespace
lij-oci Feb 19, 2021
0c5fd9e
names_and_types_helpers
lij-oci Feb 19, 2021
0e66e49
src, cmake, package, and include paths switched
Feb 19, 2021
4fad13f
switch defines
Feb 19, 2021
d54ea6a
remove shared_functions.hpp
lij-oci Feb 19, 2021
25b0319
separate hpp template from other functions interface
Feb 19, 2021
63ff2c6
cleanup comments
Feb 19, 2021
48c60c9
remove opendds_include.hpp
lij-oci Feb 19, 2021
2f5b341
Merge pull request #59 from adamsj-oci/combine_packages
adamsj-ros Feb 22, 2021
2e33534
merge with combining packages
lij-oci Feb 22, 2021
bcc22b8
Merge branch 'system_test_cleanup' into service
Feb 22, 2021
f5efe49
Merge pull request #1 from adamsj-oci/service
lij-oci Feb 22, 2021
25249b9
Merge branch 'service' of https://github.com/lij-oci/rmw_opendds into…
lij-oci Feb 22, 2021
184d7ef
changes with merging combined packages
lij-oci Feb 23, 2021
82dd174
fix type support to pre xtypes
adamsj-ros Feb 23, 2021
42592ab
fix space error
adamsj-ros Feb 23, 2021
c617704
rmw includes
lij-oci Feb 23, 2021
fd95006
Merge branch 'service' of https://github.com/lij-oci/rmw_opendds into…
lij-oci Feb 23, 2021
aac54c2
remove_pub/sub
lij-oci Feb 24, 2021
d431e6b
remove_pub/sub2
lij-oci Feb 24, 2021
4d118e4
clean_service commented out temporarily
lij-oci Feb 25, 2021
017780f
Merge branch 'master' into system_test_cleanup
Feb 25, 2021
4413df1
Merge pull request #63 from adamsj-oci/system_test_cleanup
adamsj-ros Feb 26, 2021
6427a60
code review changes
lij-oci Feb 26, 2021
0a56c72
azure-pipelines
lij-oci Feb 26, 2021
bc83fa3
node name
lij-oci Feb 26, 2021
440f0e9
Merge pull request #58 from lij-oci/service
lij-oci Mar 1, 2021
25837dd
add todo
adamsj-ros Mar 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This project contains several ROS2 packages:

- `rmw_opendds`: composed of (this repo)
- `rmw_opendds_cpp`: Responsible for binding the ROS2 `rmw.h` interface functions to the equivalent OpenDDS functions.
- `rmw_opendds_shared_cpp`: Shared code used in rmw_opendds.
- `rosidl_typesupport_opendds`: composed of (https://github.com/oci-labs/rosidl_typesupport_opendds)
- `opendds_cmake_module`: Responsible for configuring paths to the TAO/OpenDDS IDL processors and headers.
- `rosidl_typesupport_opendds_c`: Responsible for generating OpenDDS C headers based on the OMG IDLs produced by ROS2 preprocessors.
Expand Down
64 changes: 39 additions & 25 deletions rmw_opendds_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake REQUIRED)

find_package(opendds_cmake_module REQUIRED)
find_package(OpenDDS QUIET)

Expand All @@ -24,6 +23,11 @@ endif()

find_package(rcutils REQUIRED)

# rcutils package changes CXX standard to 11
if(${CMAKE_CXX_STANDARD} LESS 14)
set(CMAKE_CXX_STANDARD 14)
endif()

find_package(rosidl_typesupport_opendds_c)
if(NOT rosidl_typesupport_opendds_c_FOUND)
ament_package()
Expand All @@ -39,7 +43,6 @@ if(NOT rosidl_typesupport_opendds_cpp_FOUND)
endif()

find_package(rmw REQUIRED)
find_package(rmw_opendds_shared_cpp REQUIRED)
find_package(rosidl_generator_c REQUIRED)
find_package(rosidl_generator_cpp REQUIRED)

Expand All @@ -53,7 +56,6 @@ ament_export_include_directories(include)
ament_export_dependencies(
rcutils
rmw
rmw_opendds_shared_cpp
rosidl_generator_c
rosidl_generator_cpp
rosidl_typesupport_opendds_c
Expand All @@ -64,49 +66,54 @@ register_rmw_implementation(
"cpp:rosidl_typesupport_cpp:rosidl_typesupport_opendds_cpp"
)


# Build RMW library.
add_library(
rmw_opendds_cpp
SHARED
src/opendds_static_publisher_info.cpp
src/opendds_static_subscriber_info.cpp
src/get_client.cpp
src/get_participant.cpp
src/get_publisher.cpp
src/get_service.cpp
src/get_subscriber.cpp
src/DDSPublisher.cpp
src/DDSSubscriber.cpp
src/DDSClient.cpp
src/DDSServer.cpp
src/DDSTopic.cpp
src/OpenDDSNode.cpp
src/Service.cpp
src/condition_error.cpp
src/demangle.cpp
src/event.cpp
src/event_converter.cpp
src/guard_condition.cpp
src/identifier.cpp
src/process_topic_and_service_names.cpp
src/init.cpp
src/namespace_prefix.cpp
src/qos.cpp
src/serialization_format.cpp
src/topic_endpoint_info.cpp
src/trigger_guard_condition.cpp
src/types/custom_data_reader_listener.cpp
src/types/custom_publisher_listener.cpp
src/types/custom_subscriber_listener.cpp
src/wait.cpp
src/wait_set.cpp
src/rmw_client.cpp
src/rmw_compare_gid_equals.cpp
src/rmw_count.cpp
src/rmw_event.cpp
src/rmw_get_gid_for_publisher.cpp
src/rmw_get_implementation_identifier.cpp
src/rmw_get_serialization_format.cpp
src/rmw_get_topic_endpoint_info.cpp
src/rmw_guard_condition.cpp
src/rmw_init.cpp
src/rmw_logging.cpp
src/rmw_node.cpp
src/rmw_node_info_and_types.cpp
src/rmw_node_names.cpp
src/rmw_publish.cpp
src/rmw_publisher.cpp
src/rmw_request.cpp
src/rmw_response.cpp
src/rmw_serialize.cpp
src/rmw_service.cpp
src/rmw_service_names_and_types.cpp
src/rmw_service_server_is_available.cpp
src/rmw_server.cpp
src/rmw_subscription.cpp
src/rmw_take.cpp
src/rmw_topic_names_and_types.cpp
src/rmw_trigger_guard_condition.cpp
src/rmw_wait.cpp
src/rmw_wait_set.cpp
src/serialization_format.cpp
src/rmw_get_topic_endpoint_info.cpp)
)

OPENDDS_TARGET_SOURCES(rmw_opendds_cpp resources/opendds_static_serialized_data.idl TAO_IDL_OPTIONS "-Sa -St")
target_link_libraries(rmw_opendds_cpp ${opendds_libs})
Expand All @@ -115,7 +122,6 @@ target_link_libraries(rmw_opendds_cpp ${opendds_libs})
ament_target_dependencies(rmw_opendds_cpp
"rcutils"
"rmw"
"rmw_opendds_shared_cpp"
"rosidl_generator_c"
"rosidl_generator_cpp"
"rosidl_typesupport_opendds_c"
Expand All @@ -124,6 +130,14 @@ ament_target_dependencies(rmw_opendds_cpp
target_include_directories(rmw_opendds_cpp PUBLIC ${patched_directory})
ament_export_libraries(rmw_opendds_cpp)

if(WIN32)
# Causes the visibility macros to use dllexport rather than dllimport
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(rmw_opendds_cpp
PRIVATE "RMW_OPENDDS_CPP_BUILDING_DLL"
"_CRT_NONSTDC_NO_DEPRECATE")
endif()

# Causes the visibility macros to use dllexport rather than dllimport
# which is appropriate when building the library but not consuming it.
target_compile_definitions(rmw_opendds_cpp
Expand Down
54 changes: 54 additions & 0 deletions rmw_opendds_cpp/include/rmw_opendds_cpp/DDSClient.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2014-2017 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW_OPENDDS_CPP__DDSCLIENT_HPP_
#define RMW_OPENDDS_CPP__DDSCLIENT_HPP_

#include <rmw_opendds_cpp/Service.hpp>
#include <rmw_opendds_cpp/OpenDDSNode.hpp>
#include <rmw_opendds_cpp/RmwAllocateFree.hpp>

#include <dds/DCPS/GuardCondition.h>

class DDSClient
{
public:
typedef RmwAllocateFree<DDSClient> Raf;
static DDSClient * from(const rmw_client_t * client);
int64_t send(const void * ros_request) const;
bool take(rmw_service_info_t * request_header, void * ros_reply) const;
void add_to(OpenDDSNode * dds_node);
bool remove_from(OpenDDSNode * dds_node);
bool is_server_available() const;
const std::string& service_name() const { return service_.name(); }
void * requester() const { return requester_; }
DDS::ReadCondition_var read_condition() const { return read_condition_; }

private:
friend Raf;
DDSClient(const rosidl_service_type_support_t * ts, const char * service_name,
const rmw_qos_profile_t * rmw_qos, DDS::DomainParticipant_var dp);
~DDSClient() { cleanup(); }
void cleanup();
bool count_matched_subscribers(size_t & count) const;
bool count_matched_publishers(size_t & count) const;

Service service_;
void * requester_;
DDS::DataReader_var reader_;
DDS::ReadCondition_var read_condition_;
DDS::DataWriter_var writer_;
};

#endif // RMW_OPENDDS_CPP__DDSCLIENT_HPP_
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright 2017 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -12,23 +10,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw_opendds_cpp/get_participant.hpp"
#ifndef RMW_OPENDDS_CPP__DDSENTITY_HPP_
#define RMW_OPENDDS_CPP__DDSENTITY_HPP_

#include "rmw_opendds_cpp/identifier.hpp"
#include <dds/DdsDcpsInfrastructureC.h>

namespace rmw_opendds_cpp
{
#include <rmw/ret_types.h>

DDS::DomainParticipant *
get_participant(rmw_node_t * node)
class DDSEntity
{
if (!node) {
return NULL;
}
if (node->implementation_identifier != opendds_identifier) {
return NULL;
}
return static_cast<DDS::DomainParticipant *>(node->data);
}
public:
// Given DDS::StatusMask, fill the corresponding rmw_status and return RMW_RET_OK.
// Otherwise return RMW_RET_UNSUPPORTED if DDS::StatusMask is unsupported,
// RMW_RET_TIMEOUT, or RMW_RET_ERROR on other errors.
virtual rmw_ret_t get_status(const DDS::StatusMask mask, void * rmw_status) = 0;
virtual DDS::Entity * get_entity() = 0;
};

} // namespace rmw_opendds_cpp
#endif // RMW_OPENDDS_CPP__DDSENTITY_HPP_
78 changes: 78 additions & 0 deletions rmw_opendds_cpp/include/rmw_opendds_cpp/DDSPublisher.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2014-2017 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW_OPENDDS_CPP__DDSPUBLISHER_HPP_
#define RMW_OPENDDS_CPP__DDSPUBLISHER_HPP_

#include <rmw_opendds_cpp/DDSEntity.hpp>
#include <rmw_opendds_cpp/DDSTopic.hpp>
#include <rmw_opendds_cpp/RmwAllocateFree.hpp>

#include <atomic>

class OpenDDSPublisherListener : public DDS::PublisherListener
{
public:
typedef RmwAllocateFree<OpenDDSPublisherListener> Raf;

virtual void on_publication_matched(DDS::DataWriter *, const DDS::PublicationMatchedStatus & status) {
current_count_ = status.current_count;
}
std::size_t current_count() const { return current_count_; }

void on_offered_deadline_missed(DDS::DataWriter_ptr, const DDS::OfferedDeadlineMissedStatus&) {}
void on_offered_incompatible_qos(DDS::DataWriter_ptr, const DDS::OfferedIncompatibleQosStatus&) {}
void on_liveliness_lost(DDS::DataWriter_ptr, const DDS::LivelinessLostStatus&) {}

private:
friend Raf;
OpenDDSPublisherListener() { current_count_ = 0; }
~OpenDDSPublisherListener() {}
std::atomic<std::size_t> current_count_;
};

class DDSPublisher : public DDSEntity
{
public:
typedef RmwAllocateFree<DDSPublisher> Raf;
static DDSPublisher * from(const rmw_publisher_t * pub);
const std::string& topic_name() const { return topic_.name(); }
const std::string& topic_type() const { return topic_.type(); }
rmw_ret_t get_rmw_qos(rmw_qos_profile_t & qos) const;
rmw_ret_t to_cdr_stream(const void * ros_message, rcutils_uint8_array_t & cdr_stream);
DDS::DataWriter_var writer() const { return writer_; }

std::size_t matched_subscribers() const { return listener_->current_count(); }
DDS::InstanceHandle_t instance_handle() const { return publisher_->get_instance_handle(); }
rmw_gid_t gid() const { return publisher_gid_; }

// Remap the OpenDDS DataWriter status to a generic RMW status
rmw_ret_t get_status(const DDS::StatusMask mask, void * rmw_status) override;
// Return the writer associated with this publisher
DDS::Entity * get_entity() override { return writer_; }
private:
friend Raf;
DDSPublisher(DDS::DomainParticipant_var dp, const rosidl_message_type_support_t * ros_ts,
const char * topic_name, const rmw_qos_profile_t * rmw_qos);
~DDSPublisher() { cleanup(); }
void cleanup();

DDSTopic topic_;
OpenDDSPublisherListener * listener_;
DDS::Publisher_var publisher_;
DDS::DataWriter_var writer_;
rmw_gid_t publisher_gid_;
};

#endif // RMW_OPENDDS_CPP__DDSPUBLISHER_HPP_
51 changes: 51 additions & 0 deletions rmw_opendds_cpp/include/rmw_opendds_cpp/DDSServer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2014-2017 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW_OPENDDS_CPP__DDSSERVER_HPP_
#define RMW_OPENDDS_CPP__DDSSERVER_HPP_

#include <rmw_opendds_cpp/Service.hpp>
#include <rmw_opendds_cpp/OpenDDSNode.hpp>
#include <rmw_opendds_cpp/RmwAllocateFree.hpp>

#include <dds/DCPS/GuardCondition.h>

class DDSServer
{
public:
typedef RmwAllocateFree<DDSServer> Raf;
static DDSServer * from(const rmw_service_t * service);
bool take(rmw_service_info_t * request_header, void * ros_request) const;
bool send(const rmw_request_id_t * request_header, const void * ros_reply) const;
void add_to(OpenDDSNode * dds_node);
bool remove_from(OpenDDSNode * dds_node);
const std::string& service_name() const { return service_.name(); }
void * replier() const { return replier_; }
DDS::ReadCondition_var read_condition() const { return read_condition_; }

private:
friend Raf;
DDSServer(const rosidl_service_type_support_t * ts, const char * service_name,
const rmw_qos_profile_t * rmw_qos, DDS::DomainParticipant_var dp);
~DDSServer() { cleanup(); }
void cleanup();

Service service_;
void * replier_;
DDS::DataReader_var reader_;
DDS::ReadCondition_var read_condition_;
DDS::DataWriter_var writer_;
};

#endif // RMW_OPENDDS_CPP__DDSSERVER_HPP_
Loading