48 if (
_impl->_type ==
nullptr) {
49 std::cerr <<
"Invalid TypeSupport" << std::endl;
53 efd::DomainParticipantQos pqos = efd::PARTICIPANT_QOS_DEFAULT;
55 auto factory = efd::DomainParticipantFactory::get_instance();
56 _impl->_participant = factory->create_participant(0, pqos);
57 if (
_impl->_participant ==
nullptr) {
58 std::cerr <<
"Failed to create DomainParticipant" << std::endl;
61 _impl->_type.register_type(
_impl->_participant);
63 efd::SubscriberQos subqos = efd::SUBSCRIBER_QOS_DEFAULT;
64 _impl->_subscriber =
_impl->_participant->create_subscriber(subqos,
nullptr);
65 if (
_impl->_subscriber ==
nullptr) {
66 std::cerr <<
"Failed to create Subscriber" << std::endl;
70 efd::TopicQos tqos = efd::TOPIC_QOS_DEFAULT;
71 const std::string base {
"rt/carla/" };
72 const std::string publisher_type {
"/vehicle_control_cmd"};
73 std::string topic_name = base;
77 topic_name += publisher_type;
78 _impl->_topic =
_impl->_participant->create_topic(topic_name,
_impl->_type->getName(), tqos);
79 if (
_impl->_topic ==
nullptr) {
80 std::cerr <<
"Failed to create Topic" << std::endl;
84 efd::DataReaderQos rqos = efd::DATAREADER_QOS_DEFAULT;
86 _impl->_datareader =
_impl->_subscriber->create_datareader(
_impl->_topic, rqos, listener);
87 if (
_impl->_datareader ==
nullptr) {
88 std::cerr <<
"Failed to create DataReader" << std::endl;
96 eprosima::fastrtps::types::ReturnCode_t rcode =
_impl->_datareader->take_next_sample(&
_impl->_event, &info);
97 if (rcode == erc::ReturnCodeValue::RETCODE_OK) {
100 if (rcode == erc::ReturnCodeValue::RETCODE_ERROR) {
101 std::cerr <<
"RETCODE_ERROR" << std::endl;
104 if (rcode == erc::ReturnCodeValue::RETCODE_UNSUPPORTED) {
105 std::cerr <<
"RETCODE_UNSUPPORTED" << std::endl;
108 if (rcode == erc::ReturnCodeValue::RETCODE_BAD_PARAMETER) {
109 std::cerr <<
"RETCODE_BAD_PARAMETER" << std::endl;
112 if (rcode == erc::ReturnCodeValue::RETCODE_PRECONDITION_NOT_MET) {
113 std::cerr <<
"RETCODE_PRECONDITION_NOT_MET" << std::endl;
116 if (rcode == erc::ReturnCodeValue::RETCODE_OUT_OF_RESOURCES) {
117 std::cerr <<
"RETCODE_OUT_OF_RESOURCES" << std::endl;
120 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ENABLED) {
121 std::cerr <<
"RETCODE_NOT_ENABLED" << std::endl;
124 if (rcode == erc::ReturnCodeValue::RETCODE_IMMUTABLE_POLICY) {
125 std::cerr <<
"RETCODE_IMMUTABLE_POLICY" << std::endl;
128 if (rcode == erc::ReturnCodeValue::RETCODE_INCONSISTENT_POLICY) {
129 std::cerr <<
"RETCODE_INCONSISTENT_POLICY" << std::endl;
132 if (rcode == erc::ReturnCodeValue::RETCODE_ALREADY_DELETED) {
133 std::cerr <<
"RETCODE_ALREADY_DELETED" << std::endl;
136 if (rcode == erc::ReturnCodeValue::RETCODE_TIMEOUT) {
137 std::cerr <<
"RETCODE_TIMEOUT" << std::endl;
140 if (rcode == erc::ReturnCodeValue::RETCODE_NO_DATA) {
141 std::cerr <<
"RETCODE_NO_DATA" << std::endl;
144 if (rcode == erc::ReturnCodeValue::RETCODE_ILLEGAL_OPERATION) {
145 std::cerr <<
"RETCODE_ILLEGAL_OPERATION" << std::endl;
148 if (rcode == erc::ReturnCodeValue::RETCODE_NOT_ALLOWED_BY_SECURITY) {
149 std::cerr <<
"RETCODE_NOT_ALLOWED_BY_SECURITY" << std::endl;
152 std::cerr <<
"UNKNOWN" << std::endl;