checkpoint_marker.cpp
Go to the documentation of this file.
00001 #include "checkpoint_marker.h"
00002 
00003 const std::string CheckpointMarker::marker_header_frame_ = "/map";
00004 const std::string CheckpointMarker::marker_ns_ = "";
00005 
00006 CheckpointMarker::CheckpointMarker()
00007 {
00008     rviz_pub = nh_.advertise<visualization_msgs::Marker>("visualization_marker", 0);
00009 }
00010 
00011 visualization_msgs::Marker
00012 CheckpointMarker::generate_common_marker_msg(CheckpointRequest checkpoint)
00013 {
00014     visualization_msgs::Marker marker;
00015 
00016     if (checkpoint.ref_frame == "")
00017         ROS_WARN("Checkpoint without reference frame. It will not display anything");
00018 
00019     marker.header.frame_id = checkpoint.ref_frame;
00020     marker.header.stamp    = ros::Time();
00021     marker.ns              = marker_ns_;
00022     marker.id              = checkpoint.id;
00023     marker.type            = visualization_msgs::Marker::SPHERE;
00024     marker.action          = visualization_msgs::Marker::ADD;
00025 
00026     marker.scale.x = 0.1;
00027     marker.scale.y = 0.1;
00028     marker.scale.z = 0.1;
00029 
00030     marker.pose.orientation.x = 0.0;
00031     marker.pose.orientation.y = 0.0;
00032     marker.pose.orientation.z = 0.0;
00033     marker.pose.orientation.w = 1.0;
00034 
00035     marker.pose.position = checkpoint.position;
00036 
00037     return marker;
00038 }
00039 
00040 
00041 visualization_msgs::Marker
00042 CheckpointMarker::generate_new_marker_msg(CheckpointRequest checkpoint)
00043 {
00044     visualization_msgs::Marker marker = generate_common_marker_msg(checkpoint);
00045 
00046     // yellow (255,255,0, 60%)
00047     marker.color.r = 1.0;
00048     marker.color.g = 1.0;
00049     marker.color.b = 0.0;
00050     marker.color.a = 0.6;
00051 
00052     return marker;
00053 }
00054 
00055 visualization_msgs::Marker
00056 CheckpointMarker::generate_visited_marker_msg(CheckpointRequest checkpoint)
00057 {
00058     visualization_msgs::Marker marker = generate_common_marker_msg(checkpoint);
00059 
00060     // grey (128,128,128,80%)
00061     marker.color.r = 0.5;
00062     marker.color.g = 0.5;
00063     marker.color.b = 0.5;
00064     marker.color.a = 0.8;
00065 
00066     return marker;
00067 }
00068 
00069 visualization_msgs::Marker
00070 CheckpointMarker::generate_active_marker_msg(CheckpointRequest checkpoint)
00071 {
00072     visualization_msgs::Marker marker = generate_common_marker_msg(checkpoint);
00073 
00074     // red (255,0,0,90%)
00075     marker.color.r = 1.0;
00076     marker.color.g = 0.0;
00077     marker.color.b = 0.0;
00078     marker.color.a = 0.9;
00079 
00080     return marker;
00081 }
00082 
00083 void
00084 CheckpointMarker::display_checkpoint(visualization_msgs::Marker marker)
00085 {
00086     rviz_pub.publish(marker);
00087 }
00088 
00089 void
00090 CheckpointMarker::display_new_checkpoint(CheckpointRequest checkpoint)
00091 {
00092     display_checkpoint(generate_new_marker_msg(checkpoint));
00093 }
00094 
00095 void
00096 CheckpointMarker::display_visited_checkpoint(CheckpointRequest checkpoint)
00097 {
00098     display_checkpoint(generate_visited_marker_msg(checkpoint));
00099 }
00100 
00101 void
00102 CheckpointMarker::display_active_checkpoint(CheckpointRequest checkpoint)
00103 {
00104     display_checkpoint(generate_active_marker_msg(checkpoint));
00105 }


iri_checkpoint_nav
Author(s): Jose Luis Rivero
autogenerated on Fri Dec 6 2013 22:56:28