Add function to calculate the orientation at which the footprint sweeps the smallest area - #45
Add function to calculate the orientation at which the footprint sweeps the smallest area#45corot wants to merge 2 commits into
Conversation
…ps the smallest area
ca0d7f0 to
3fa85bc
Compare
| for (unsigned int i = 0; i < footprint.size() - 1; ++i) | ||
| { | ||
| double edge_dist = distanceToLine(0, 0, footprint[i].x, footprint[i].y, footprint[i + 1].x, footprint[i + 1].y); | ||
| if (edge_dist < min_dist) |
There was a problem hiding this comment.
if +x is the horizontal, rotating the rectangle 90 deg will minimize the sweeping area; so 90 deg is the right answer
There was a problem hiding this comment.
the answer won't be 90, true
but it will be correct anyway: will sweep the same area as with 90
in any case that fp violates the 2nd assumption I added to the function (true, the assumptions are a bit ad-hoc,,, but are true for every polygonal robot I know
There was a problem hiding this comment.
hum, true. But then the function should check the violation. You don't need to loop all edges if you assume the closest one is parallel to the x-axis
| // return the orientation of the closest edge, directed from back to front (+x axis direction) | ||
| std::sort(closest_edge.begin(), closest_edge.end(), | ||
| [](const geometry_msgs::Point& p1, const geometry_msgs::Point& p2) { return p1.x < p2.x; }); | ||
| return orientation(closest_edge.front().x, closest_edge.front().y, closest_edge.back().x, closest_edge.back().y); | ||
| } |
There was a problem hiding this comment.
This logic won't work. You are trying to compute the direction in which the sweep is minimum and not the edge which minimizes the sweep (the closest edge may not be the one either as @renan028 mentioned).
You will need to implement something like this https://en.wikipedia.org/wiki/Rotating_calipers and figure out the normal to the min width of the polygon.
There was a problem hiding this comment.
oh,,, yes, yes;
I forgot to add the assumptions I'm doing here:
- the footprint is symmetric wrt the x axis
- the closest edge is approximately parallel to either x or y axis
Then the logic makes sense
67e2141 to
2fb17ce
Compare
|
replaced by #52 |


https://www.wrike.com/open.htm?id=929048956 1/4 PRs