matlab_rviz.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 ***************************************************************************************************/
35 #include "ros/ros.h"
36 #include "std_msgs/String.h"
37 #include "geometry_msgs/PoseWithCovariance.h"
38 #include "tf/transform_listener.h"
39 #include "mtt/TargetList.h"
40 #include <visualization_msgs/Marker.h>
41 
42 ros::Publisher marker_pub;
43 
44 void drawCallback(const geometry_msgs::Pose& input)
45 {
46  visualization_msgs::Marker marker;
47 
48  marker.header.frame_id = "/map";
49  marker.header.stamp = ros::Time::now();
50 
51  marker.ns = "quality";
52  marker.id = input.orientation.x;
53 
54  marker.type = visualization_msgs::Marker::CYLINDER;
55  marker.action = visualization_msgs::Marker::ADD;
56 
57  // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header
58  marker.pose.position.x = input.position.x;
59  marker.pose.position.y = input.position.y;
60  marker.pose.position.z = 0;
61  marker.pose.orientation.x = 0.0;
62  marker.pose.orientation.y = 0.0;
63  marker.pose.orientation.z = 0.0;
64  marker.pose.orientation.w = 1.0;
65 
66  // Set the scale of the marker
67  marker.scale.x = 0.5;
68  marker.scale.y = 0.5;
69  marker.scale.z = 0.5;
70 
71  //good or bad leader
72  if(input.position.z == -1){
73  marker.color.r = 0.0f;
74  marker.color.g = 1.0f;
75  }
76  else if (input.position.z == 1){
77  marker.color.r = 1.0f;
78  marker.color.g = 0.0f;
79  }
80 
81  marker.color.b = 0.2f;
82  marker.color.a = 1.0;
83 
84  marker.lifetime = ros::Duration(2);
85 
86  // Publish the marker
87  marker_pub.publish(marker);
88 }
89 
90 int main(int argc, char **argv)
91 {
92  ros::init(argc, argv, "class_view");
93  ros::NodeHandle n;
94 
95  ros::Subscriber sub_draw = n.subscribe("/pose_to_draw", 1000, drawCallback);
96  marker_pub = n.advertise<visualization_msgs::Marker>("/leader_quality", 1);
97 
98  ros::spin();
99 
100  return 0;
101 }
void drawCallback(const geometry_msgs::Pose &input)
Definition: matlab_rviz.cpp:44
ros::Publisher marker_pub
Visualization of leader classification.
Definition: matlab_rviz.cpp:42
int main(int argc, char **argv)
Definition: matlab_rviz.cpp:90


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