interactive_markers_tools.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #include <cob_interactive_teleop/interactive_markers_tools.h>
00019 
00020 namespace interactive_markers
00021 {
00022 
00023 void makeCircle(visualization_msgs::InteractiveMarkerControl &control,
00024                 float radius,
00025                 float width,
00026                 std_msgs::ColorRGBA color
00027                 )
00028 {
00029   visualization_msgs::Marker marker;
00030 
00031   marker.pose.orientation = control.orientation;
00032   marker.type = visualization_msgs::Marker::TRIANGLE_LIST;
00033   marker.scale.x = radius;
00034   marker.scale.y = radius;
00035   marker.scale.z = radius;
00036   marker.color = color;
00037 
00038   int steps = 36;
00039   std::vector<geometry_msgs::Point> circle1, circle2;
00040 
00041   geometry_msgs::Point v1, v2;
00042 
00043   for (int i = 0; i < steps; i++)
00044   {
00045     float a = float(i) / float(steps) * M_PI * 2.0;
00046 
00047     v1.y = 0.5 * cos(a);
00048     v1.z = 0.5 * sin(a);
00049 
00050     v2.y = (1 + width) * v1.y;
00051     v2.z = (1 + width) * v1.z;
00052 
00053     circle1.push_back(v1);
00054     circle2.push_back(v2);
00055   }
00056 
00057   for (int i = 0; i < steps; i++)
00058   {
00059     int i1 = i;
00060     int i2 = (i + 1) % steps;
00061 
00062     marker.points.clear();
00063     marker.points.push_back(circle1[i1]);
00064     marker.points.push_back(circle2[i1]);
00065     marker.points.push_back(circle1[i2]);
00066     marker.points.push_back(circle2[i1]);
00067     marker.points.push_back(circle2[i2]);
00068     marker.points.push_back(circle1[i2]);
00069 
00070     control.markers.push_back(marker);
00071   }
00072 }
00073 
00074 }


cob_interactive_teleop
Author(s): Michal Spanel
autogenerated on Sun Jun 9 2019 20:20:09