-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid region returned when there are obstacles that exceed the bounds. #68
Comments
Hey, thanks for the detailed report! (And sorry it took me two months to reply...). This is definitely a bug, and I'll see if I can figure out what's going on. |
Thanks again for making this so easy to reproduce! It turns out that, as far as I can tell, this is not exactly an IRIS bug, but instead an issue with plot_bounds(big_bounds, alpha=0.3, facecolor='none', edgecolor='black')
plt.xlim([minx-1, maxx+1])
plt.ylim([miny-1, maxy+1])
for obs in obstacles:
vertices = np.array(list(zip(*obs)))
plot_polygon(vertices,facecolor='blue', alpha=0.5)
# Plot seed
plt.plot(seed[0], seed[1], 'xr')
ax = plt.gca()
ir.getEllipsoid().draw(ax)
plot_bounds(small_bounds, alpha=0.3, facecolor='yellow', edgecolor='black') The ellipsoid (whose drawing points are not computed by cddlib) is right where I would expect to see it, which means that the polyhedron is probably correct. Internally, IRIS only ever uses the half-space representation of the polyhedron, so its vertices are only computed when you try to draw it. To verify that something wonky is going on, we can pull out just a subset of the half-spaces from the final polyhedron and try to draw them. Let's use all but the last half-space: p = ir.getPolyhedron()
plot_polygon(irispy.Polyhedron(p.getA()[:-1],
p.getB()[:-1]).getDrawingVertices(),
draw_vertices=True,
facecolor="green",
alpha=0.2) That works fine. The last constraint is: >>> ir.getPolyhedron().getA()[-1], ir.getPolyhedron().getB()[-1]
(array([-0., -1.]), -2.0) which is just the constraint that p = ir.getPolyhedron()
plot_polygon(irispy.Polyhedron(p.getA()[:],
p.getB()[:]).getDrawingVertices(),
draw_vertices=True,
facecolor="green",
alpha=0.2) To see if this was an issue with the way IRIS uses cddlib, I passed the exact same julia> using Polyhedra, CDDLib
julia> A = [
7.2719127679597916902309862052788957953453063964843750000000000000000000000000000000000000000000000000e-01 -6.8643488180003897625169884122442454099655151367187500000000000000000000000000000000000000000000000000e-01;
-9.9227812777442014890993959852494299411773681640625000000000000000000000000000000000000000000000000000e-01 1.2403272608667256782233323519903933629393577575683593750000000000000000000000000000000000000000000000e-01;
4.1480457874537551265698201961862334741226732148788869380950927734375000000000000000000000000000000000e-08 -9.9999999999999911182158029987476766109466552734375000000000000000000000000000000000000000000000000000e-01;
1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00;
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00;
-1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 -0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00;
-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 -1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00;
];
julia> b = [
3.7378473714697459939770851633511483669281005859375 ,
-3.47297834459160004172417757217772305011749267578125,
-1.9999989615082682803404168225824832916259765625 ,
8. ,
3.87999999999999989341858963598497211933135986328125,
-3.75 ,
-2.
];
julia> h = SimpleHRepresentation(A, b);
julia> p = polyhedron(h, CDDLibrary());
julia> vrep(p)
V-representation
begin
2 3 real
1.0 3.750000823973488 2.0
3.419486915845482e-14 8.557499217096555e-13 6.838973831690964e-14
end The same exact A and B inputs, when passed to CDD in "exact" (rational) mode give correct vertices: julia> p = polyhedron(h, CDDLibrary(:exact));
julia> vrep(p)
V-representation
begin
5 3 rational
1//1 160402435284077913733595294199767//40251582856530797108415980109824 4368491638549381//1125899906842624
1//1 67032365826159611//17875293625971088 2//1
1//1 23016623785096468//3274978363205447 2//1
1//1 8//1 4683029438162320//1545713938944383
1//1 8//1 4368491638549381//1125899906842624
end
julia> Float64.(SimpleVRepresentation(vrep(p)).V)
5×2 Array{Float64,2}:
3.985 3.88
3.75 2.0
7.02802 2.0
8.0 3.02969
8.0 3.88 So, ultimately, this just boils down to a lesson I've learned many times over: never trust |
Hello,
I'm not sure if this is a bug, or if obstacles are not allowed to exceed the bounds and this is expected behavior.
Basically, IRIS is returning a degenerate region that is invalid when there are obstacles that intersect the environment bounds.
The left figure shows, in green, the region that IRIS returns when using the obstacles in blue, the seed point as the red cross and when the boundary is the large box with black edges.
On the right, the same result when the boundary used is the yellow area instead. As you can see the region returned consists of three vertices where two of them are the same point. Moreover, one of those vertices is outside the boundary.
Just leaving this here in case this is something that should be fixed.
By the way, thanks for making this available, Robin. It works fantastically well and it's really easy to use!
The vertices of the regions are:
The code I used to generate this problem is the following (Jupyter notebook):
The text was updated successfully, but these errors were encountered: