interactive_markers_tools.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
19 
20 namespace interactive_markers
21 {
22 
23 void makeCircle(visualization_msgs::InteractiveMarkerControl &control,
24  float radius,
25  float width,
26  std_msgs::ColorRGBA color
27  )
28 {
29  visualization_msgs::Marker marker;
30 
31  marker.pose.orientation = control.orientation;
32  marker.type = visualization_msgs::Marker::TRIANGLE_LIST;
33  marker.scale.x = radius;
34  marker.scale.y = radius;
35  marker.scale.z = radius;
36  marker.color = color;
37 
38  int steps = 36;
39  std::vector<geometry_msgs::Point> circle1, circle2;
40 
41  geometry_msgs::Point v1, v2;
42 
43  for (int i = 0; i < steps; i++)
44  {
45  float a = float(i) / float(steps) * M_PI * 2.0;
46 
47  v1.y = 0.5 * cos(a);
48  v1.z = 0.5 * sin(a);
49 
50  v2.y = (1 + width) * v1.y;
51  v2.z = (1 + width) * v1.z;
52 
53  circle1.push_back(v1);
54  circle2.push_back(v2);
55  }
56 
57  for (int i = 0; i < steps; i++)
58  {
59  int i1 = i;
60  int i2 = (i + 1) % steps;
61 
62  marker.points.clear();
63  marker.points.push_back(circle1[i1]);
64  marker.points.push_back(circle2[i1]);
65  marker.points.push_back(circle1[i2]);
66  marker.points.push_back(circle2[i1]);
67  marker.points.push_back(circle2[i2]);
68  marker.points.push_back(circle1[i2]);
69 
70  control.markers.push_back(marker);
71  }
72 }
73 
74 }
void makeCircle(visualization_msgs::InteractiveMarkerControl &control, float radius, float width, std_msgs::ColorRGBA color)
Makes circle from markers and assigns it to specified control.
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)


cob_interactive_teleop
Author(s): Michal Spanel
autogenerated on Wed Apr 7 2021 03:03:04