95 if (
_impl->_type ==
nullptr) {
96 std::cerr <<
"Invalid TypeSupport" << std::endl;
103 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
109 auto factory = efd::DomainParticipantFactory::get_instance();
110 _impl->_participant = factory->create_participant(0, pqos);
111 if (
_impl->_participant ==
nullptr) {
112 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
119 _impl->_type.register_type(
_impl->_participant);
124 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
129 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
130 if (
_impl->_publisher ==
nullptr) {
131 std::cerr <<
"Failed to create Publisher" << std::endl;
138 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
143 const std::string base {
"rt/carla/" };
144 std::string topic_name = base;
152 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
153 if (
_impl->_topic ==
nullptr) {
154 std::cerr <<
"Failed to create Topic" << std::endl;
161 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
162 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
168 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
169 if (
_impl->_datawriter ==
nullptr) {
170 std::cerr <<
"Failed to create DataWriter" << std::endl;
194 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
196 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_event, instance_handle);
198 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
203 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
204 std::cerr <<
"RETCODE_ERROR" << std::endl;
207 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
208 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
211 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
212 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
215 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
216 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
219 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
220 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
223 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
224 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
227 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
228 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
231 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
232 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
235 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
236 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
239 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
240 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
243 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
244 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
247 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
248 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
251 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
252 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
256 std::cerr <<
"UNKNOWN" << std::endl;
273 std::vector<float> vector_data ;
274 SetData(seconds, nanoseconds, actor_id, {x, y, z});
292 std_msgs::msg::Header header;
293 header.stamp(std::move(time));
300 _impl->_event.header(std::move(header));
301 _impl->_event.other_actor_id(actor_id);
302 _impl->_event.normal_impulse(impulse);