139 if (
_impl->_type ==
nullptr) {
140 std::cerr <<
"Invalid TypeSupport" << std::endl;
146 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
148 auto factory = efd::DomainParticipantFactory::get_instance();
149 _impl->_participant = factory->create_participant(0, pqos);
150 if (
_impl->_participant ==
nullptr) {
151 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
157 _impl->_type.register_type(
_impl->_participant);
161 efd::PublisherQos pubqos = efd::PUBLISHER_QOS_DEFAULT;
162 _impl->_publisher =
_impl->_participant->create_publisher(pubqos,
nullptr);
163 if (
_impl->_publisher ==
nullptr) {
164 std::cerr <<
"Failed to create Publisher" << std::endl;
170 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
171 const std::string base {
"rt/carla/" };
172 std::string topic_name = base;
176 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
177 if (
_impl->_topic ==
nullptr) {
178 std::cerr <<
"Failed to create Topic" << std::endl;
184 efd::DataWriterQos wqos = efd::DATAWRITER_QOS_DEFAULT;
185 wqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
187 _impl->_datawriter =
_impl->_publisher->create_datawriter(
_impl->_topic, wqos, listener);
188 if (
_impl->_datawriter ==
nullptr) {
189 std::cerr <<
"Failed to create DataWriter" << std::endl;
208 eprosima::fastrtps::rtps::InstanceHandle_t instance_handle;
213 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datawriter->write(&
_impl->_float, instance_handle);
215 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
219 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
221 std::cerr <<
"RETCODE_ERROR" << std::endl;
224 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
226 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
229 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
231 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
234 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
236 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
239 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
241 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
244 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
246 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
249 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
251 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
254 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
256 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
259 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
261 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
264 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
266 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
269 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
271 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
274 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
276 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
279 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
281 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
285 std::cerr <<
"UNKNOWN" << std::endl;