3 #include "CloCK_math.h"
5 class ConfiguratorInterface;
17 Pointf(
float _x,
float _y){
45 struct cv::traits::Depth<
Pointf> {
enum {value = Depth<cv::Point2f>::value};};
48 struct cv::traits::Type<
Pointf> {
enum {value = CV_MAKETYPE(cv::traits::Depth<Pointf>::value, 2)};};
50 float length(cv::Point2f
const& p);
52 float angle(cv::Point2f
const&);
62 typedef std::set<Pointf> CoordinateContainer;
68 b2Vec2 getb2Vec2(cv::Point2f );
89 Pointf Polar2f(
float radius,
float angle);
99 std::vector<T> set2vec(std::set<T> s){
114 template <
typename T>
115 std::vector<cv::Point2f> set2vec2f(std::set<T> s){
116 std::vector <cv::Point2f> vec;
118 vec.push_back(cv::Point2f(t.x, t.y));
130 template <
typename T>
inline
131 std::vector<b2Vec2> cast_b2Vec2(
const std::vector<T>& v){
132 std::vector<b2Vec2> result;
134 result.push_back(b2Vec2(t.x, t.y));
146 template <
typename T>
inline
147 std::vector<cv::Point2f> cast_Point2f(
const std::vector<T>& v){
148 std::vector<cv::Point2f> result;
150 result.push_back(cv::Point2f(t.x, t.y));
163 template <
typename T>
164 std::set<T> vec2set(std::vector<T> vec){
178 std::pair <bool, BodyFeatures> bounding_rotated_box(std::vector <cv::Point2f>nb);
180 template <
typename Pt>
181 static b2PolygonShape sensor_box(
const std::vector <Pt> &all_points_pt, b2Transform robot_pose,
const Disturbance * dist){
182 b2PolygonShape shape;
183 b2Vec2 centroid(2.0, 2.0), center=centroid, center_local=b2Vec2_zero;
184 float halfHeight=0, halfWidth=0;
185 if (dist->isValid()){
186 std::vector <b2Vec2> d_vertices=dist->vertices();
187 std::vector <cv::Point2f> all_points=cast_Point2f(all_points_pt);
188 for (b2Vec2 p: d_vertices){
189 p=b2MulT(robot_pose, p);
190 all_points.push_back(cv::Point2f(p.x, p.y));
192 float minx=(std::min_element(all_points.begin(),all_points.end(),
CompareX())).base()->x;
193 float miny=(std::min_element(all_points.begin(), all_points.end(),
CompareY())).base()->y;
194 float maxx=(std::max_element(all_points.begin(), all_points.end(),
CompareX())).base()->x;
195 float maxy=(std::max_element(all_points.begin(), all_points.end(),
CompareY())).base()->y;
196 halfHeight=(fabs(maxy-miny))/2;
197 halfWidth=(fabs(maxx-minx))/2;
198 center.x=maxx-halfWidth;
199 center.y=maxy-halfHeight;
200 centroid=center-center_local;
202 shape.SetAsBox(halfWidth, halfHeight,centroid, 0);
215 std::pair<bool,BodyFeatures> bounding_box( std::vector <Pt >&nb){
216 float l=(0.0005*2), w=(0.0005*2) ;
217 float x_glob=0.0f, y_glob=0.0f;
218 std::pair <bool, BodyFeatures> result(0,
BodyFeatures());
224 typename std::vector<Pt>::iterator maxx=std::max_element(nb.begin(), nb.end(), compareX);
225 typename std::vector<Pt>::iterator miny=std::min_element(nb.begin(), nb.end(), compareY);
226 typename std::vector<Pt>::iterator minx=std::min_element(nb.begin(), nb.end(), compareX);
227 typename std::vector<Pt>::iterator maxy=std::max_element(nb.begin(), nb.end(), compareY);
228 if (minx->x!=maxx->x){
229 w= fabs((*maxx).x-(*minx).x);
231 if (miny->y!=maxy->y){
232 l=fabs((*maxy).y-(*miny).y);
234 x_glob= ((*maxx).x+(*minx).x)/2;
235 y_glob= ((*maxy).y+(*miny).y)/2;
236 result.second.halfLength=l/2;
237 result.second.halfWidth=w/2;
238 result.second.pose.p=b2Vec2(x_glob, y_glob);
Definition: disturbance.h:45
Definition: configurator.h:17
Wrapper around cv::Point2f for customisation purposes.
Definition: sensor.h:12
Definition: disturbance.h:22
Definition: disturbance.h:15
Definition: disturbance.h:112