43 if (
_impl->_type ==
nullptr) {
44 std::cerr <<
"Invalid TypeSupport" << std::endl;
48 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
50 auto factory = efd::DomainParticipantFactory::get_instance();
51 _impl->_participant = factory->create_participant(0, pqos);
52 if (
_impl->_participant ==
nullptr) {
53 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
56 _impl->_type.register_type(
_impl->_participant);
58 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
59 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
60 if (
_impl->_publisher ==
nullptr) {
61 std::cerr <<
"Failed to create Publisher" << std::endl;
65 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
66 const std::string base {
"rt/carla/" };
67 std::string topic_name = base;
71 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
72 if (
_impl->_topic ==
nullptr) {
73 std::cerr <<
"Failed to create Topic" << std::endl;
77 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
78 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
80 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
81 if (
_impl->_datawriter ==
nullptr) {
82 std::cerr <<
"Failed to create DataWriter" << std::endl;
90 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
91 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_event, instance_handle);
92 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
95 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
96 std::cerr <<
"RETCODE_ERROR" << std::endl;
99 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
100 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
103 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
104 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
107 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
108 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
111 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
112 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
115 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
116 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
119 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
120 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
123 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
124 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
127 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
128 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
131 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
132 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
135 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
136 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
139 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
140 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
143 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
144 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
147 std::cerr <<
"UNKNOWN" << std::endl;