Marker.cpp
Go to the documentation of this file.
00001 
00002 #include <ros/ros.h>
00003 #include <visualization_msgs/Marker.h>
00004 
00005 int main( int argc, char** argv )
00006 {
00007   ros::init(argc, argv, "basic_shapes");
00008   ros::NodeHandle n;
00009   ros::Rate r(1);
00010   ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 1);
00011 
00012   // Set our initial shape type to be a cube
00013   uint32_t shape = visualization_msgs::Marker::SPHERE;
00014 
00015   ROS_INFO("Publishing markers");
00016 
00017   double x = 0;
00018   double y = 0;
00019   double z = 0;
00020 
00021   if (argc > 1) {
00022     x = atof(argv[1]);
00023     y = atof(argv[2]);
00024     z = atof(argv[3]);
00025   }
00026 
00027   while (ros::ok())
00028   {
00029     visualization_msgs::Marker marker;
00030     // Set the frame ID and timestamp.  See the TF tutorials for information on these.
00031     marker.header.frame_id = "/r_gripper_r_finger_tip_link";
00032     marker.header.stamp = ros::Time::now();
00033 
00034     // Set the namespace and id for this marker.  This serves to create a unique ID
00035     // Any marker sent with the same namespace and id will overwrite the old one
00036     marker.ns = "basic_shapes";
00037     marker.id = 0;
00038 
00039     // Set the marker type.  Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER
00040     marker.type = shape;
00041 
00042     // Set the marker action.  Options are ADD and DELETE
00043     marker.action = visualization_msgs::Marker::ADD;
00044 
00045     // Set the pose of the marker.  This is a full 6DOF pose relative to the frame/time specified in the header
00046     marker.pose.position.x = x;
00047     marker.pose.position.y = y;
00048     marker.pose.position.z = z;
00049     marker.pose.orientation.x = 0.0;
00050     marker.pose.orientation.y = 0.0;
00051     marker.pose.orientation.z = 0.0;
00052     marker.pose.orientation.w = 1.0;
00053 
00054     // Set the scale of the marker -- 1x1x1 here means 1m on a side
00055     marker.scale.x = 0.001;
00056     marker.scale.y = 0.001;
00057     marker.scale.z = 0.001;
00058 
00059     // Set the color -- be sure to set alpha to something non-zero!
00060     marker.color.r = 1.0f;
00061     marker.color.g = 0.0f;
00062     marker.color.b = 0.0f;
00063     marker.color.a = 1.0;
00064 
00065     marker.lifetime = ros::Duration();
00066 
00067     // Publish the marker
00068     marker_pub.publish(marker);
00069 
00070     // Cycle between different shapes
00071     if (0)
00072     switch (shape)
00073     {
00074     case visualization_msgs::Marker::CUBE:
00075       shape = visualization_msgs::Marker::SPHERE;
00076       break;
00077     case visualization_msgs::Marker::SPHERE:
00078       shape = visualization_msgs::Marker::ARROW;
00079       break;
00080     case visualization_msgs::Marker::ARROW:
00081       shape = visualization_msgs::Marker::CYLINDER;
00082       break;
00083     case visualization_msgs::Marker::CYLINDER:
00084       shape = visualization_msgs::Marker::CUBE;
00085       break;
00086     }
00087 
00088     r.sleep();
00089   }
00090 }


ias_drawer_executive
Author(s): Thomas Ruehr
autogenerated on Mon Oct 6 2014 08:59:23