Go to the documentation of this file.00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <math.h>
00004 #include <string.h>
00005 #include <unistd.h>
00006 #include <string>
00007 #include <vector>
00008
00009 #include <ros/ros.h>
00010 #include <visualization_msgs/Marker.h>
00011 #include <nav_msgs/Odometry.h>
00012 #include <geometry_msgs/Vector3.h>
00013 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00014
00015 float x=0, y=0, z=0, w=0;
00016 float x_temp=0, y_temp=0, z_temp=0, w_temp=0;
00017 float dust_sensor=0, acohol_sensor=0, thermopile_sensor=0;
00018 int cnt=0;
00019
00020 ros::Publisher marker_pub;
00021 ros::Subscriber classification_sub;
00022 ros::Subscriber dataSensors_sub;
00023 ros::Subscriber odom_sub;
00024 ros::Subscriber amcl_sub;
00025
00026
00027
00028
00029
00030 void dataSensorsCallback(const geometry_msgs::Vector3::ConstPtr& msg) {
00031
00032 acohol_sensor=msg->x;
00033 dust_sensor=msg->y;
00034 thermopile_sensor=msg->z;
00035
00036 }
00037
00038
00039
00040 void odomCallback(const nav_msgs::Odometry::ConstPtr& msg) {
00041
00042 x=msg->pose.pose.position.x;
00043 y=msg->pose.pose.position.y;
00044 z=msg->pose.pose.orientation.z;
00045 w=msg->pose.pose.orientation.w;
00046
00047
00048 uint32_t shape = visualization_msgs::Marker::CUBE;
00049
00050
00051
00052
00053
00054 visualization_msgs::Marker marker;
00055
00056 marker.header.frame_id = "base_link";
00057 marker.header.stamp = ros::Time::now();
00058
00059
00060
00061
00062 marker.ns = "basic_shapes";
00063 marker.id = cnt;
00064 cnt++;
00065 marker.type = shape;
00066 marker.action = visualization_msgs::Marker::ADD;
00067 marker.pose.position.x = 0;
00068 marker.pose.position.y = 0;
00069 marker.pose.position.z = 0;
00070 marker.pose.orientation.x = 0.0;
00071 marker.pose.orientation.y = 0.0;
00072 marker.pose.orientation.z = 0;
00073 marker.pose.orientation.w = 0;
00074
00075 marker.scale.x = 0.20;
00076 marker.scale.y = 0.23;
00077 marker.scale.z = 0.3;
00078
00079 if((thermopile_sensor>40) && (thermopile_sensor<145)){
00080 marker.color.r = 1.0f;
00081 marker.color.g = 0.0f;
00082 marker.color.b = 0.0f;
00083 marker.color.a = 0.02;
00084 } else if ((thermopile_sensor>145) && (thermopile_sensor<160)) {
00085
00086 marker.color.r = 1.0f;
00087 marker.color.g = 0.0f;
00088 marker.color.b = 0.0f;
00089 marker.color.a = 0.08;
00090 } else if (thermopile_sensor>160) {
00091
00092 marker.color.r = 1.0f;
00093 marker.color.g = 0.0f;
00094 marker.color.b = 0.0f;
00095 marker.color.a = 0.3;
00096 } else {
00097
00098 marker.color.r = 0.0f;
00099 marker.color.g = 1.0f;
00100 marker.color.b = 0.0f;
00101 marker.color.a = 0.02;
00102 }
00103
00104
00105 if((acohol_sensor>360) && (acohol_sensor<390)){
00106 marker.color.r = 0.0f;
00107 marker.color.g = 0.0f;
00108 marker.color.b = 1.0f;
00109 marker.color.a = 0.02;
00110 } else if ((acohol_sensor>390) && (acohol_sensor<410)) {
00111
00112 marker.color.r = 0.0f;
00113 marker.color.g = 0.0f;
00114 marker.color.b = 1.0f;
00115 marker.color.a = 0.08;
00116 } else if (acohol_sensor>410) {
00117
00118 marker.color.r = 0.0f;
00119 marker.color.g = 0.0f;
00120 marker.color.b = 1.0f;
00121 marker.color.a = 0.3;
00122 } else if (thermopile_sensor<40){
00123
00124 marker.color.r = 0.0f;
00125 marker.color.g = 1.0f;
00126 marker.color.b = 0.0f;
00127 marker.color.a = 0.02;
00128 }
00129
00130 marker.lifetime = ros::Duration();
00131 marker_pub.publish(marker);
00132
00133 }
00134
00135
00136
00137 int main( int argc, char** argv )
00138 {
00139 ros::init(argc, argv, "classification_markers");
00140 ros::NodeHandle n;
00141 ros::Rate r(1);
00142 marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker_robot", 1);
00143 odom_sub = n.subscribe("odom", 1, odomCallback);
00144
00145 dataSensors_sub = n.subscribe("robot_sensors", 1, dataSensorsCallback);
00146
00147 ros::spin();
00148
00149 }