rviz_logo_marker.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 
3 #include "visualization_msgs/Marker.h"
4 #include "visualization_msgs/MarkerArray.h"
6 
7 #include <tf/tf.h>
9 
11 
12 void makeMarker()
13 {
14  // create an interactive marker for our server
15  visualization_msgs::InteractiveMarker int_marker;
16  int_marker.header.frame_id = "/rviz_logo";
17  int_marker.name = "R";
18 
19  int_marker.pose.orientation.x = 0.0;
20  int_marker.pose.orientation.y = 0.0;
21  int_marker.pose.orientation.z = 1.0;
22  int_marker.pose.orientation.w = 1.0;
23  int_marker.pose.position.y = -2.0;
24  int_marker.scale = 2.3;
25 
26  visualization_msgs::Marker marker;
27  marker.type = visualization_msgs::Marker::MESH_RESOURCE;
28 
29  tf::quaternionTFToMsg(tf::Quaternion(tf::Vector3(0, 0, 1), 0.2), marker.pose.orientation);
30 
31  marker.pose.position.x = 0;
32  marker.pose.position.y = -0.22;
33  marker.pose.position.z = 0;
34  marker.scale.x = marker.scale.y = marker.scale.z = 4;
35  marker.color.r = 0;
36  marker.color.g = 0;
37  marker.color.b = 0;
38  marker.color.a = 0;
39  marker.mesh_resource = "package://rviz/image_src/R.stl";
40  marker.mesh_use_embedded_materials = true;
41  marker.id = 0;
42 
43  // create a non-interactive control which contains the box
44  visualization_msgs::InteractiveMarkerControl control;
45  control.always_visible = true;
46  control.markers.push_back(marker);
47 
48  // add the control to the interactive marker
49  int_marker.controls.push_back(control);
50 
51  visualization_msgs::InteractiveMarkerControl linear_control;
52  linear_control.name = "rotate_z";
53  linear_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
54  linear_control.orientation.y = 1;
55  linear_control.orientation.w = 1;
56 
57  // add the control to the interactive marker
58  int_marker.controls.push_back(linear_control);
59 
60  server->insert(int_marker);
61 
62  int_marker.name = "Viz";
63 
64  marker.mesh_resource = "package://rviz/image_src/Viz.stl";
65  marker.pose.position.x = 3.3;
66  marker.pose.orientation.x = 0.0;
67  marker.pose.orientation.y = 0.0;
68  marker.pose.orientation.z = 0.0;
69  marker.pose.orientation.w = 1.0;
70  control.markers.clear();
71  control.markers.push_back(marker);
72 
73  // add the control to the interactive marker
74  int_marker.controls.clear();
75  int_marker.controls.push_back(control);
76 
77  server->insert(int_marker);
78 
79 
80  server->applyChanges();
81 }
82 
83 void publishCallback(tf::TransformBroadcaster& /*tf_broadcaster*/, const ros::TimerEvent& /*unused*/)
84 {
85  static tf::TransformBroadcaster br;
86  tf::Transform transform;
87  transform.setOrigin(tf::Vector3(3, 1, 0));
88  transform.setRotation(tf::createQuaternionFromRPY(0, 0, M_PI * 0.9));
89  br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "base_link", "rviz_logo"));
90 }
91 
92 int main(int argc, char** argv)
93 {
94  ros::init(argc, argv, "rviz_logo_marker");
96  tf::TransformBroadcaster tf_broadcaster;
97 
98  ros::Timer publish_timer =
99  n.createTimer(ros::Duration(0.1), boost::bind(&publishCallback, tf_broadcaster, _1));
100 
101  server = new interactive_markers::InteractiveMarkerServer("rviz_logo");
102  makeMarker();
103 
104  ros::spin();
105 }
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
TFSIMD_FORCE_INLINE void setRotation(const Quaternion &q)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void makeMarker()
interactive_markers::InteractiveMarkerServer * server
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
void sendTransform(const StampedTransform &transform)
ROSCPP_DECL void spin()
void publishCallback(tf::TransformBroadcaster &, const ros::TimerEvent &)
INTERACTIVE_MARKERS_PUBLIC void insert(const visualization_msgs::InteractiveMarker &int_marker)
int main(int argc, char **argv)
INTERACTIVE_MARKERS_PUBLIC void applyChanges()
static Time now()
TFSIMD_FORCE_INLINE void setOrigin(const Vector3 &origin)


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Fri Aug 12 2022 02:06:09