forked from Archive/PX4-Autopilot
first push on supporting ROS2 Dashing and IDL 4.2
This commit is contained in:
parent
f885d2274a
commit
278d2fd21f
|
@ -5,4 +5,3 @@ uint64 timestamp # time since system start (microseconds)
|
|||
|
||||
float32[2] original_setpoint # velocities demanded
|
||||
float32[2] adapted_setpoint # velocities allowed
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Optical flow in XYZ body frame in SI units.
|
||||
# @see http://en.wikipedia.org/wiki/International_System_of_Units
|
||||
# http://en.wikipedia.org/wiki/International_System_of_Units
|
||||
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#
|
||||
# Sensor readings in SI-unit form.
|
||||
#
|
||||
# These fields are scaled and offset-compensated where possible and do not
|
||||
# change with board revisions and sensor updates.
|
||||
#
|
||||
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
|
|
|
@ -125,7 +125,11 @@ void @(topic)_Publisher::run()
|
|||
|
||||
// Publication code
|
||||
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ st;
|
||||
@[else]@
|
||||
@(topic) st;
|
||||
@[end if]@
|
||||
|
||||
/* Initialize your structure here */
|
||||
|
||||
|
@ -150,7 +154,11 @@ void @(topic)_Publisher::run()
|
|||
}while(std::cin >> ch);
|
||||
}
|
||||
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
void @(topic)_Publisher::publish(@(topic)_* st)
|
||||
@[else]@
|
||||
void @(topic)_Publisher::publish(@(topic)* st)
|
||||
@[end if]@
|
||||
{
|
||||
mp_publisher->write(st);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,11 @@ topic = alias if alias else spec.short_name
|
|||
#include <fastrtps/fastrtps_fwd.h>
|
||||
#include <fastrtps/publisher/PublisherListener.h>
|
||||
|
||||
@[if float(fastrtps_version) < 1.9]@
|
||||
#include "@(topic)_PubSubTypes.h"
|
||||
@[else]@
|
||||
#include "@(topic)PubSubTypes.h"
|
||||
@[end if]@
|
||||
|
||||
using namespace eprosima::fastrtps;
|
||||
using namespace eprosima::fastrtps::rtps;
|
||||
|
@ -76,7 +80,11 @@ public:
|
|||
virtual ~@(topic)_Publisher();
|
||||
bool init();
|
||||
void run();
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
void publish(@(topic)_* st);
|
||||
@[else]@
|
||||
void publish(@(topic)* st);
|
||||
@[end if]@
|
||||
private:
|
||||
Participant *mp_participant;
|
||||
Publisher *mp_publisher;
|
||||
|
@ -89,7 +97,11 @@ private:
|
|||
void onPublicationMatched(Publisher* pub, MatchingInfo& info);
|
||||
int n_matched;
|
||||
} m_listener;
|
||||
@[if float(fastrtps_version) < 1.9]@
|
||||
@(topic)_PubSubType myType;
|
||||
@[else]@
|
||||
@(topic)PubSubType myType;
|
||||
@[end if]@
|
||||
};
|
||||
|
||||
#endif // _@(topic)__PUBLISHER_H_
|
||||
|
|
|
@ -92,7 +92,11 @@ void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
|
|||
@[for topic in send_topics]@
|
||||
case @(rtps_message_id(ids, topic)): // @(topic)
|
||||
{
|
||||
@[ if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ st;
|
||||
@[ else]@
|
||||
@(topic) st;
|
||||
@[ end if]@
|
||||
eprosima::fastcdr::FastBuffer cdrbuffer(data_buffer, len);
|
||||
eprosima::fastcdr::Cdr cdr_des(cdrbuffer);
|
||||
st.deserialize(cdr_des);
|
||||
|
@ -145,7 +149,11 @@ bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
|
|||
case @(rtps_message_id(ids, topic)): // @(topic)
|
||||
if (_@(topic)_sub.hasMsg())
|
||||
{
|
||||
@[ if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ msg = _@(topic)_sub.getMsg();
|
||||
@[ else]@
|
||||
@(topic) msg = _@(topic)_sub.getMsg();
|
||||
@[ end if]@
|
||||
msg.serialize(scdr);
|
||||
ret = true;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,13 @@ void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber* sub)
|
|||
{
|
||||
// Take data
|
||||
if(sub->takeNextData(&msg, &m_info))
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ st;
|
||||
@[else]@
|
||||
@(topic) st;
|
||||
@[end if]@
|
||||
|
||||
if(sub->takeNextData(&st, &m_info))
|
||||
{
|
||||
if(m_info.sampleKind == ALIVE)
|
||||
{
|
||||
|
@ -141,7 +148,11 @@ bool @(topic)_Subscriber::hasMsg()
|
|||
return m_listener.has_msg;
|
||||
}
|
||||
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ @(topic)_Subscriber::getMsg()
|
||||
@[else]@
|
||||
@(topic) @(topic)_Subscriber::getMsg()
|
||||
@[end if]@
|
||||
{
|
||||
m_listener.has_msg = false;
|
||||
return m_listener.msg;
|
||||
|
|
|
@ -64,7 +64,11 @@ topic = alias if alias else spec.short_name
|
|||
#include <fastrtps/fastrtps_fwd.h>
|
||||
#include <fastrtps/subscriber/SubscriberListener.h>
|
||||
#include <fastrtps/subscriber/SampleInfo.h>
|
||||
@[if float(fastrtps_version) < 1.9]@
|
||||
#include "@(topic)_PubSubTypes.h"
|
||||
@[else]@
|
||||
#include "@(topic)PubSubTypes.h"
|
||||
@[end if]@
|
||||
|
||||
using namespace eprosima::fastrtps;
|
||||
using namespace eprosima::fastrtps::rtps;
|
||||
|
@ -77,7 +81,11 @@ public:
|
|||
bool init();
|
||||
void run();
|
||||
bool hasMsg();
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ getMsg();
|
||||
@[else]@
|
||||
@(topic) getMsg();
|
||||
@[end if]@
|
||||
private:
|
||||
Participant *mp_participant;
|
||||
Subscriber *mp_subscriber;
|
||||
|
@ -92,11 +100,19 @@ private:
|
|||
SampleInfo_t m_info;
|
||||
int n_matched;
|
||||
int n_msg;
|
||||
@[if (ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal") and float(fastrtps_version) < 1.9]@
|
||||
@(topic)_ msg;
|
||||
@[else]@
|
||||
@(topic) msg;
|
||||
@[end if]@
|
||||
bool has_msg = false;
|
||||
|
||||
} m_listener;
|
||||
@[if float(fastrtps_version) < 1.9]@
|
||||
@(topic)_PubSubType myType;
|
||||
@[else]@
|
||||
@(topic)PubSubType myType;
|
||||
@[end if]@
|
||||
};
|
||||
|
||||
#endif // _@(topic)__SUBSCRIBER_H_
|
||||
|
|
|
@ -57,7 +57,11 @@ 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 ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
include_directive = '#include "%s_.idl"' % builtin_type
|
||||
@[else]@
|
||||
include_directive = '#include "%s.idl"' % builtin_type
|
||||
@[end if]@
|
||||
builtin_types.add(builtin_type)
|
||||
include_directives.add(include_directive)
|
||||
return sorted(include_directives)
|
||||
|
@ -74,10 +78,17 @@ def get_idl_type_name(field_type):
|
|||
def add_msg_field(field):
|
||||
if (not field.is_header):
|
||||
if field.is_array:
|
||||
@[if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
print(' {0}__{1}_array_{2} {3}_;'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
|
||||
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)
|
||||
print(' {0} {1}_;'.format(base_type, 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:
|
||||
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)
|
||||
print(' {0} {1};'.format(base_type, field.name))
|
||||
@[end if]@
|
||||
|
||||
|
||||
def add_msg_fields():
|
||||
|
@ -88,6 +99,11 @@ def add_msg_fields():
|
|||
def add_array_typedefs():
|
||||
for field in spec.parsed_fields():
|
||||
if not field.is_header and field.is_array:
|
||||
@[if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else
|
||||
@[else]@
|
||||
base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else
|
||||
@[end if]@
|
||||
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)
|
||||
array_type = 'typedef {0} {1}__{2}_array_{3}[{4}];'.format(base_type, topic, get_idl_type_name(field.base_type).replace(" ", "_"), field.array_len, field.array_len)
|
||||
if array_type not in array_types:
|
||||
|
@ -109,18 +125,28 @@ def add_msg_constants():
|
|||
@#############################
|
||||
@# Include dependency messages
|
||||
@#############################
|
||||
@[for line in get_include_directives(spec)]
|
||||
@(line)
|
||||
@[end for]
|
||||
@[for line in get_include_directives(spec)]@
|
||||
@(line)@
|
||||
@[end for]@
|
||||
@# Constants
|
||||
@add_msg_constants()
|
||||
@# Array types
|
||||
@add_array_typedefs()
|
||||
@[if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
struct @(topic)_
|
||||
@[else]@
|
||||
struct @(topic)
|
||||
@[end if]@
|
||||
{
|
||||
@add_msg_fields()
|
||||
@[if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal" and float(fastrtps_version) < 1.9]@
|
||||
}; // struct @(topic)_
|
||||
|
||||
#pragma keylist @(topic)_
|
||||
@[else]@
|
||||
}; // struct @(topic)
|
||||
|
||||
#pragma keylist @(topic)
|
||||
@[end if]@
|
||||
|
||||
#endif // __@(topic)__idl__
|
||||
|
|
|
@ -187,6 +187,8 @@ parser.add_argument("-f", "--fastrtpsgen-dir", dest='fastrtpsgen', type=str, nar
|
|||
help="fastrtpsgen installation dir, only needed if fastrtpsgen is not in PATH, by default empty", default="")
|
||||
parser.add_argument("-g", "--fastrtpsgen-include", dest='fastrtpsgen_include', type=str,
|
||||
help="directory(ies) to add to preprocessor include paths of fastrtpsgen, by default empty", default="")
|
||||
parser.add_argument("-r", "--ros2-distro", dest='ros2_distro', type=str, nargs='?',
|
||||
help="ROS2 distro, only required if generating the agent for usage with ROS2 nodes, by default empty", default="")
|
||||
parser.add_argument("--delete-tree", dest='del_tree',
|
||||
action="store_true", help="Delete dir tree output dir(s)")
|
||||
|
||||
|
@ -236,6 +238,8 @@ if fastrtpsgen_include is not None and fastrtpsgen_include != '':
|
|||
os.path.abspath(
|
||||
args.fastrtpsgen_include) + " "
|
||||
|
||||
ros2_distro = "" if args.ros2_distro == None else args.ros2_distro
|
||||
|
||||
# If nothing specified it's generated both
|
||||
if agent == False and client == False:
|
||||
agent = True
|
||||
|
@ -293,19 +297,30 @@ uRTPS_SUBSCRIBER_H_TEMPL_FILE = 'Subscriber.h.em'
|
|||
|
||||
|
||||
def generate_agent(out_dir):
|
||||
# get FastRTPSGen version
|
||||
if(os.path.exists(fastrtpsgen_path)):
|
||||
fastrtps_vers = subprocess.check_output(
|
||||
[fastrtpsgen_path, "-version"]).strip()[-5:-2]
|
||||
if not fastrtps_vers:
|
||||
raise Exception(
|
||||
"FastRTPSGen failed with code error %s" % fastrtps_vers)
|
||||
else:
|
||||
raise Exception(
|
||||
"FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag")
|
||||
|
||||
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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, ros2_distro, fastrtps_vers, 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, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_PUBLISHER_H_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
|
||||
|
||||
if classifier.alias_msgs_to_send:
|
||||
for msg_file in classifier.alias_msgs_to_send:
|
||||
|
@ -317,28 +332,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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_PUBLISHER_H_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
|
||||
|
||||
if classifier.alias_msgs_to_receive:
|
||||
for msg_file in classifier.alias_msgs_to_receive:
|
||||
|
@ -350,24 +365,24 @@ 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, classifier.msg_id_map)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_vers, 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, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
|
||||
package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_AGENT_TEMPL_FILE)
|
||||
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_AGENT_TOPICS_H_TEMPL_FILE)
|
||||
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_AGENT_TOPICS_SRC_TEMPL_FILE)
|
||||
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, 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, uRTPS_AGENT_CMAKELISTS_TEMPL_FILE)
|
||||
urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_id_map, fastrtps_vers, ros2_distro, uRTPS_AGENT_CMAKELISTS_TEMPL_FILE)
|
||||
|
||||
# Final steps to install agent
|
||||
mkdir_p(os.path.join(out_dir, "fastrtpsgen"))
|
||||
|
@ -375,16 +390,12 @@ def generate_agent(out_dir):
|
|||
os.chdir(os.path.join(out_dir, "fastrtpsgen"))
|
||||
if not glob.glob(os.path.join(idl_dir, "*.idl")):
|
||||
raise Exception("No IDL files found in %s" % idl_dir)
|
||||
if(os.path.exists(fastrtpsgen_path)):
|
||||
for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")):
|
||||
ret = subprocess.call(fastrtpsgen_path + " -d " + out_dir +
|
||||
"/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True)
|
||||
if ret:
|
||||
raise Exception(
|
||||
"fastrtpsgen failed with code error %s" % ret)
|
||||
else:
|
||||
raise Exception(
|
||||
"fastrtpsgen not found. Specify the location of fastrtpsgen with the -f flag")
|
||||
for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")):
|
||||
ret = subprocess.call(fastrtpsgen_path + " -d " + out_dir +
|
||||
"/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True)
|
||||
if ret:
|
||||
raise Exception(
|
||||
"FastRTPSGen failed with code error %s" % ret)
|
||||
|
||||
rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*PubSubMain*"))
|
||||
rm_wildcard(os.path.join(out_dir, "fastrtpsgen/makefile*"))
|
||||
|
|
|
@ -170,7 +170,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, ids):
|
||||
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtps_ver, ros2_distro, ids):
|
||||
"""
|
||||
Generates an .idl from .msg file
|
||||
"""
|
||||
|
@ -178,11 +178,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, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
|
@ -190,14 +190,18 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
|
|||
os.makedirs(outputdir)
|
||||
|
||||
template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE)
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + "_.idl")))
|
||||
if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal":
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + "_.idl")))
|
||||
else:
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + ".idl")))
|
||||
|
||||
return generate_by_template(output_file, template_file, em_globals)
|
||||
|
||||
|
||||
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, template_name):
|
||||
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtps_ver, ros2_distro, template_name):
|
||||
"""
|
||||
Generates source file by msg content
|
||||
"""
|
||||
|
@ -223,19 +227,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, MsgScope.SEND) for f in send_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_ver, 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, MsgScope.SEND) for f in alias_send_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
|
||||
|
||||
if receive_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f, "", package, includepath, ids, MsgScope.RECEIVE) for f in receive_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_ver, 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, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
|
||||
merged_em_globals = merge_em_globals_list(em_globals_list)
|
||||
|
||||
|
@ -250,7 +254,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, template_name):
|
||||
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtps_ver, ros2_distro, template_name):
|
||||
"""
|
||||
Generates a sources and headers from .msg file
|
||||
"""
|
||||
|
@ -258,11 +262,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, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
|
@ -276,7 +280,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, scope):
|
||||
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, scope):
|
||||
"""
|
||||
Generates em globals dictionary
|
||||
"""
|
||||
|
@ -304,7 +308,9 @@ def get_em_globals(filename_msg, alias, package, includepath, ids, scope):
|
|||
"ids": ids,
|
||||
"scope": scope,
|
||||
"package": package,
|
||||
"alias": alias
|
||||
"alias": alias,
|
||||
"fastrtps_version": fastrtps_ver,
|
||||
"ros2_distro": ros2_distro
|
||||
}
|
||||
|
||||
return em_globals
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
|
||||
set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
#set(ROS2_DISTRO $ENV{ROS_DISTRO})
|
||||
set(ROS2_DISTRO "")
|
||||
|
||||
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
|
||||
|
||||
set(send_topic_files)
|
||||
|
@ -81,7 +84,8 @@ if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_t
|
|||
--agent-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_agent
|
||||
--client-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_client
|
||||
--idl-dir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_agent/idl
|
||||
>micrortps_bridge.log > /dev/null
|
||||
--ros2-distro ${ROS2_DISTRO}
|
||||
#>micrortps_bridge.log > /dev/null
|
||||
DEPENDS ${send_topic_files} ${receive_topic_files}
|
||||
COMMENT "Generating RTPS topic bridge"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue