Skip to content

Commit

Permalink
Merge pull request #61 from oci-labs/system_test_cleanup
Browse files Browse the repository at this point in the history
System test cleanup
  • Loading branch information
adamsj-ros authored Mar 1, 2021
2 parents 1c5f117 + 25837dd commit bab7b75
Show file tree
Hide file tree
Showing 123 changed files with 3,539 additions and 5,224 deletions.
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

0 comments on commit bab7b75

Please sign in to comment.