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 
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  marker.pose.orientation = tf2::toMsg(tf2::Quaternion(tf2::Vector3(0, 0, 1), 0.2));
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 
81 }
82 
83 void publishCallback(const ros::TimerEvent& /*unused*/)
84 {
86  geometry_msgs::TransformStamped transform;
87  transform.transform.translation = tf2::toMsg(tf2::Vector3(3, 1, 0));
89  q.setRPY(0, 0, M_PI * 0.9);
90  transform.transform.rotation = tf2::toMsg(q);
91  transform.header.frame_id = "base_link";
92  transform.header.stamp = ros::Time::now();
93  transform.child_frame_id = "rviz_logo";
94  br.sendTransform(transform);
95 }
96 
97 int main(int argc, char** argv)
98 {
99  ros::init(argc, argv, "rviz_logo_marker");
100  ros::NodeHandle n;
101 
102  ros::Timer publish_timer =
103  n.createTimer(ros::Duration(0.1), boost::bind(&publishCallback, boost::placeholders::_1));
104 
106  makeMarker();
107 
108  ros::spin();
109 }
server
interactive_markers::InteractiveMarkerServer * server
Definition: rviz_logo_marker.cpp:10
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
publishCallback
void publishCallback(const ros::TimerEvent &)
Definition: rviz_logo_marker.cpp:83
ros.h
tf2::Quaternion::setRPY
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
makeMarker
void makeMarker()
Definition: rviz_logo_marker.cpp:12
transform_broadcaster.h
main
int main(int argc, char **argv)
Definition: rviz_logo_marker.cpp:97
tf2_ros::TransformBroadcaster::sendTransform
void sendTransform(const geometry_msgs::TransformStamped &transform)
interactive_markers::InteractiveMarkerServer::insert
INTERACTIVE_MARKERS_PUBLIC void insert(const visualization_msgs::InteractiveMarker &int_marker)
ros::TimerEvent
interactive_markers::InteractiveMarkerServer::applyChanges
INTERACTIVE_MARKERS_PUBLIC void applyChanges()
interactive_markers::InteractiveMarkerServer
interactive_marker_server.h
tf2_ros::TransformBroadcaster
tf2::Quaternion
tf2_geometry_msgs.h
tf2::toMsg
B toMsg(const A &a)
ros::spin
ROSCPP_DECL void spin()
ros::NodeHandle::createTimer
Timer createTimer(Duration period, const TimerCallback &callback, bool oneshot=false, bool autostart=true) const
ros::Duration
ros::Timer
ros::NodeHandle
ros::Time::now
static Time now()


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10