fix FastRTPSGen version verification

This commit is contained in:
TSC21
2019-10-04 16:56:03 +01:00
committed by Nuno Marques
parent 9c00f3de02
commit e7b0384f05
7 changed files with 26 additions and 26 deletions
+6 -6
View File
@@ -64,7 +64,7 @@ topic = alias if alias else spec.short_name
#include <fastrtps/Domain.h> #include <fastrtps/Domain.h>
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
#include <fastrtps/utils/eClock.h> #include <fastrtps/utils/eClock.h>
@[end if]@ @[end if]@
@@ -80,7 +80,7 @@ bool @(topic)_Publisher::init()
// Create RTPSParticipant // Create RTPSParticipant
ParticipantAttributes PParam; ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; PParam.rtps.builtin.domainId = 0;
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
PParam.rtps.builtin.leaseDuration = c_TimeInfinite; PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
@[else]@ @[else]@
PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
@@ -97,7 +97,7 @@ bool @(topic)_Publisher::init()
PublisherAttributes Wparam; PublisherAttributes Wparam;
Wparam.topic.topicKind = NO_KEY; Wparam.topic.topicKind = NO_KEY;
Wparam.topic.topicDataType = myType.getName(); //This type MUST be registered Wparam.topic.topicDataType = myType.getName(); //This type MUST be registered
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
Wparam.topic.topicName = "@(topic)_PubSubTopic"; Wparam.topic.topicName = "@(topic)_PubSubTopic";
@[else]@ @[else]@
Wparam.topic.topicName = "@(topic)PubSubTopic"; Wparam.topic.topicName = "@(topic)PubSubTopic";
@@ -130,7 +130,7 @@ void @(topic)_Publisher::run()
{ {
while(m_listener.n_matched == 0) while(m_listener.n_matched == 0)
{ {
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
eClock::my_sleep(250); // Sleep 250 ms; eClock::my_sleep(250); // Sleep 250 ms;
@[else]@ @[else]@
std::this_thread::sleep_for(std::chrono::milliseconds(250)); // Sleep 250 ms std::this_thread::sleep_for(std::chrono::milliseconds(250)); // Sleep 250 ms
@@ -138,7 +138,7 @@ void @(topic)_Publisher::run()
} }
// Publication code // Publication code
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_ st; @(topic)_ st;
@[else]@ @[else]@
@(topic) st; @(topic) st;
@@ -167,7 +167,7 @@ void @(topic)_Publisher::run()
}while(std::cin >> ch); }while(std::cin >> ch);
} }
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
void @(topic)_Publisher::publish(@(topic)_* st) void @(topic)_Publisher::publish(@(topic)_* st)
@[else]@ @[else]@
void @(topic)_Publisher::publish(@(topic)* st) void @(topic)_Publisher::publish(@(topic)* st)
+3 -3
View File
@@ -64,7 +64,7 @@ topic = alias if alias else spec.short_name
#include <fastrtps/fastrtps_fwd.h> #include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/publisher/PublisherListener.h> #include <fastrtps/publisher/PublisherListener.h>
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
#include "@(topic)_PubSubTypes.h" #include "@(topic)_PubSubTypes.h"
@[else]@ @[else]@
#include "@(topic)PubSubTypes.h" #include "@(topic)PubSubTypes.h"
@@ -80,7 +80,7 @@ public:
virtual ~@(topic)_Publisher(); virtual ~@(topic)_Publisher();
bool init(); bool init();
void run(); void run();
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
void publish(@(topic)_* st); void publish(@(topic)_* st);
@[else]@ @[else]@
void publish(@(topic)* st); void publish(@(topic)* st);
@@ -97,7 +97,7 @@ private:
void onPublicationMatched(Publisher* pub, MatchingInfo& info); void onPublicationMatched(Publisher* pub, MatchingInfo& info);
int n_matched; int n_matched;
} m_listener; } m_listener;
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_PubSubType myType; @(topic)_PubSubType myType;
@[else]@ @[else]@
@(topic)PubSubType myType; @(topic)PubSubType myType;
+2 -2
View File
@@ -92,7 +92,7 @@ void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
@[for topic in send_topics]@ @[for topic in send_topics]@
case @(rtps_message_id(ids, topic)): // @(topic) case @(rtps_message_id(ids, topic)): // @(topic)
{ {
@[ if 1.5 < fastrtpsgen_version <= 1.7]@ @[ if 1.5 <= fastrtpsgen_version[0] <= 1.7]@
@(topic)_ st; @(topic)_ st;
@[ else]@ @[ else]@
@(topic) st; @(topic) st;
@@ -149,7 +149,7 @@ bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
case @(rtps_message_id(ids, topic)): // @(topic) case @(rtps_message_id(ids, topic)): // @(topic)
if (_@(topic)_sub.hasMsg()) if (_@(topic)_sub.hasMsg())
{ {
@[ if 1.5 < fastrtpsgen_version <= 1.7]@ @[ if 1.5 <= fastrtpsgen_version[0] <= 1.7]@
@(topic)_ msg = _@(topic)_sub.getMsg(); @(topic)_ msg = _@(topic)_sub.getMsg();
@[ else]@ @[ else]@
@(topic) msg = _@(topic)_sub.getMsg(); @(topic) msg = _@(topic)_sub.getMsg();
+4 -4
View File
@@ -75,7 +75,7 @@ bool @(topic)_Subscriber::init()
// Create RTPSParticipant // Create RTPSParticipant
ParticipantAttributes PParam; ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; // MUST BE THE SAME AS IN THE PUBLISHER PParam.rtps.builtin.domainId = 0; // MUST BE THE SAME AS IN THE PUBLISHER
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
PParam.rtps.builtin.leaseDuration = c_TimeInfinite; PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
@[else]@ @[else]@
PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
@@ -92,7 +92,7 @@ bool @(topic)_Subscriber::init()
SubscriberAttributes Rparam; SubscriberAttributes Rparam;
Rparam.topic.topicKind = NO_KEY; Rparam.topic.topicKind = NO_KEY;
Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
Rparam.topic.topicName = "@(topic)_PubSubTopic"; Rparam.topic.topicName = "@(topic)_PubSubTopic";
@[else]@ @[else]@
Rparam.topic.topicName = "@(topic)PubSubTopic"; Rparam.topic.topicName = "@(topic)PubSubTopic";
@@ -125,7 +125,7 @@ void @(topic)_Subscriber::SubListener::onSubscriptionMatched(Subscriber* sub, Ma
void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber* sub) void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber* sub)
{ {
// Take data // Take data
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_ st; @(topic)_ st;
@[else]@ @[else]@
@(topic) st; @(topic) st;
@@ -156,7 +156,7 @@ bool @(topic)_Subscriber::hasMsg()
return m_listener.has_msg; return m_listener.has_msg;
} }
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_ @(topic)_Subscriber::getMsg() @(topic)_ @(topic)_Subscriber::getMsg()
@[else]@ @[else]@
@(topic) @(topic)_Subscriber::getMsg() @(topic) @(topic)_Subscriber::getMsg()
+4 -4
View File
@@ -64,7 +64,7 @@ topic = alias if alias else spec.short_name
#include <fastrtps/fastrtps_fwd.h> #include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/subscriber/SubscriberListener.h> #include <fastrtps/subscriber/SubscriberListener.h>
#include <fastrtps/subscriber/SampleInfo.h> #include <fastrtps/subscriber/SampleInfo.h>
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
#include "@(topic)_PubSubTypes.h" #include "@(topic)_PubSubTypes.h"
@[else]@ @[else]@
#include "@(topic)PubSubTypes.h" #include "@(topic)PubSubTypes.h"
@@ -81,7 +81,7 @@ public:
bool init(); bool init();
void run(); void run();
bool hasMsg(); bool hasMsg();
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_ getMsg(); @(topic)_ getMsg();
@[else]@ @[else]@
@(topic) getMsg(); @(topic) getMsg();
@@ -100,7 +100,7 @@ private:
SampleInfo_t m_info; SampleInfo_t m_info;
int n_matched; int n_matched;
int n_msg; int n_msg;
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_ msg; @(topic)_ msg;
@[else]@ @[else]@
@(topic) msg; @(topic) msg;
@@ -108,7 +108,7 @@ private:
bool has_msg = false; bool has_msg = false;
} m_listener; } m_listener;
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
@(topic)_PubSubType myType; @(topic)_PubSubType myType;
@[else]@ @[else]@
@(topic)PubSubType myType; @(topic)PubSubType myType;
+6 -6
View File
@@ -57,7 +57,7 @@ def get_include_directives(spec):
if genmsg.msgs.is_valid_constant_type(genmsg.msgs.bare_msg_type(field.type)): if genmsg.msgs.is_valid_constant_type(genmsg.msgs.bare_msg_type(field.type)):
continue continue
builtin_type = str(field.base_type).replace('px4/', '') builtin_type = str(field.base_type).replace('px4/', '')
if 1.5 < fastrtpsgen_version <= 1.7: if 1.5 <= fastrtpsgen_version <= 1.7:
include_directive = '#include "%s_.idl"' % builtin_type include_directive = '#include "%s_.idl"' % builtin_type
else: else:
include_directive = '#include "%s.idl"' % builtin_type include_directive = '#include "%s.idl"' % builtin_type
@@ -77,12 +77,12 @@ def get_idl_type_name(field_type):
def add_msg_field(field): def add_msg_field(field):
if (not field.is_header): if (not field.is_header):
if field.is_array: if field.is_array:
if 1.5 < fastrtpsgen_version <= 1.7: if 1.5 <= fastrtpsgen_version <= 1.7:
print(' {0}__{1}_array_{2} {3}_;'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name)) print(' {0}__{1}_array_{2} {3}_;'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
else: else:
print(' {0}__{1}_array_{2} {3};'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name)) print(' {0}__{1}_array_{2} {3};'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
else: else:
if 1.5 < fastrtpsgen_version <= 1.7: if 1.5 <= fastrtpsgen_version <= 1.7:
base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type) base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
else: else:
base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type) base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
@@ -96,7 +96,7 @@ def add_msg_fields():
def add_array_typedefs(): def add_array_typedefs():
for field in spec.parsed_fields(): for field in spec.parsed_fields():
if not field.is_header and field.is_array: if not field.is_header and field.is_array:
if 1.5 < fastrtpsgen_version <= 1.7: if 1.5 <= fastrtpsgen_version <= 1.7:
base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type) base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
else: else:
base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type) base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
@@ -127,14 +127,14 @@ def add_msg_constants():
@add_msg_constants() @add_msg_constants()
@# Array types @# Array types
@add_array_typedefs() @add_array_typedefs()
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
struct @(topic)_ struct @(topic)_
@[else]@ @[else]@
struct @(topic) struct @(topic)
@[end if]@ @[end if]@
{ {
@add_msg_fields() @add_msg_fields()
@[if 1.5 < fastrtpsgen_version <= 1.7]@ @[if 1.5 <= fastrtpsgen_version <= 1.7]@
}; // struct @(topic)_ }; // struct @(topic)_
#pragma keylist @(topic)_ #pragma keylist @(topic)_
+1 -1
View File
@@ -190,7 +190,7 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
os.makedirs(outputdir) os.makedirs(outputdir)
template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE) template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE)
if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal": if 1.5 <= fastrtpsgen_version <= 1.7:
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace( output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
"msg.idl.em", str(spec_short_name + "_.idl"))) "msg.idl.em", str(spec_short_name + "_.idl")))
else: else: