43 if (
_impl->_type ==
nullptr) {
44 std::cerr <<
"Invalid TypeSupport" << std::endl;
47 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
49 auto factory = efd::DomainParticipantFactory::get_instance();
50 _impl->_participant = factory->create_participant(0, pqos);
51 if (
_impl->_participant ==
nullptr) {
52 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
55 _impl->_type.register_type(
_impl->_participant);
57 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
58 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
59 if (
_impl->_publisher ==
nullptr) {
60 std::cerr <<
"Failed to create Publisher" << std::endl;
64 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
65 const std::string base {
"rt/carla/" };
66 std::string topic_name = base;
70 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
71 if (
_impl->_topic ==
nullptr) {
72 std::cerr <<
"Failed to create Topic" << std::endl;
76 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
77 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
79 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
80 if (
_impl->_datawriter ==
nullptr) {
81 std::cerr <<
"Failed to create DataWriter" << std::endl;
89 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
90 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_float, instance_handle);
91 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
94 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
95 std::cerr <<
"RETCODE_ERROR" << std::endl;
98 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
99 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
102 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
103 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
106 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
107 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
110 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
111 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
114 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
115 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
118 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
119 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
122 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
123 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
126 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
127 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
130 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
131 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
134 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
135 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
138 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
139 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
142 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
143 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
146 std::cerr <<
"UNKNOWN" << std::endl;