| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,28 +89,22 @@ class GraphManager | |||
| 89 | 89 | ||
| 90 | 90 | /** | |
| 91 | 91 | * @brief Adds a DDS participant to the graph tree. | |
| 92 | - * @param participant Pointer to the participant to be added to the graph. | ||
| 93 | - */ | ||
| 94 | - void add_participant( | ||
| 95 | - const eprosima::fastdds::dds::DomainParticipant* participant); | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * @brief Adds a DDS participant to the graph tree. | ||
| 99 | - * @param guid rtps::GUID_t of the participant to be added. | ||
| 100 | - * @param node_name Name of the ROS 2 node associated to the given participant. | ||
| 92 | + * @param participant eprosima::fastdds::dds::DomainParticipant to be added. | ||
| 93 | + * @param from_microros if this participant has been added from micro-ROS. | ||
| 101 | 94 | * @param enclave ROS 2 enclave. | |
| 102 | 95 | */ | |
| 103 | 96 | void add_participant( | |
| 104 | - const eprosima::fastrtps::rtps::GUID_t& guid, | ||
| 105 | - const std::string& node_name, | ||
| 106 | - const std::string& enclave); | ||
| 97 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 98 | + bool from_microros = true, | ||
| 99 | + const std::string& enclave = "/"); | ||
| 107 | 100 | ||
| 108 | 101 | /** | |
| 109 | 102 | * @brief Removes a DDS participant from the graph tree. | |
| 110 | - * @param guid rtps::GUID_t of the participant to be removed. | ||
| 103 | + * @param participant eprosima::fastdds::dds::DomainParticipant to be removed. | ||
| 111 | 104 | */ | |
| 112 | 105 | void remove_participant( | |
| 113 | - const eprosima::fastrtps::rtps::GUID_t& guid); | ||
| 106 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 107 | + bool from_microros = true); | ||
| 114 | 108 | ||
| 115 | 109 | /** | |
| 116 | 110 | * @brief Adds a DDS datawriter to the graph tree. | |
@@ -186,7 +180,7 @@ class GraphManager | |||
| 186 | 180 | */ | |
| 187 | 181 | void associate_entity( | |
| 188 | 182 | const eprosima::fastrtps::rtps::GUID_t& entity_guid, | |
| 189 | - const eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 183 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 190 | 184 | const dds::xrce::ObjectKind& entity_kind); | |
| 191 | 185 | ||
| 192 | 186 | private: | |
@@ -277,11 +271,12 @@ class GraphManager | |||
| 277 | 271 | eprosima::fastdds::dds::DomainId_t domain_id_; | |
| 278 | 272 | bool graph_changed_; | |
| 279 | 273 | bool display_on_change_; | |
| 280 | - const char * enclave_; | ||
| 281 | 274 | std::thread microros_graph_publisher_; | |
| 282 | 275 | std::mutex mtx_; | |
| 283 | 276 | std::condition_variable cv_; | |
| 284 | 277 | ||
| 278 | + eprosima::fastdds::dds::DataWriterQos datawriter_qos_; | ||
| 279 | + | ||
| 285 | 280 | rmw_dds_common::GraphCache graphCache_; | |
| 286 | 281 | std::unique_ptr<ParticipantListener> participant_listener_; | |
| 287 | 282 | std::unique_ptr<DatareaderListener> datareader_listener_; | |
@@ -293,9 +288,17 @@ class GraphManager | |||
| 293 | 288 | std::unique_ptr<eprosima::fastdds::dds::Subscriber> subscriber_; | |
| 294 | 289 | std::unique_ptr<eprosima::fastdds::dds::Topic> ros_discovery_topic_; | |
| 295 | 290 | std::unique_ptr<eprosima::fastdds::dds::Topic> ros_to_microros_graph_topic_; | |
| 296 | - std::unique_ptr<eprosima::fastdds::dds::DataWriter> ros_discovery_datawriter_; | ||
| 297 | 291 | std::unique_ptr<eprosima::fastdds::dds::DataWriter> ros_to_microros_graph_datawriter_; | |
| 298 | 292 | std::unique_ptr<eprosima::fastdds::dds::DataReader> ros_discovery_datareader_; | |
| 293 | + | ||
| 294 | + // Store a auxiliary publishers and datawriter for each participant created in micro-ROS | ||
| 295 | + std::map< | ||
| 296 | + eprosima::fastdds::dds::DomainParticipant*, | ||
| 297 | + std::pair< | ||
| 298 | + std::unique_ptr<eprosima::fastdds::dds::Publisher>, | ||
| 299 | + std::unique_ptr<eprosima::fastdds::dds::DataWriter> | ||
| 300 | + > | ||
| 301 | + > micro_ros_graph_datawriters_; | ||
| 299 | 302 | }; | |
| 300 | 303 | ||
| 301 | 304 | } // namespace graph_manager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,20 +32,16 @@ bool Agent::create( | |||
| 32 | 32 | bool result = xrce_dds_agent_instance_.create(argc, argv); | |
| 33 | 33 | if (result) | |
| 34 | 34 | { | |
| 35 | + auto graph_manager_ = find_or_create_graph_manager(0); | ||
| 35 | 36 | /** | |
| 36 | 37 | * Add CREATE_PARTICIPANT callback. | |
| 37 | 38 | */ | |
| 38 | 39 | std::function<void ( | |
| 39 | - const eprosima::fastdds::dds::DomainParticipant *)> on_create_participant | ||
| 40 | + eprosima::fastdds::dds::DomainParticipant *)> on_create_participant | ||
| 40 | 41 | ([&]( | |
| 41 | - const eprosima::fastdds::dds::DomainParticipant* participant) -> void | ||
| 42 | + eprosima::fastdds::dds::DomainParticipant* participant) -> void | ||
| 42 | 43 | { | |
| 43 | - auto graph_manager_ = | ||
| 44 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 45 | - participant->get_domain_id() | ||
| 46 | - ) | ||
| 47 | - ); | ||
| 48 | - | ||
| 44 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 49 | 45 | graph_manager_->add_participant(participant); | |
| 50 | 46 | }); | |
| 51 | 47 | xrce_dds_agent_instance_.add_middleware_callback( | |
@@ -57,17 +53,12 @@ bool Agent::create( | |||
| 57 | 53 | * Add REMOVE_PARTICIPANT callback. | |
| 58 | 54 | */ | |
| 59 | 55 | std::function<void ( | |
| 60 | - const eprosima::fastdds::dds::DomainParticipant *)> on_delete_participant | ||
| 56 | + eprosima::fastdds::dds::DomainParticipant *)> on_delete_participant | ||
| 61 | 57 | ([&]( | |
| 62 | - const eprosima::fastdds::dds::DomainParticipant* participant) -> void | ||
| 58 | + eprosima::fastdds::dds::DomainParticipant* participant) -> void | ||
| 63 | 59 | { | |
| 64 | - auto graph_manager_ = | ||
| 65 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 66 | - participant->get_domain_id() | ||
| 67 | - ) | ||
| 68 | - ); | ||
| 69 | - | ||
| 70 | - graph_manager_->remove_participant(participant->guid()); | ||
| 60 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 61 | + graph_manager_->remove_participant(participant); | ||
| 71 | 62 | }); | |
| 72 | 63 | xrce_dds_agent_instance_.add_middleware_callback( | |
| 73 | 64 | eprosima::uxr::Middleware::Kind::FASTDDS, | |
@@ -78,22 +69,18 @@ bool Agent::create( | |||
| 78 | 69 | * Add CREATE_DATAWRITER callback. | |
| 79 | 70 | */ | |
| 80 | 71 | std::function<void ( | |
| 81 | - const eprosima::fastdds::dds::DomainParticipant *, | ||
| 82 | - const eprosima::fastdds::dds::DataWriter *)> on_create_datawriter | ||
| 72 | + eprosima::fastdds::dds::DomainParticipant *, | ||
| 73 | + eprosima::fastdds::dds::DataWriter *)> on_create_datawriter | ||
| 83 | 74 | ([&]( | |
| 84 | - const eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 85 | - const eprosima::fastdds::dds::DataWriter* datawriter) -> void | ||
| 75 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 76 | + eprosima::fastdds::dds::DataWriter* datawriter) -> void | ||
| 86 | 77 | { | |
| 87 | - auto graph_manager_ = | ||
| 88 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 89 | - participant->get_domain_id() | ||
| 90 | - ) | ||
| 91 | - ); | ||
| 78 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 92 | 79 | ||
| 93 | 80 | // TODO(jamoralp): Workaround for Fast-DDS bug #9977. Remove when fixed | |
| 94 | - const eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 81 | + eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 95 | 82 | datawriter->get_instance_handle(); | |
| 96 | - const eprosima::fastrtps::rtps::GUID_t datawriter_guid = | ||
| 83 | + eprosima::fastrtps::rtps::GUID_t datawriter_guid = | ||
| 97 | 84 | iHandle2GUID(instance_handle); | |
| 98 | 85 | graph_manager_->add_datawriter(datawriter_guid, participant, datawriter); | |
| 99 | 86 | graph_manager_->associate_entity( | |
@@ -108,23 +95,19 @@ bool Agent::create( | |||
| 108 | 95 | * Add DELETE_DATAWRITER callback. | |
| 109 | 96 | */ | |
| 110 | 97 | std::function<void ( | |
| 111 | - const eprosima::fastdds::dds::DomainParticipant *, | ||
| 112 | - const eprosima::fastdds::dds::DataWriter *)> on_delete_datawriter | ||
| 98 | + eprosima::fastdds::dds::DomainParticipant *, | ||
| 99 | + eprosima::fastdds::dds::DataWriter *)> on_delete_datawriter | ||
| 113 | 100 | ([&]( | |
| 114 | - const eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 115 | - const eprosima::fastdds::dds::DataWriter* datawriter) -> void | ||
| 101 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 102 | + eprosima::fastdds::dds::DataWriter* datawriter) -> void | ||
| 116 | 103 | { | |
| 117 | 104 | ||
| 118 | - auto graph_manager_ = | ||
| 119 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 120 | - participant->get_domain_id() | ||
| 121 | - ) | ||
| 122 | - ); | ||
| 105 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 123 | 106 | ||
| 124 | 107 | // TODO(jamoralp): Workaround for Fast-DDS bug #9977. Remove when fixed | |
| 125 | - const eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 108 | + eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 126 | 109 | datawriter->get_instance_handle(); | |
| 127 | - const eprosima::fastrtps::rtps::GUID_t datawriter_guid = | ||
| 110 | + eprosima::fastrtps::rtps::GUID_t datawriter_guid = | ||
| 128 | 111 | eprosima::fastrtps::rtps::iHandle2GUID(instance_handle); | |
| 129 | 112 | graph_manager_->remove_datawriter(datawriter_guid); | |
| 130 | 113 | }); | |
@@ -138,22 +121,18 @@ bool Agent::create( | |||
| 138 | 121 | * Add CREATE_DATAREADER callback. | |
| 139 | 122 | */ | |
| 140 | 123 | std::function<void ( | |
| 141 | - const eprosima::fastdds::dds::DomainParticipant *, | ||
| 142 | - const eprosima::fastdds::dds::DataReader*)> on_create_datareader | ||
| 124 | + eprosima::fastdds::dds::DomainParticipant *, | ||
| 125 | + eprosima::fastdds::dds::DataReader*)> on_create_datareader | ||
| 143 | 126 | ([&]( | |
| 144 | - const eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 145 | - const eprosima::fastdds::dds::DataReader* datareader) -> void | ||
| 127 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 128 | + eprosima::fastdds::dds::DataReader* datareader) -> void | ||
| 146 | 129 | { | |
| 147 | - auto graph_manager_ = | ||
| 148 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 149 | - participant->get_domain_id() | ||
| 150 | - ) | ||
| 151 | - ); | ||
| 130 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 152 | 131 | ||
| 153 | 132 | // TODO(jamoralp): Workaround for Fast-DDS bug #9977. Remove when fixed | |
| 154 | - const eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 133 | + eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 155 | 134 | datareader->get_instance_handle(); | |
| 156 | - const eprosima::fastrtps::rtps::GUID_t datareader_guid = | ||
| 135 | + eprosima::fastrtps::rtps::GUID_t datareader_guid = | ||
| 157 | 136 | eprosima::fastrtps::rtps::iHandle2GUID(instance_handle); | |
| 158 | 137 | graph_manager_->add_datareader(datareader_guid, participant, datareader); | |
| 159 | 138 | graph_manager_->associate_entity( | |
@@ -168,22 +147,18 @@ bool Agent::create( | |||
| 168 | 147 | * Add DELETE_DATAREADER callback. | |
| 169 | 148 | */ | |
| 170 | 149 | std::function<void ( | |
| 171 | - const eprosima::fastdds::dds::DomainParticipant *, | ||
| 172 | - const eprosima::fastdds::dds::DataReader *)> on_delete_datareader | ||
| 150 | + eprosima::fastdds::dds::DomainParticipant *, | ||
| 151 | + eprosima::fastdds::dds::DataReader *)> on_delete_datareader | ||
| 173 | 152 | ([&]( | |
| 174 | - const eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 175 | - const eprosima::fastdds::dds::DataReader* datareader) -> void | ||
| 153 | + eprosima::fastdds::dds::DomainParticipant* participant, | ||
| 154 | + eprosima::fastdds::dds::DataReader* datareader) -> void | ||
| 176 | 155 | { | |
| 177 | - auto graph_manager_ = | ||
| 178 | - find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t( | ||
| 179 | - participant->get_domain_id() | ||
| 180 | - ) | ||
| 181 | - ); | ||
| 156 | + auto graph_manager_ = find_or_create_graph_manager(participant->get_domain_id()); | ||
| 182 | 157 | ||
| 183 | 158 | // TODO(jamoralp): Workaround for Fast-DDS bug #9977. Remove when fixed | |
| 184 | - const eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 159 | + eprosima::fastrtps::rtps::InstanceHandle_t instance_handle = | ||
| 185 | 160 | datareader->get_instance_handle(); | |
| 186 | - const eprosima::fastrtps::rtps::GUID_t datareader_guid = | ||
| 161 | + eprosima::fastrtps::rtps::GUID_t datareader_guid = | ||
| 187 | 162 | eprosima::fastrtps::rtps::iHandle2GUID(instance_handle); | |
| 188 | 163 | graph_manager_->remove_datareader(datareader_guid); | |
| 189 | 164 | }); | |
@@ -204,16 +179,14 @@ void Agent::run() | |||
| 204 | 179 | ||
| 205 | 180 | std::shared_ptr<graph_manager::GraphManager> Agent::find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t domain_id) | |
| 206 | 181 | { | |
| 207 | - auto it = graph_manager_map_.find(domain_id); | ||
| 182 | + | ||
| 183 | + auto it = graph_manager_map_.find(domain_id); | ||
| 208 | 184 | ||
| 209 | 185 | if (it != graph_manager_map_.end()) { | |
| 210 | 186 | return it->second; | |
| 211 | 187 | }else{ | |
| 212 | 188 | return graph_manager_map_.insert( | |
| 213 | - std::pair< | ||
| 214 | - eprosima::fastdds::dds::DomainId_t, | ||
| 215 | - std::shared_ptr<graph_manager::GraphManager> | ||
| 216 | - >( | ||
| 189 | + std::make_pair( | ||
| 217 | 190 | domain_id, | |
| 218 | 191 | std::make_shared<graph_manager::GraphManager>(domain_id) | |
| 219 | 192 | ) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments