microRTPS: use FastRTPS version instead of FastRTPSGen version to generate conditional code

This commit is contained in:
TSC21
2020-03-10 19:05:59 +00:00
committed by Nuno Marques
parent c7d86b73d4
commit 7612879ffd
10 changed files with 76 additions and 90 deletions
+3 -3
View File
@@ -69,7 +69,7 @@ except AttributeError:
#include <fastrtps/Domain.h>
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
#include <fastrtps/utils/eClock.h>
@[end if]@
@@ -85,7 +85,7 @@ bool @(topic)_Publisher::init()
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
@[if 1.5 <= fastrtpsgen_version <= 1.7 or ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" or ros2_distro == "dashing"]@
@[if fastrtps_version <= 1.8]@
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
@[else]@
PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
@@ -149,7 +149,7 @@ void @(topic)_Publisher::PubListener::onPublicationMatched(Publisher* pub, Match
}
}
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
void @(topic)_Publisher::publish(@(package)::msg::dds_::@(topic)_* st)
@[ else]@
+3 -3
View File
@@ -68,7 +68,7 @@ except AttributeError:
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/publisher/PublisherListener.h>
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
#include "@(topic)_PubSubTypes.h"
@[else]@
#include "@(topic)PubSubTypes.h"
@@ -84,7 +84,7 @@ public:
virtual ~@(topic)_Publisher();
bool init();
void run();
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
void publish(@(package)::msg::dds_::@(topic)_* st);
@[ else]@
@@ -109,7 +109,7 @@ private:
void onPublicationMatched(Publisher* pub, MatchingInfo& info);
int n_matched;
} m_listener;
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
@(package)::msg::dds_::@(topic)_PubSubType @(topic)DataType;
@[ else]@
+4 -4
View File
@@ -20,7 +20,7 @@ from px_generate_uorb_topic_files import MsgScope # this is in Tools/
send_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
recv_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
package = package[0]
fastrtpsgen_version = fastrtpsgen_version[0]
fastrtps_version = fastrtps_version[0]
try:
ros2_distro = ros2_distro[0].decode("utf-8")
except AttributeError:
@@ -74,7 +74,7 @@ except AttributeError:
@[for topic in recv_topics]@
@[ if 1.5 <= fastrtpsgen_version <= 1.7]@
@[ if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_;
@[ else]@
@@ -89,7 +89,7 @@ using @(topic)_msg_t = @(topic);
@[ end if]@
@[end for]@
@[for topic in send_topics]@
@[ if 1.5 <= fastrtpsgen_version <= 1.7]@
@[ if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_;
@[ else]@
@@ -131,7 +131,7 @@ private:
@[end for]@
@[end if]@
@[if 1.5 <= fastrtpsgen_version <= 1.7 or not ros2_distro]@
@[if fastrtps_version <= 1.7 or not ros2_distro]@
template <class T>
uint8_t getMsgSysID(T* msg) { return msg->sys_id_(); }
+2 -2
View File
@@ -84,7 +84,7 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable* t_send
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; // MUST BE THE SAME AS IN THE PUBLISHER
@[if 1.5 <= fastrtpsgen_version <= 1.7 or ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" or ros2_distro == "dashing"]@
@[if fastrtps_version <= 1.8]@
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
@[else]@
PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
@@ -199,7 +199,7 @@ bool @(topic)_Subscriber::hasMsg()
return false;
}
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
@(package)::msg::dds_::@(topic)_ @(topic)_Subscriber::getMsg()
@[ else]@
+4 -4
View File
@@ -68,7 +68,7 @@ except AttributeError:
#include <fastrtps/fastrtps_fwd.h>
#include <fastrtps/subscriber/SubscriberListener.h>
#include <fastrtps/subscriber/SampleInfo.h>
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
#include "@(topic)_PubSubTypes.h"
@[else]@
#include "@(topic)PubSubTypes.h"
@@ -89,7 +89,7 @@ public:
bool init(uint8_t topic_ID, std::condition_variable* t_send_queue_cv, std::mutex* t_send_queue_mutex, std::queue<uint8_t>* t_send_queue);
void run();
bool hasMsg();
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
@(package)::msg::dds_::@(topic)_ getMsg();
@[ else]@
@@ -118,7 +118,7 @@ private:
SampleInfo_t m_info;
int n_matched;
int n_msg;
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
@(package)::msg::dds_::@(topic)_ msg;
@[ else]@
@@ -140,7 +140,7 @@ private:
std::mutex has_msg_mutex;
} m_listener;
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
@(package)::msg::dds_::@(topic)_PubSubType @(topic)DataType;
@[ else]@
@@ -17,7 +17,7 @@ from px_generate_uorb_topic_helper import * # this is in Tools/
from px_generate_uorb_topic_files import MsgScope # this is in Tools/
package = package[0]
fastrtpsgen_version = fastrtpsgen_version[0]
fastrtps_version = fastrtps_version[0]
try:
ros2_distro = ros2_distro[0].decode("utf-8")
except AttributeError:
+2 -2
View File
@@ -17,7 +17,7 @@ from px_generate_uorb_topic_helper import * # this is in Tools/
from px_generate_uorb_topic_files import MsgScope # this is in Tools/
package = package[0]
fastrtpsgen_version = fastrtpsgen_version[0]
fastrtps_version = fastrtps_version[0]
try:
ros2_distro = ros2_distro[0].decode("utf-8")
except AttributeError:
@@ -86,7 +86,7 @@ static constexpr int64_t TRIGGER_RESET_THRESHOLD_NS = 100ll * 1000ll * 1000ll;
static constexpr int REQUEST_RESET_COUNTER_THRESHOLD = 5;
@# Sets the timesync DDS type according to the FastRTPS and ROS2 version
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
@[ if ros2_distro]@
using timesync_msg_t = @(package)::msg::dds_::Timesync_;
@[ else]@
+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)):
continue
builtin_type = str(field.base_type).replace('px4/', '')
if 1.5 <= fastrtpsgen_version <= 1.7:
if fastrtps_version <= 1.7:
include_directive = '#include "%s_.idl"' % builtin_type
else:
include_directive = '#include "%s.idl"' % builtin_type
@@ -77,12 +77,12 @@ def get_idl_type_name(field_type):
def add_msg_field(field):
if (not field.is_header):
if field.is_array:
if 1.5 <= fastrtpsgen_version <= 1.7:
if fastrtps_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))
else:
print(' {0}__{1}_array_{2} {3};'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
else:
if 1.5 <= fastrtpsgen_version <= 1.7:
if fastrtps_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)
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)
@@ -96,7 +96,7 @@ def add_msg_fields():
def add_array_typedefs():
for field in spec.parsed_fields():
if not field.is_header and field.is_array:
if 1.5 <= fastrtpsgen_version <= 1.7:
if fastrtps_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)
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)
@@ -127,14 +127,14 @@ def add_msg_constants():
@add_msg_constants()
@# Array types
@add_array_typedefs()
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
struct @(topic)_
@[else]@
struct @(topic)
@[end if]@
{
@add_msg_fields()
@[if 1.5 <= fastrtpsgen_version <= 1.7]@
@[if fastrtps_version <= 1.7]@
}; // struct @(topic)_
#pragma keylist @(topic)_
+37 -51
View File
@@ -209,16 +209,16 @@ else:
if args.fastrtpsgen is None or args.fastrtpsgen == '':
# Assume fastrtpsgen is in PATH
fastrtpsgen_path = 'fastrtpsgen'
for dirname in os.environ['PATH'].split(':') :
for dirname in os.environ['PATH'].split(':'):
candidate = os.path.join(dirname, 'fastrtpsgen')
if os.path.isfile(candidate) :
if os.path.isfile(candidate):
fastrtpsgen_path = candidate
else:
# Path to fastrtpsgen is explicitly specified
if os.path.isdir(args.fastrtpsgen) :
if os.path.isdir(args.fastrtpsgen):
fastrtpsgen_path = os.path.join(
os.path.abspath(args.fastrtpsgen), 'fastrtpsgen')
else :
else:
fastrtpsgen_path = args.fastrtpsgen
fastrtpsgen_include = args.fastrtpsgen_include
@@ -227,27 +227,13 @@ if fastrtpsgen_include is not None and fastrtpsgen_include != '':
os.path.abspath(
args.fastrtpsgen_include) + " "
# get FastRTPSGen version
# Note: since Fast-RTPS 1.8.x release, FastRTPSGen is now a separated
# repository and not included in the Fast-RTPS project.
# The starting version since this separation is 1.0.0, which doesn't
# follow the Fast-RTPS version convention
fastrtpsgen_version = 0.0
if(os.path.exists(fastrtpsgen_path)):
try:
fastrtpsgen_version_out = subprocess.check_output(
[fastrtpsgen_path, "-version"]).strip()[-5:-2]
except OSError:
raise
try:
fastrtpsgen_version = float(fastrtpsgen_version_out)
except ValueError:
print("'fastrtpsgen -version' returned None. Hardsetting version to 1.0")
fastrtpsgen_version = 1.0
else:
raise Exception(
"FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag")
# get FastRTPS version (major.minor, since patch is not relevant at this stage)
fastrtps_version = ""
try:
fastrtps_version = float(subprocess.check_output(
"ldconfig -v | grep libfastrtps | tail -c 6", shell=True).decode("utf-8").strip()[-5:-2])
except ValueError:
print("No valid version found to FasRTPS. Make sure it is installed.")
# get ROS 2 version, if exists
ros2_distro = ""
@@ -322,21 +308,21 @@ uRTPS_SUBSCRIBER_H_TEMPL_FILE = 'Subscriber.h.em'
def generate_agent(out_dir):
global fastrtpsgen_version
global fastrtps_version
if classifier.msgs_to_send:
for msg_file in classifier.msgs_to_send:
if gen_idl:
if out_dir != agent_out_dir:
px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", os.path.join(out_dir, "/idl"), urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
else:
px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", idl_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
if classifier.alias_msgs_to_send:
for msg_file in classifier.alias_msgs_to_send:
@@ -345,28 +331,28 @@ def generate_agent(out_dir):
if gen_idl:
if out_dir != agent_out_dir:
px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, os.path.join(out_dir, "/idl"), urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
else:
px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, idl_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
if classifier.msgs_to_receive:
for msg_file in classifier.msgs_to_receive:
if gen_idl:
if out_dir != agent_out_dir:
px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", os.path.join(out_dir, "/idl"), urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
else:
px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", idl_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
if classifier.alias_msgs_to_receive:
for msg_file in classifier.alias_msgs_to_receive:
@@ -375,28 +361,28 @@ def generate_agent(out_dir):
if gen_idl:
if out_dir != agent_out_dir:
px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, os.path.join(out_dir, "/idl"), urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
else:
px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, idl_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtpsgen_version, ros2_distro, classifier.msg_id_map)
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_id_map)
px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_AGENT_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_AGENT_TEMPL_FILE)
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_TIMESYNC_CPP_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_TIMESYNC_CPP_TEMPL_FILE)
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_TIMESYNC_H_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_TIMESYNC_H_TEMPL_FILE)
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_AGENT_TOPICS_H_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_AGENT_TOPICS_H_TEMPL_FILE)
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_AGENT_TOPICS_SRC_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_AGENT_TOPICS_SRC_TEMPL_FILE)
if cmakelists:
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_AGENT_CMAKELISTS_TEMPL_FILE)
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_AGENT_CMAKELISTS_TEMPL_FILE)
# Final steps to install agent
mkdir_p(os.path.join(out_dir, "fastrtpsgen"))
@@ -407,7 +393,7 @@ def generate_agent(out_dir):
for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")):
try:
ret = subprocess.check_call(fastrtpsgen_path + " -d " + out_dir +
"/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True)
"/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True)
except OSError:
raise
@@ -452,7 +438,7 @@ def mkdir_p(dirpath):
def generate_client(out_dir):
global fastrtpsgen_version
global fastrtps_version
# Rename work in the default path
if default_client_out != out_dir:
@@ -467,7 +453,7 @@ def generate_client(out_dir):
os.rename(def_file, def_file.replace(".h", ".h_"))
px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir,
out_dir, uorb_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtpsgen_version, ros2_distro, uRTPS_CLIENT_TEMPL_FILE)
out_dir, uorb_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_version, ros2_distro, uRTPS_CLIENT_TEMPL_FILE)
# Final steps to install client
cp_wildcard(os.path.join(urtps_templates_dir,
+14 -14
View File
@@ -167,7 +167,7 @@ def generate_output_from_file(format_idx, filename, outputdir, package, template
return generate_by_template(output_file, template_file, em_globals)
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtpsgen_version, ros2_distro, ids):
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtps_version, ros2_distro, ids):
"""
Generates an .idl from .msg file
"""
@@ -175,11 +175,11 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
if (alias != ""):
em_globals = get_em_globals(
msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
spec_short_name = alias
else:
em_globals = get_em_globals(
msg, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
msg, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
spec_short_name = em_globals["spec"].short_name
# Make sure output directory exists:
@@ -187,7 +187,7 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
os.makedirs(outputdir)
template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE)
if 1.5 <= fastrtpsgen_version <= 1.7:
if 1.5 <= fastrtps_version <= 1.7:
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
"msg.idl.em", str(spec_short_name + "_.idl")))
else:
@@ -198,7 +198,7 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filename_receive_msgs, filename_alias_receive_msgs,
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtpsgen_version, ros2_distro, template_name):
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtps_version, ros2_distro, template_name):
"""
Generates source file by msg content
"""
@@ -216,19 +216,19 @@ def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filenam
em_globals_list = []
if send_msgs:
em_globals_list.extend([get_em_globals(
f, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.SEND) for f in send_msgs])
f, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.SEND) for f in send_msgs])
if alias_send_msgs:
em_globals_list.extend([get_em_globals(
f[0], f[1], package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
f[0], f[1], package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
if receive_msgs:
em_globals_list.extend([get_em_globals(
f, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.RECEIVE) for f in receive_msgs])
f, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.RECEIVE) for f in receive_msgs])
if alias_receive_msgs:
em_globals_list.extend([get_em_globals(
f[0], f[1], package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
f[0], f[1], package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
merged_em_globals = merge_em_globals_list(em_globals_list)
@@ -243,7 +243,7 @@ def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filenam
return generate_by_template(output_file, template_file, merged_em_globals)
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtpsgen_version, ros2_distro, template_name):
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtps_version, ros2_distro, template_name):
"""
Generates a sources and headers from .msg file
"""
@@ -251,11 +251,11 @@ def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, pa
if (alias):
em_globals = get_em_globals(
msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
spec_short_name = alias
else:
em_globals = get_em_globals(
msg, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
msg, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
spec_short_name = em_globals["spec"].short_name
# Make sure output directory exists:
@@ -269,7 +269,7 @@ def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, pa
return generate_by_template(output_file, template_file, em_globals)
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, scope):
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, scope):
"""
Generates em globals dictionary
"""
@@ -298,7 +298,7 @@ def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtpsgen_v
"scope": scope,
"package": package,
"alias": alias,
"fastrtpsgen_version": fastrtpsgen_version,
"fastrtps_version": fastrtps_version,
"ros2_distro": ros2_distro
}