50 if (
_impl->_type ==
nullptr) {
51 std::cerr <<
"Invalid TypeSupport" << std::endl;
55 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
58 auto factory = efd::DomainParticipantFactory::get_instance();
60 _impl->_participant = factory->create_participant(0, pqos);
61 if (
_impl->_participant ==
nullptr) {
62 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
66 _impl->_type.register_type(
_impl->_participant);
68 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
70 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
71 if (
_impl->_publisher ==
nullptr) {
72 std::cerr <<
"Failed to create Publisher" << std::endl;
76 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
77 const std::string base {
"rt/carla/" };
78 std::string topic_name = base;
84 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
85 if (
_impl->_topic ==
nullptr) {
86 std::cerr <<
"Failed to create Topic" << std::endl;
90 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
91 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
93 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
94 if (
_impl->_datawriter ==
nullptr) {
95 std::cerr <<
"Failed to create DataWriter" << std::endl;
106 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
108 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_event, instance_handle);
110 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
114 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
115 std::cerr <<
"RETCODE_ERROR" << std::endl;
119 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
120 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
124 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
125 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;
134 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
135 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
139 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
140 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
144 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
145 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
149 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
150 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
154 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
155 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
159 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
160 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
164 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
165 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
169 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
170 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
174 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
175 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
179 std::cerr <<
"UNKNOWN" << std::endl;
188 std_msgs::msg::Header header;
189 header.stamp(std::move(time));
192 _impl->_event.header(std::move(header));
193 _impl->_event.crossed_lane_markings({data[0], data[1], data[2]});