bag_filter.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
39 #include <ros/ros.h>
40 #include <std_msgs/Header.h>
41 #include <tf/transform_listener.h>
42 #include "mtt/TargetList.h"
43 // #include "mtt/TargetListPC.h"
44 #include <visualization_msgs/Marker.h>
45 #include <visualization_msgs/MarkerArray.h>
46 
47 mtt::TargetList targetList;
48 mtt::Target target;
49 visualization_msgs::Marker arrow_marker;
50 visualization_msgs::MarkerArray arrow_markerList;
51 visualization_msgs::Marker ids_marker;
52 visualization_msgs::MarkerArray ids_markerList;
53 
54 ros::Publisher targets_pub;
55 ros::Publisher arrows_pub;
56 ros::Publisher ids_pub;
57 
58 uint interest_id = 90;
59 
60 void targetsCallback(const mtt::TargetList& list){
61  targetList.Targets.clear();
62  for(uint i = 0; i < list.Targets.size(); i++){
63  if (list.Targets[i].id == interest_id){
64  target = list.Targets[i];
65  targetList.Targets.push_back(target);
66  }
67  }
68  targets_pub.publish(targetList);
69 }
70 
71 void arrowsCallback(const visualization_msgs::MarkerArray &msg){
72  arrow_markerList.markers.clear();
73  for(uint i = 0; i < msg.markers.size(); i++){
74  if(msg.markers[i].id == interest_id){
75  arrow_marker = msg.markers[i];
76  arrow_markerList.markers.push_back(arrow_marker);
77  }
78  }
80 }
81 
82 void idsCallback(const visualization_msgs::MarkerArray &msg){
83  ids_markerList.markers.clear();
84  for(uint i = 0; i < msg.markers.size(); i++){
85  if(msg.markers[i].id == interest_id){
86  ids_marker = msg.markers[i];
87  ids_markerList.markers.push_back(ids_marker);
88  }
89  }
90  ids_pub.publish(ids_markerList);
91 }
92 
93 
94 int main(int argc, char** argv)
95 {
96  ros::init(argc, argv, "bag_filter");
97  ros::NodeHandle n;
98 
99  ros::Rate loop_rate(10);
100 
101  ros::Subscriber sub_targets = n.subscribe("/targetsF", 1000, targetsCallback);
102  ros::Subscriber sub_arrows = n.subscribe("/arrowsF", 1000, arrowsCallback);
103  ros::Subscriber sub_ids = n.subscribe("/idsF", 1000, idsCallback);
104 
105  targets_pub = n.advertise<mtt::TargetList>("/targets", 100);
106  arrows_pub = n.advertise<visualization_msgs::MarkerArray>("/arrows", 100);
107  ids_pub = n.advertise<visualization_msgs::MarkerArray>("/ids", 100);
108 
109  while (ros::ok())
110  {
111  ros::spinOnce();
112  loop_rate.sleep();
113  }
114 
115  return(0);
116 }
117 
118 
119 
uint interest_id
Definition: bag_filter.cpp:58
mtt::Target target
Definition: bag_filter.cpp:48
ros::Publisher arrows_pub
Definition: bag_filter.cpp:55
void idsCallback(const visualization_msgs::MarkerArray &msg)
Definition: bag_filter.cpp:82
visualization_msgs::Marker ids_marker
Definition: bag_filter.cpp:51
visualization_msgs::MarkerArray arrow_markerList
Definition: bag_filter.cpp:50
void targetsCallback(const mtt::TargetList &list)
Definition: bag_filter.cpp:60
visualization_msgs::Marker arrow_marker
Definition: bag_filter.cpp:49
visualization_msgs::MarkerArray ids_markerList
Definition: bag_filter.cpp:52
int main(int argc, char **argv)
Definition: bag_filter.cpp:94
void arrowsCallback(const visualization_msgs::MarkerArray &msg)
Definition: bag_filter.cpp:71
ros::Publisher ids_pub
Definition: bag_filter.cpp:56
ros::Publisher targets_pub
Definition: bag_filter.cpp:54
mtt::TargetList targetList
Tag good/bad leader in bag files.
Definition: bag_filter.cpp:47


human_leader
Author(s): Procopio Stein
autogenerated on Mon Mar 2 2015 01:31:41