00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00035 #include "ros/ros.h" 00036 #include "std_msgs/String.h" 00037 #include "geometry_msgs/PoseWithCovariance.h" 00038 #include "tf/transform_listener.h" 00039 #include "mtt/TargetList.h" 00040 #include <visualization_msgs/Marker.h> 00041 00042 ros::Publisher marker_pub; 00043 00044 void drawCallback(const geometry_msgs::Pose& input) 00045 { 00046 visualization_msgs::Marker marker; 00047 00048 marker.header.frame_id = "/map"; 00049 marker.header.stamp = ros::Time::now(); 00050 00051 marker.ns = "quality"; 00052 marker.id = input.orientation.x; 00053 00054 marker.type = visualization_msgs::Marker::CYLINDER; 00055 marker.action = visualization_msgs::Marker::ADD; 00056 00057 // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header 00058 marker.pose.position.x = input.position.x; 00059 marker.pose.position.y = input.position.y; 00060 marker.pose.position.z = 0; 00061 marker.pose.orientation.x = 0.0; 00062 marker.pose.orientation.y = 0.0; 00063 marker.pose.orientation.z = 0.0; 00064 marker.pose.orientation.w = 1.0; 00065 00066 // Set the scale of the marker 00067 marker.scale.x = 0.5; 00068 marker.scale.y = 0.5; 00069 marker.scale.z = 0.5; 00070 00071 //good or bad leader 00072 if(input.position.z == -1){ 00073 marker.color.r = 0.0f; 00074 marker.color.g = 1.0f; 00075 } 00076 else if (input.position.z == 1){ 00077 marker.color.r = 1.0f; 00078 marker.color.g = 0.0f; 00079 } 00080 00081 marker.color.b = 0.2f; 00082 marker.color.a = 1.0; 00083 00084 marker.lifetime = ros::Duration(2); 00085 00086 // Publish the marker 00087 marker_pub.publish(marker); 00088 } 00089 00090 int main(int argc, char **argv) 00091 { 00092 ros::init(argc, argv, "class_view"); 00093 ros::NodeHandle n; 00094 00095 ros::Subscriber sub_draw = n.subscribe("/pose_to_draw", 1000, drawCallback); 00096 marker_pub = n.advertise<visualization_msgs::Marker>("/leader_quality", 1); 00097 00098 ros::spin(); 00099 00100 return 0; 00101 }