5 class ConfiguratorInterface;
16 Pointf(
float _x,
float _y){
44 struct cv::traits::Depth<
Pointf> {
enum {value = Depth<cv::Point2f>::value};};
47 struct cv::traits::Type<
Pointf> {
enum {value = CV_MAKETYPE(cv::traits::Depth<Pointf>::value, 2)};};
49 float length(cv::Point2f
const& p);
51 float angle(cv::Point2f
const&);
113 template <
typename T>
115 std::vector <cv::Point2f> vec;
117 vec.push_back(cv::Point2f(t.x, t.y));
129 template <
typename T>
inline
131 std::vector<b2Vec2> result;
133 result.push_back(b2Vec2(t.x, t.y));
145 template <
typename T>
inline
147 std::vector<cv::Point2f> result;
149 result.push_back(cv::Point2f(t.x, t.y));
162 template <
typename T>
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;
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);
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:47
Definition: configurator.h:17
std::vector< b2Vec2 > cast_b2Vec2(const std::vector< T > &v)
Casts a vector of 2d points to a vector of box2d b2Vec2.
Definition: sensor.h:130
b2Vec2 getb2Vec2(cv::Point2f)
Gets an opencv point in b2VEc2 format.
Definition: sensor.cpp:30
std::set< Pointf > CoordinateContainer
container for LIDAR coordinates
Definition: sensor.h:61
std::vector< cv::Point2f > cast_Point2f(const std::vector< T > &v)
Casts a vector of 2d points to a vector of cv::Point2f.
Definition: sensor.h:146
Pointf Polar2f(float radius, float angle)
Gets Pointf from polar coordinates.
Definition: sensor.cpp:36
Pointf getPointf(T v)
Get the Pointf object from a 2d point/vector.
Definition: sensor.h:77
std::vector< cv::Point2f > set2vec2f(std::set< T > s)
Casts a set of 2d points/vectors to a vector of cv::Point2f.
Definition: sensor.h:114
std::set< T > vec2set(std::vector< T > vec)
Casts a vector to set.
Definition: sensor.h:163
std::vector< T > set2vec(std::set< T > s)
Casts a set to vector.
Definition: sensor.h:98
std::pair< bool, BodyFeatures > bounding_box(std::vector< Pt > &nb)
Makes an upright bounding box around points.
Definition: sensor.h:215
Definition: disturbance.h:24
Definition: disturbance.h:17
Definition: disturbance.h:114
Wrapper around cv::Point2f for customisation purposes.
Definition: sensor.h:12