49 if (
_impl->_type ==
nullptr) {
50 std::cerr <<
"Invalid TypeSupport" << std::endl;
54 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
57 auto factory = efd::DomainParticipantFactory::get_instance();
59 _impl->_participant = factory->create_participant(0, pqos);
60 if (
_impl->_participant ==
nullptr) {
61 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
65 _impl->_type.register_type(
_impl->_participant);
67 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
69 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
70 if (
_impl->_publisher ==
nullptr) {
71 std::cerr <<
"Failed to create Publisher" << std::endl;
75 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
77 const std::string base {
"rt/carla/" };
78 std::string topic_name = base;
85 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
86 if (
_impl->_topic ==
nullptr) {
87 std::cerr <<
"Failed to create Topic" << std::endl;
91 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
93 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
97 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
98 if (
_impl->_datawriter ==
nullptr) {
99 std::cerr <<
"Failed to create DataWriter" << std::endl;
109 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
111 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_nav, instance_handle);
113 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
117 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
118 std::cerr <<
"RETCODE_ERROR" << std::endl;
121 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
122 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
125 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
126 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
129 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
130 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
133 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
134 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
137 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
138 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
141 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
142 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
145 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
146 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
149 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
150 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
153 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
154 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
157 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
158 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
161 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
162 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
165 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
166 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
170 std::cerr <<
"UNKNOWN return code: " << rcode() << std::endl;
182 std_msgs::msg::Header header;
183 header.stamp(std::move(time));
186 _impl->_nav.header(std::move(header));
187 _impl->_nav.latitude(*data++);
188 _impl->_nav.longitude(*data++);
189 _impl->_nav.altitude(*data++);