44 if (
_impl->_type ==
nullptr) {
45 std::cerr <<
"Invalid TypeSupport" << std::endl;
50 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
52 auto factory = efd::DomainParticipantFactory::get_instance();
53 _impl->_participant = factory->create_participant(0, pqos);
54 if (
_impl->_participant ==
nullptr) {
55 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
58 _impl->_type.register_type(
_impl->_participant);
62 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
63 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
64 if (
_impl->_publisher ==
nullptr) {
65 std::cerr <<
"Failed to create Publisher" << std::endl;
71 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
72 const std::string base {
"rt/carla/" };
73 std::string topic_name = base;
77 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
78 if (
_impl->_topic ==
nullptr) {
79 std::cerr <<
"Failed to create Topic" << std::endl;
85 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
86 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
88 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
89 if (
_impl->_datawriter ==
nullptr) {
90 std::cerr <<
"Failed to create DataWriter" << std::endl;
101 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
102 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_string, instance_handle);
103 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
109 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
110 std::cerr <<
"RETCODE_ERROR" << std::endl;
113 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
114 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
117 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
118 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
121 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
122 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
125 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
126 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
129 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
130 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
133 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
134 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
137 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
138 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
141 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
142 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
145 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
146 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
149 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
150 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
153 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
154 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
157 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
158 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
161 std::cerr <<
"UNKNOWN" << std::endl;