Go to the documentation of this file.00001 #include "ros/ros.h"
00002
00003 #include "visualization_msgs/Marker.h"
00004 #include "visualization_msgs/MarkerArray.h"
00005 #include "interactive_markers/interactive_marker_server.h"
00006
00007 #include <tf/tf.h>
00008 #include <tf/transform_broadcaster.h>
00009
00010 interactive_markers::InteractiveMarkerServer* server;
00011
00012 void makeMarker( )
00013 {
00014
00015 visualization_msgs::InteractiveMarker int_marker;
00016 int_marker.header.frame_id = "/rviz_logo";
00017 int_marker.name = "R";
00018
00019 int_marker.pose.orientation.x = 0.0;
00020 int_marker.pose.orientation.y = 0.0;
00021 int_marker.pose.orientation.z = 1.0;
00022 int_marker.pose.orientation.w = 1.0;
00023 int_marker.pose.position.y = - 2.0;
00024 int_marker.scale = 2.3;
00025
00026 visualization_msgs::Marker marker;
00027 marker.type = visualization_msgs::Marker::MESH_RESOURCE;
00028
00029 tf::quaternionTFToMsg( tf::Quaternion( tf::Vector3(0, 0, 1), 0.2 ), marker.pose.orientation );
00030
00031 marker.pose.position.x = 0;
00032 marker.pose.position.y = -0.22;
00033 marker.pose.position.z = 0;
00034 marker.scale.x = marker.scale.y = marker.scale.z = 4;
00035 marker.color.r = 0;
00036 marker.color.g = 0;
00037 marker.color.b = 0;
00038 marker.color.a = 0;
00039 marker.mesh_resource = "package://rviz/image_src/R.stl";
00040 marker.mesh_use_embedded_materials = true;
00041 marker.id = 0;
00042
00043
00044 visualization_msgs::InteractiveMarkerControl control;
00045 control.always_visible = true;
00046 control.markers.push_back( marker );
00047
00048
00049 int_marker.controls.push_back( control );
00050
00051 visualization_msgs::InteractiveMarkerControl linear_control;
00052 linear_control.name = "rotate_z";
00053 linear_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
00054 linear_control.orientation.y = 1;
00055 linear_control.orientation.w = 1;
00056
00057
00058 int_marker.controls.push_back(linear_control);
00059
00060 server->insert(int_marker);
00061
00062 int_marker.name = "Viz";
00063
00064 marker.mesh_resource = "package://rviz/image_src/Viz.stl";
00065 marker.pose.position.x = 3.3;
00066 marker.pose.orientation.x = 0.0;
00067 marker.pose.orientation.y = 0.0;
00068 marker.pose.orientation.z = 0.0;
00069 marker.pose.orientation.w = 1.0;
00070 control.markers.clear();
00071 control.markers.push_back( marker );
00072
00073
00074 int_marker.controls.clear();
00075 int_marker.controls.push_back( control );
00076
00077 server->insert(int_marker);
00078
00079
00080 server->applyChanges();
00081 }
00082
00083 void publishCallback(tf::TransformBroadcaster& tf_broadcaster, const ros::TimerEvent&)
00084 {
00085 static tf::TransformBroadcaster br;
00086 tf::Transform transform;
00087 transform.setOrigin( tf::Vector3(3, 1, 0) );
00088 transform.setRotation( tf::createQuaternionFromRPY(0, 0, M_PI * 0.9) );
00089 br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "base_link", "rviz_logo"));
00090 }
00091
00092 int main(int argc, char** argv)
00093 {
00094 ros::init(argc, argv, "rviz_logo_marker");
00095 ros::NodeHandle n;
00096 tf::TransformBroadcaster tf_broadcaster;
00097
00098 ros::Timer publish_timer = n.createTimer(ros::Duration(0.1), boost::bind(&publishCallback,tf_broadcaster,_1));
00099
00100 server = new interactive_markers::InteractiveMarkerServer("rviz_logo");
00101 makeMarker( );
00102
00103 ros::spin();
00104 }