3 #ifdef NAVDATA_STRUCTS_INCLUDES 5 #include "ardrone_autonomy/${item['struct_name']}.h" 9 %
for member in item[
'members']:
10 %
if member[
'include'] not in included:
11 <% included.append(
member[
'include']) %>\
12 #include <${'/'.join(member['include'].split('::'))}.h> 18 #ifdef NAVDATA_STRUCTS_HEADER_PUBLIC 19 void PublishNavdataTypes(
const navdata_unpacked_t &n,
const ros::Time &received);
22 #ifdef NAVDATA_STRUCTS_HEADER_PRIVATE 23 %
for item in structs:
25 bool enabled_${item[
'struct_name']};
26 ardrone_autonomy::${item[
'struct_name']} ${item[
'struct_name']}_msg;
29 bool enabled_legacy_navdata;
31 bool initialized_navdata_publishers;
34 #ifdef NAVDATA_STRUCTS_INITIALIZE 35 if(!initialized_navdata_publishers)
37 initialized_navdata_publishers =
true;
40 if(enabled_legacy_navdata)
42 navdata_pub = node_handle.advertise<ardrone_autonomy::Navdata>(
"ardrone/navdata", 25);
43 imu_pub = node_handle.advertise<sensor_msgs::Imu>(
"ardrone/imu", 25);
44 mag_pub = node_handle.advertise<geometry_msgs::Vector3Stamped>(
"ardrone/mag", 25);
45 odo_pub = node_handle.advertise<nav_msgs::Odometry>(
"ardrone/odometry", 25);
50 %
for item in structs:
51 ros::param::param(
"~enable_${item['struct_name']}", enabled_${item[
'struct_name']},
false);
52 if(enabled_${item[
'struct_name']})
54 pub_${item[
'struct_name']} = node_handle.advertise<ardrone_autonomy::${item[
'struct_name']}>(
"ardrone/${item['struct_name']}",
NAVDATA_QUEUE_SIZE);
63 #ifdef NAVDATA_STRUCTS_SOURCE 64 void ARDroneDriver::PublishNavdataTypes(
const navdata_unpacked_t &n,
const ros::Time &received)
66 if(initialized_navdata_publishers)
68 %
for item in structs:
69 if(enabled_${item[
'struct_name']} && pub_${item[
'struct_name']}.getNumSubscribers()>0)
71 ${item[
'struct_name']}_msg.drone_time = ((double)ardrone_time_to_usec(n.navdata_time.time))/1000000.0;
72 ${item[
'struct_name']}_msg.header.stamp = received;
73 ${item[
'struct_name']}_msg.header.frame_id = droneFrameBase;
75 %
for member in item[
'members']:
76 %
if member[
'array_size'] is None:
78 ${format_member(item,
member, None)}
79 ${item[
'struct_name']}_msg.${
member[
'name']} = m;
83 ${item[
'struct_name']}_msg.${
member[
'name']}.clear();
84 for(
int i=0; i<${
member[
'array_size']}; i++)
86 ${format_member(item,
member,
'i')}
87 ${item[
'struct_name']}_msg.${
member[
'name']}.push_back(m);
92 pub_${item[
'struct_name']}.publish(${item[
'struct_name']}_msg);
105 <%def name=
"format_member(item, member, i)">
106 ${
member[
'c_type']} c = n.${item[
'struct_name']}.${
member[
'name']}${
'[{}]'.format(i)
if i is not None
else ''};
108 %
if 'matrix33' in
member[
'ros_type']:
118 % elif
'vector21' in
member[
'ros_type']:
121 % elif
'vector31' in
member[
'ros_type']:
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
<%def name="format_member(item, member, i)"> if matrix33 in member['ros_type']
#define NAVDATA_QUEUE_SIZE