robotic 0.3.4.dev1__cp312-cp312-manylinux2014_x86_64.whl → 0.3.4.dev3__cp312-cp312-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of robotic might be problematic. Click here for more details.
- robotic/_robotic.pyi +43 -15
- robotic/_robotic.so +0 -0
- robotic/include/rai/Algo/RidgeRegression.h +1 -1
- robotic/include/rai/Algo/rungeKutta.h +1 -1
- robotic/include/rai/Core/array.h +31 -22
- robotic/include/rai/Core/array.ipp +59 -74
- robotic/include/rai/Core/arrayDouble.h +29 -25
- robotic/include/rai/Core/defines.h +0 -1
- robotic/include/rai/Core/thread.h +1 -1
- robotic/include/rai/Core/util.h +0 -1
- robotic/include/rai/DataGen/shapenetGrasps.h +1 -1
- robotic/include/rai/Geo/geo.h +7 -7
- robotic/include/rai/Geo/mesh.h +2 -2
- robotic/include/rai/Geo/pairCollision.h +42 -42
- robotic/include/rai/Geo/signedDistanceFunctions.h +5 -3
- robotic/include/rai/KOMO/komo.h +1 -1
- robotic/include/rai/Kin/cameraview.h +27 -16
- robotic/include/rai/Kin/dof_forceExchange.h +3 -3
- robotic/include/rai/Kin/feature.h +1 -1
- robotic/include/rai/Kin/frame.h +1 -1
- robotic/include/rai/Kin/proxy.h +1 -1
- robotic/include/rai/Kin/simulation.h +5 -3
- robotic/include/rai/Logic/treeSearchDomain.h +2 -2
- robotic/include/rai/Optim/BayesOpt.h +14 -7
- robotic/include/rai/Optim/CMA/boundary_transformation.h +73 -0
- robotic/include/rai/Optim/CMA/cmaes.h +175 -0
- robotic/include/rai/Optim/CMA/cmaes_interface.h +68 -0
- robotic/include/rai/Optim/GlobalIterativeNewton.h +7 -3
- robotic/include/rai/Optim/NLP.h +15 -1
- robotic/include/rai/Optim/NLP_Solver.h +5 -5
- robotic/include/rai/Optim/constrained.h +3 -3
- robotic/include/rai/Optim/lagrangian.h +6 -5
- robotic/include/rai/Optim/m_EvoStrategies.h +113 -0
- robotic/include/rai/Optim/{gradient.h → m_Gradient.h} +12 -13
- robotic/include/rai/Optim/m_LBFGS.h +21 -0
- robotic/include/rai/Optim/m_LeastSquaresZeroOrder.h +34 -13
- robotic/include/rai/Optim/m_LocalGreedy.h +31 -0
- robotic/include/rai/Optim/m_NelderMead.h +23 -0
- robotic/include/rai/Optim/{newton.h → m_Newton.h} +8 -5
- robotic/include/rai/Optim/options.h +7 -7
- robotic/include/rai/Optim/primalDual.h +9 -5
- robotic/include/rai/Optim/testProblems_Opt.h +5 -5
- robotic/include/rai/Optim/utils.h +10 -20
- robotic/include/rai/Search/TreeSearchNode.h +1 -1
- robotic/librai.so +0 -0
- robotic/meshTool +0 -0
- robotic/version.py +1 -1
- {robotic-0.3.4.dev1.dist-info → robotic-0.3.4.dev3.dist-info}/METADATA +1 -1
- {robotic-0.3.4.dev1.dist-info → robotic-0.3.4.dev3.dist-info}/RECORD +70 -64
- robotic/include/rai/Optim/lbfgs.h +0 -18
- /robotic/include/rai/Geo/{assimpInterface.h → i_assimp.h} +0 -0
- /robotic/include/rai/Geo/{fclInterface.h → i_fcl.h} +0 -0
- /robotic/include/rai/Kin/{kin_bullet.h → i_Bullet.h} +0 -0
- /robotic/include/rai/Kin/{kin_feather.h → i_Feather.h} +0 -0
- /robotic/include/rai/Kin/{kin_ode.h → i_Ode.h} +0 -0
- /robotic/include/rai/Kin/{kin_physx.h → i_Physx.h} +0 -0
- /robotic/include/rai/Optim/{opt-ceres.h → i_Ceres.h} +0 -0
- /robotic/include/rai/Optim/{opt-ipopt.h → i_Ipopt.h} +0 -0
- /robotic/include/rai/Optim/{opt-nlopt.h → i_NLopt.h} +0 -0
- /robotic/include/rai/Optim/{liblbfgs.h → liblbfgs/liblbfgs.h} +0 -0
- /robotic/include/rai/Optim/{SlackGaussNewton.h → m_SlackGaussNewton.h} +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-bot +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-h5info +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-info +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-meshTool +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-test +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-urdfConvert.py +0 -0
- {robotic-0.3.4.dev1.data → robotic-0.3.4.dev3.data}/scripts/ry-view +0 -0
- {robotic-0.3.4.dev1.dist-info → robotic-0.3.4.dev3.dist-info}/WHEEL +0 -0
- {robotic-0.3.4.dev1.dist-info → robotic-0.3.4.dev3.dist-info}/licenses/LICENSE +0 -0
- {robotic-0.3.4.dev1.dist-info → robotic-0.3.4.dev3.dist-info}/top_level.txt +0 -0
|
@@ -284,22 +284,23 @@ arr& getNoArr();
|
|
|
284
284
|
/// @{
|
|
285
285
|
|
|
286
286
|
/// a generic vector-valued function \f$f:~x\mapsto y\in\mathbb{R}^d\f$, where return value may have Jacobian attached
|
|
287
|
-
typedef std::function<arr(const arr& x)> fct;
|
|
287
|
+
// typedef std::function<arr(const arr& x)> fct;
|
|
288
288
|
typedef std::function<arr(const arr& x)> VectorFunction;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
289
|
+
typedef std::function<double(arr& g, arr& H, const arr& x)> ScalarFunction;
|
|
290
|
+
|
|
291
|
+
// /// a scalar function \f$f:~x\mapsto y\in\mathbb{R}\f$ with optional gradient and hessian
|
|
292
|
+
// struct ScalarFunction {
|
|
293
|
+
// uint dim;
|
|
294
|
+
// virtual double f(arr& g, arr& H, const arr& x) = 0;
|
|
295
|
+
// virtual ~ScalarFunction() {}
|
|
296
|
+
// std::function<double(const arr& x)> cfunc(){ return [this](const arr& x){ return this->f(NoArr, NoArr, x); }; }
|
|
297
|
+
// };
|
|
298
|
+
|
|
299
|
+
// struct Conv_cfunc2ScalarFunction : ScalarFunction {
|
|
300
|
+
// std::function<double(arr& g, arr& H, const arr& x)> cfunc;
|
|
301
|
+
// Conv_cfunc2ScalarFunction(std::function<double(arr& g, arr& H, const arr& x)> _cfunc) : cfunc(_cfunc) {}
|
|
302
|
+
// double f(arr& g, arr& H, const arr& x){ return cfunc(g, H, x); }
|
|
303
|
+
// };
|
|
303
304
|
|
|
304
305
|
/// a kernel function
|
|
305
306
|
struct KernelFunction {
|
|
@@ -370,6 +371,7 @@ inline arr range(double lo, double hi, uint steps) { return rai::grid(1, lo, hi,
|
|
|
370
371
|
//inline uintA range(uint n) { uintA r; r.setStraightPerm(n); return r; }
|
|
371
372
|
|
|
372
373
|
arr repmat(const arr& A, uint m, uint n);
|
|
374
|
+
arr match(const arr& A, const uintA& shape);
|
|
373
375
|
|
|
374
376
|
//inline uintA randperm(uint n) { uintA z; z.setRandomPerm(n); return z; }
|
|
375
377
|
inline arr linspace(double base, double limit, uint n) { return rai::grid(1, base, limit, n).reshape(-1); }
|
|
@@ -437,11 +439,13 @@ arr reshapeColor(const arr& col, int d0=-1);
|
|
|
437
439
|
|
|
438
440
|
void scanArrFile(const char* name);
|
|
439
441
|
|
|
440
|
-
arr
|
|
441
|
-
arr
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
bool
|
|
442
|
+
arr finiteDifference_gradient(ScalarFunction f, const arr& x0, double y0, double eps=1e-8);
|
|
443
|
+
arr finiteDifference_jacobian(VectorFunction f, const arr& x0, const arr& y0, double eps=1e-8);
|
|
444
|
+
// arr finiteDifferenceGradient(ScalarFunction f, const arr& x, arr& Janalytic=NoArr, double eps=1e-8);
|
|
445
|
+
// arr finiteDifferenceJacobian(VectorFunction f, const arr& _x, arr& Janalytic=NoArr, double eps=1e-8);
|
|
446
|
+
bool checkGradient(ScalarFunction f, const arr& x, double tolerance, bool verbose=false);
|
|
447
|
+
bool checkHessian(ScalarFunction f, const arr& x, double tolerance, bool verbose=false);
|
|
448
|
+
bool checkJacobian(VectorFunction f, const arr& x, double tolerance, bool verbose=false, const StringA& featureNames= {});
|
|
445
449
|
void boundClip(arr& y, const arr& bounds);
|
|
446
450
|
bool boundCheck(const arr& x, const arr& bounds, double eps=1e-3, bool verbose=true);
|
|
447
451
|
|
|
@@ -494,8 +498,8 @@ double euclideanDistance(const arr& v, const arr& w);
|
|
|
494
498
|
double metricDistance(const arr& g, const arr& v, const arr& w);
|
|
495
499
|
|
|
496
500
|
//min max
|
|
497
|
-
arr max(const arr& v, uint
|
|
498
|
-
arr min(const arr& v, uint
|
|
501
|
+
arr max(const arr& v, uint axis);
|
|
502
|
+
arr min(const arr& v, uint axis);
|
|
499
503
|
uint argmin(const arr& x);
|
|
500
504
|
uint argmax(const arr& x);
|
|
501
505
|
void argmax(uint& i, uint& j, const arr& x);
|
|
@@ -505,7 +509,7 @@ double absMax(const arr& x);
|
|
|
505
509
|
double absMin(const arr& x);
|
|
506
510
|
|
|
507
511
|
double sum(const arr& v);
|
|
508
|
-
arr sum(const arr& v, uint
|
|
512
|
+
arr sum(const arr& v, uint axis);
|
|
509
513
|
double sumOfAbs(const arr& v);
|
|
510
514
|
double sumOfPos(const arr& v);
|
|
511
515
|
double sumOfSqr(const arr& v);
|
|
@@ -514,9 +518,9 @@ double product(const arr& v);
|
|
|
514
518
|
|
|
515
519
|
double trace(const arr& v);
|
|
516
520
|
double var(const arr& v);
|
|
517
|
-
arr mean(const arr& v);
|
|
521
|
+
arr mean(const arr& v, uint axis=0);
|
|
518
522
|
arr covar(const arr& X);
|
|
519
|
-
arr
|
|
523
|
+
arr vardiag(const arr& X);
|
|
520
524
|
void clip(const arr& x, double lo, double hi);
|
|
521
525
|
|
|
522
526
|
void op_transpose(arr& x, const arr& y);
|
|
@@ -140,7 +140,7 @@ struct Var_data : Var_base {
|
|
|
140
140
|
|
|
141
141
|
Var_data(const char* name=0) : Var_base(name), data() {} // default constructor for value always initializes, also primitive types 'bool' or 'int'
|
|
142
142
|
~Var_data() {
|
|
143
|
-
if(rwlock.isLocked()) {
|
|
143
|
+
if(rwlock.isLocked()) { cout << "can't destroy a variable when it is currently accessed!" <<endl; exit(1); }
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
robotic/include/rai/Core/util.h
CHANGED
robotic/include/rai/Geo/geo.h
CHANGED
|
@@ -244,8 +244,8 @@ struct Camera {
|
|
|
244
244
|
|
|
245
245
|
float heightAbs;
|
|
246
246
|
float focalLength;
|
|
247
|
-
float whRatio;
|
|
248
247
|
float zNear, zFar;
|
|
248
|
+
float width=640., height=480.;
|
|
249
249
|
|
|
250
250
|
Camera();
|
|
251
251
|
|
|
@@ -253,8 +253,8 @@ struct Camera {
|
|
|
253
253
|
void setHeightAngle(float a);
|
|
254
254
|
void setHeightAbs(float h);
|
|
255
255
|
void setZRange(float znear, float zfar);
|
|
256
|
-
void setWHRatio(float ratio);
|
|
257
256
|
void setFocalLength(float f);
|
|
257
|
+
void setWidthHeight(float w, float h);
|
|
258
258
|
void setPosition(const Vector& x);
|
|
259
259
|
void setKinect();
|
|
260
260
|
void setDefault();
|
|
@@ -274,12 +274,12 @@ struct Camera {
|
|
|
274
274
|
arr getInverseProjectionMatrix() const;
|
|
275
275
|
double glConvertToTrueDepth(double d) const;
|
|
276
276
|
double glConvertToLinearDepth(double d) const;
|
|
277
|
-
void project2PixelsAndTrueDepth(arr& x
|
|
278
|
-
void unproject_fromPixelsAndTrueDepth(arr& x
|
|
279
|
-
void unproject_fromPixelsAndGLDepth(arr& x
|
|
277
|
+
void project2PixelsAndTrueDepth(arr& x) const;
|
|
278
|
+
void unproject_fromPixelsAndTrueDepth(arr& x) const;
|
|
279
|
+
void unproject_fromPixelsAndGLDepth(arr& x) const;
|
|
280
280
|
|
|
281
|
-
arr getFxycxy(
|
|
282
|
-
arr getIntrinsicMatrix(
|
|
281
|
+
arr getFxycxy();
|
|
282
|
+
arr getIntrinsicMatrix() const;
|
|
283
283
|
|
|
284
284
|
//retired
|
|
285
285
|
void setCameraProjectionMatrix(const arr& P); //P is in standard convention -> computes fixedProjectionMatrix in OpenGL convention from this
|
robotic/include/rai/Geo/mesh.h
CHANGED
|
@@ -68,11 +68,11 @@ struct Mesh {
|
|
|
68
68
|
void setCapsule(double r, double l, uint fineness=2);
|
|
69
69
|
void setSSBox(double x_width, double y_width, double z_height, double r, uint fineness=2);
|
|
70
70
|
void setSSCvx(const arr& core, double r, uint fineness=2);
|
|
71
|
-
void setImplicitSurface(
|
|
71
|
+
void setImplicitSurface(ScalarFunction f, double lo=-10., double up=+10., uint res=100);
|
|
72
72
|
void setImplicitSurface(std::function<double(const arr& x)> f, const arr& bounds, uint res);
|
|
73
73
|
void setImplicitSurface(const arr& gridValues, const arr& size);
|
|
74
74
|
void setImplicitSurface(const floatA& gridValues, const arr& size);
|
|
75
|
-
void setImplicitSurfaceBySphereProjection(ScalarFunction
|
|
75
|
+
void setImplicitSurfaceBySphereProjection(ScalarFunction f, double rad, uint fineness=3);
|
|
76
76
|
Mesh& setRandom(uint vertices=10);
|
|
77
77
|
void setGrid(uint X, uint Y);
|
|
78
78
|
|
|
@@ -13,43 +13,18 @@
|
|
|
13
13
|
|
|
14
14
|
namespace rai {
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
* The constructor compute the collision geometry, the other methods are mostly readouts
|
|
18
|
-
* The default is distance between two convex meshes
|
|
19
|
-
* Also distance between point (=mesh1) and points (=mesh2)
|
|
20
|
-
* Also distance between point (=mesh1) and decomposed mesh (=mesh2)
|
|
21
|
-
*/
|
|
22
|
-
struct PairCollision : NonCopyable {
|
|
16
|
+
struct PairCollision {
|
|
23
17
|
//INPUTS
|
|
24
|
-
arr mesh1;
|
|
25
|
-
arr mesh2;
|
|
26
|
-
const rai::Transformation* t1=0;
|
|
27
|
-
const rai::Transformation* t2=0;
|
|
28
18
|
double rad1=0., rad2=0.; ///< only kinVector and glDraw account for this; the basic collision geometry (OUTPUTS below) is computed neglecting radii!!
|
|
29
19
|
|
|
30
20
|
//OUTPUTS
|
|
31
21
|
double distance=0.; ///< negative=penetration
|
|
32
|
-
arr p1, p2;
|
|
33
|
-
arr normal;
|
|
34
|
-
arr
|
|
35
|
-
arr simplex2; ///< simplex on obj2 defining the collision geometry
|
|
36
|
-
|
|
37
|
-
// arr m1, m2, eig1, eig2; ///< output of marginAnalysis: mean and eigenvalues of ALL point on the objs (not only simplex) that define the collision
|
|
38
|
-
|
|
39
|
-
arr poly, polyNorm;
|
|
40
|
-
|
|
41
|
-
//mesh-to-mesh
|
|
42
|
-
PairCollision(const arr& mesh1, const arr& mesh2,
|
|
43
|
-
const rai::Transformation& t1, const rai::Transformation& t2,
|
|
44
|
-
double rad1=0., double rad2=0.);
|
|
45
|
-
//sdf-to-sdf
|
|
46
|
-
PairCollision(ScalarFunction& func1, ScalarFunction& func2, const arr& seed);
|
|
47
|
-
|
|
48
|
-
~PairCollision() {}
|
|
49
|
-
|
|
50
|
-
void write(std::ostream& os) const;
|
|
22
|
+
arr p1, p2; ///< witness points on the shapes
|
|
23
|
+
arr normal; ///< normal such that "<normal, p1-p2> = distance" is guaranteed (pointing from obj2 to obj1)
|
|
24
|
+
arr simp1, simp2; ///< simplices on the shapes defining the collision geometry
|
|
51
25
|
|
|
52
26
|
double getDistance() { return distance-rad1-rad2; }
|
|
27
|
+
void write(std::ostream& os) const;
|
|
53
28
|
|
|
54
29
|
// differentiable readout methods (Jp1 and Jx1 are linear and angular Jacobians of mesh1)
|
|
55
30
|
void kinDistance(arr& y, arr& J, const arr& Jp1, const arr& Jp2);
|
|
@@ -59,27 +34,52 @@ struct PairCollision : NonCopyable {
|
|
|
59
34
|
void kinPointP2(arr& y, arr& J, const arr& Jp1, const arr& Jp2, const arr& Jx1, const arr& Jx2);
|
|
60
35
|
void kinCenter(arr& y, arr& J, const arr& Jp1, const arr& Jp2, const arr& Jx1, const arr& Jx2);
|
|
61
36
|
|
|
62
|
-
|
|
37
|
+
protected:
|
|
38
|
+
bool simplexType(uint i, uint j) { return simp1.d0==i && simp2.d0==j; } //helper
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//===========================================================================
|
|
42
|
+
|
|
43
|
+
/* A class to represent a basic function: distance between two convex (decomposed) meshes
|
|
44
|
+
* The constructor compute the collision geometry, the other methods are mostly readouts
|
|
45
|
+
* The default is distance between two convex meshes
|
|
46
|
+
* Also distance between point (=mesh1) and points (=mesh2)
|
|
47
|
+
* Also distance between point (=mesh1) and decomposed mesh (=mesh2)
|
|
48
|
+
*/
|
|
49
|
+
struct PairCollision_CvxCvx : PairCollision, NonCopyable {
|
|
63
50
|
|
|
64
|
-
|
|
51
|
+
//mesh-to-mesh
|
|
52
|
+
PairCollision_CvxCvx(const arr& pts1, const arr& pts2,
|
|
53
|
+
const rai::Transformation& t1, const rai::Transformation& t2,
|
|
54
|
+
double rad1=0., double rad2=0.);
|
|
55
|
+
//sdf-to-sdf -- TODO: own class!
|
|
56
|
+
PairCollision_CvxCvx(ScalarFunction func1, ScalarFunction func2, const arr& seed);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// void nearSupportAnalysis(double eps=1e-6); ///< analyses not only closest obj support (the simplex) but all points within a margin
|
|
60
|
+
|
|
61
|
+
private:
|
|
65
62
|
//wrappers of external libs
|
|
66
63
|
enum CCDmethod { _ccdGJKIntersect, _ccdGJKSeparate, _ccdGJKPenetration, _ccdMPRIntersect, _ccdMPRPenetration };
|
|
67
64
|
void libccd(const arr& m1, const arr& m2, CCDmethod method); //calls ccdMPRPenetration of libccd
|
|
68
|
-
void GJK_sqrDistance(); //gjk_distance of libGJK
|
|
69
|
-
bool simplexType(uint i, uint j) { return simplex1.d0==i && simplex2.d0==j; } //helper
|
|
65
|
+
void GJK_sqrDistance(const arr& pts1, const arr& pts2, const rai::Transformation& t1, const rai::Transformation& t2); //gjk_distance of libGJK
|
|
70
66
|
};
|
|
71
67
|
|
|
72
68
|
//===========================================================================
|
|
73
69
|
|
|
74
|
-
struct
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
struct PairCollision_CvxDecomp : PairCollision, NonCopyable {
|
|
71
|
+
PairCollision_CvxDecomp(const arr& x, Mesh& mesh,
|
|
72
|
+
const rai::Transformation& t1, const rai::Transformation& t2,
|
|
73
|
+
double rad1=0., double rad2=0.);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//===========================================================================
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const rai::Transformation&
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
struct PairCollision_PtPcl : PairCollision, NonCopyable {
|
|
79
|
+
PairCollision_PtPcl(const arr& x, ANN& ann,
|
|
80
|
+
const rai::Transformation& t1,
|
|
81
|
+
const rai::Transformation& t2,
|
|
82
|
+
double rad1=0., double rad2=0.);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
//===========================================================================
|
|
@@ -16,15 +16,17 @@
|
|
|
16
16
|
// analytic distance functions
|
|
17
17
|
//
|
|
18
18
|
|
|
19
|
-
struct SDF
|
|
19
|
+
struct SDF {
|
|
20
20
|
SDF(const rai::Transformation& _pose)
|
|
21
|
-
|
|
21
|
+
: pose(_pose) {}
|
|
22
22
|
~SDF() {}
|
|
23
23
|
rai::Transformation pose;
|
|
24
24
|
arr lo, up;
|
|
25
25
|
virtual double f(arr& g, arr& H, const arr& x);
|
|
26
26
|
virtual double f_raw(arr& g, arr& H, const arr& x) { NIY; }
|
|
27
27
|
|
|
28
|
+
ScalarFunction f_scalar(){ return [this](arr& g, arr& H, const arr& x){ return this->f(g, H, x); }; }
|
|
29
|
+
|
|
28
30
|
arr eval(const arr& samples);
|
|
29
31
|
floatA evalFloat(const arr& samples);
|
|
30
32
|
floatA evalGrid(uint d0, int d1=-1, int d2=-1);
|
|
@@ -157,4 +159,4 @@ struct PCL2Field {
|
|
|
157
159
|
|
|
158
160
|
//===========================================================================
|
|
159
161
|
|
|
160
|
-
|
|
162
|
+
ScalarFunction DistanceFunction_SSBox();
|
robotic/include/rai/KOMO/komo.h
CHANGED
|
@@ -165,7 +165,7 @@ struct KOMO : rai::NonCopyable {
|
|
|
165
165
|
void updateAndShiftPrefix(const rai::Configuration& C);
|
|
166
166
|
|
|
167
167
|
//-- calling a solver
|
|
168
|
-
std::shared_ptr<SolverReturn> solve(double addInitializationNoise=.01, int splineKnots=-1, const rai::OptOptions& options
|
|
168
|
+
std::shared_ptr<SolverReturn> solve(double addInitializationNoise=.01, int splineKnots=-1, const rai::OptOptions& options=*DEFAULT_OPTIONS); ///< run the solver (same as run_prepare(); run(); )
|
|
169
169
|
void reset(); ///< reset the dual variables and feature value buffers (always needed when adding/changing objectives before continuing an optimization)
|
|
170
170
|
|
|
171
171
|
//advanced
|
|
@@ -14,43 +14,50 @@
|
|
|
14
14
|
|
|
15
15
|
namespace rai {
|
|
16
16
|
|
|
17
|
+
struct DepthNoiseOptions {
|
|
18
|
+
RAI_PARAM("DepthNoise/", double, binocular_baseline, .05)
|
|
19
|
+
RAI_PARAM("DepthNoise/", int, depth_smoothing, 1)
|
|
20
|
+
RAI_PARAM("DepthNoise/", double, noise_all, .05)
|
|
21
|
+
RAI_PARAM("DepthNoise/", double, noise_wide, 4.)
|
|
22
|
+
RAI_PARAM("DepthNoise/", double, noise_local, .4)
|
|
23
|
+
RAI_PARAM("DepthNoise/", double, noise_pixel, .04)
|
|
24
|
+
};
|
|
25
|
+
|
|
17
26
|
struct CameraView : ConfigurationViewer {
|
|
18
27
|
|
|
19
|
-
/*!
|
|
20
|
-
struct
|
|
21
|
-
rai::
|
|
22
|
-
rai::Camera cam;
|
|
23
|
-
|
|
24
|
-
rai::Frame
|
|
25
|
-
Sensor() {}
|
|
26
|
-
rai::Transformation& pose() { return cam.X; }
|
|
27
|
-
arr getFxycxy() { return cam.getFxycxy(width, height); }
|
|
28
|
+
/*! a camera attached (and defined by the attributes of) a Frame */
|
|
29
|
+
struct CameraFrame {
|
|
30
|
+
rai::Frame& frame;
|
|
31
|
+
rai::Camera cam;
|
|
32
|
+
rai::Vector offset=0;
|
|
33
|
+
CameraFrame(rai::Frame& _frame) : frame(_frame) {}
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
//-- description of world configuration
|
|
31
|
-
rai::Array<
|
|
37
|
+
rai::Array<shared_ptr<CameraFrame>> cameras; //the list of sensors
|
|
32
38
|
|
|
33
39
|
enum RenderMode { all, seg, visuals };
|
|
34
40
|
|
|
35
41
|
//-- run parameter
|
|
36
|
-
|
|
42
|
+
shared_ptr<CameraFrame> currentCamera;
|
|
37
43
|
RenderMode renderMode=all;
|
|
38
44
|
byteA frameIDmap;
|
|
45
|
+
shared_ptr<DepthNoiseOptions> opt;
|
|
39
46
|
|
|
40
47
|
//-- evaluation outputs
|
|
41
48
|
CameraView(const rai::Configuration& _C, bool _offscreen=true);
|
|
42
49
|
~CameraView() {}
|
|
43
50
|
|
|
44
51
|
//-- loading the configuration: the meshes, the robot model, the tote, the sensors; all ends up in K
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
CameraFrame& setCamera(rai::Frame* frame, uint width, uint height, double focalLength=-1., double orthoAbsHeight=-1., const arr& zRange= {}, const char* backgroundImageFile=0);
|
|
53
|
+
CameraFrame& setCamera(rai::Frame* frame); //read everything from the frame attributes
|
|
54
|
+
CameraFrame& selectSensor(rai::Frame* frame); //set the OpenGL sensor
|
|
48
55
|
|
|
49
|
-
void computeImageAndDepth(byteA& image, floatA& depth);
|
|
56
|
+
void computeImageAndDepth(byteA& image, floatA& depth, bool _simulateDepthNoise=false);
|
|
50
57
|
byteA computeSegmentationImage();
|
|
51
58
|
uintA computeSegmentationID();
|
|
52
59
|
|
|
53
|
-
arr getFxycxy() { CHECK(
|
|
60
|
+
arr getFxycxy() { CHECK(currentCamera, "no sensor selected yet"); return currentCamera->cam.getFxycxy(); }
|
|
54
61
|
|
|
55
62
|
private:
|
|
56
63
|
void updateCamera();
|
|
@@ -79,4 +86,8 @@ struct Sim_CameraView : Thread {
|
|
|
79
86
|
arr getFxycxy();
|
|
80
87
|
};
|
|
81
88
|
|
|
89
|
+
//===========================================================================
|
|
90
|
+
|
|
91
|
+
void simulateDepthNoise(floatA& depth, const floatA& depth2, double offset, const arr& fxycxy, shared_ptr<DepthNoiseOptions> opt);
|
|
92
|
+
|
|
82
93
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
namespace rai {
|
|
15
15
|
|
|
16
|
-
struct
|
|
16
|
+
struct PairCollision_CvxCvx;
|
|
17
17
|
|
|
18
18
|
//===========================================================================
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ struct ForceExchangeDof : Dof, NonCopyable {
|
|
|
26
26
|
double scale=1.;
|
|
27
27
|
double force_to_torque = 0.;
|
|
28
28
|
private:
|
|
29
|
-
|
|
29
|
+
PairCollision_CvxCvx* __coll=0;
|
|
30
30
|
public:
|
|
31
31
|
|
|
32
32
|
arr poa; //in world coordinates!
|
|
@@ -50,7 +50,7 @@ struct ForceExchangeDof : Dof, NonCopyable {
|
|
|
50
50
|
virtual void kinForce(arr& y, arr& J) const;
|
|
51
51
|
virtual void kinTorque(arr& y, arr& J) const;
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
PairCollision_CvxCvx* coll();
|
|
54
54
|
|
|
55
55
|
virtual void write(ostream& os) const;
|
|
56
56
|
};
|
|
@@ -49,7 +49,7 @@ struct Feature {
|
|
|
49
49
|
// Value eval(const FrameL& F) { arr y, J; eval(y, J, F); return Value(y, J); }
|
|
50
50
|
arr eval(const rai::Configuration& C) { return eval(getFrames(C)); }
|
|
51
51
|
uint dim(const FrameL& F) { uint d=dim_phi(F); return applyLinearTrans_dim(d); }
|
|
52
|
-
|
|
52
|
+
VectorFunction asFct(const FrameL& F);
|
|
53
53
|
|
|
54
54
|
virtual const char* typeString() { return rai::niceTypeidName(typeid(*this)); }
|
|
55
55
|
virtual rai::String shortTag(const rai::Configuration& C);
|
robotic/include/rai/Kin/frame.h
CHANGED
|
@@ -346,7 +346,7 @@ struct Shape : NonCopyable {
|
|
|
346
346
|
double alpha() { arr& C=mesh().C; if(C.N==4 || C.N==2 || (C.nd==2 && C.d1==4)) return C.elem(-1); return 1.; }
|
|
347
347
|
|
|
348
348
|
void createMeshes(const str& name);
|
|
349
|
-
shared_ptr<
|
|
349
|
+
shared_ptr<SDF> functional(const rai::Transformation& pose=0);
|
|
350
350
|
|
|
351
351
|
bool canCollide(const rai::Frame* f1, const Frame* f2) const;
|
|
352
352
|
|
robotic/include/rai/Kin/proxy.h
CHANGED
|
@@ -30,6 +30,7 @@ struct Simulation {
|
|
|
30
30
|
uint stepCount=0;
|
|
31
31
|
Engine engine;
|
|
32
32
|
Array<shared_ptr<SimulationImp>> imps; ///< list of (adversarial) imps doing things/perturbations/noise in addition to clean physics engine
|
|
33
|
+
bool simulateDepthNoise=false;
|
|
33
34
|
int verbose;
|
|
34
35
|
int writeData=0;
|
|
35
36
|
ofstream dataFile;
|
|
@@ -72,12 +73,13 @@ struct Simulation {
|
|
|
72
73
|
void getImageAndDepth(byteA& image, floatA& depth); ///< use this during stepping
|
|
73
74
|
void getSegmentation(byteA& segmentation);
|
|
74
75
|
CameraView& cameraview(); ///< use this if you want to initialize the sensor, etc
|
|
75
|
-
rai::CameraView::
|
|
76
|
+
rai::CameraView::CameraFrame& addSensor(const char* sensorName, uint width=640, uint height=360, double focalLength=-1., double orthoAbsHeight=-1., const arr& zRange= {}) {
|
|
76
77
|
rai::Frame *f = C.getFrame(sensorName);
|
|
77
78
|
CHECK(f, "a camera frame must exist");
|
|
78
|
-
return cameraview().
|
|
79
|
+
return cameraview().setCamera(f, width, height, focalLength, orthoAbsHeight, zRange);
|
|
79
80
|
}
|
|
80
|
-
rai::CameraView::
|
|
81
|
+
rai::CameraView::CameraFrame& selectSensor(const char* name) { return cameraview().selectSensor(C.getFrame(name)); }
|
|
82
|
+
void setSimulateDepthNoise(bool _simulateDepthNoise) { simulateDepthNoise=_simulateDepthNoise; }
|
|
81
83
|
byteA getScreenshot();
|
|
82
84
|
|
|
83
85
|
//== ground truth interface
|
|
@@ -65,7 +65,7 @@ struct TreeSearchDomain {
|
|
|
65
65
|
virtual const Handle get_stateCopy() = 0;
|
|
66
66
|
|
|
67
67
|
/// Get the current state
|
|
68
|
-
virtual void set_state(const Handle& stateCopy) { std::
|
|
68
|
+
virtual void set_state(const Handle& stateCopy) { std::cout <<"not implemented for world of type " <<typeid(this).name() <<std::endl; exit(-1); }
|
|
69
69
|
|
|
70
70
|
/// Return whether the current state is a terminal state
|
|
71
71
|
virtual bool is_terminal_state() const = 0;
|
|
@@ -81,7 +81,7 @@ struct TreeSearchDomain {
|
|
|
81
81
|
virtual bool get_info(InfoTag tag) const = 0;
|
|
82
82
|
virtual double get_info_value(InfoTag tag) const = 0;
|
|
83
83
|
|
|
84
|
-
virtual void write(std::ostream& os) const { std::
|
|
84
|
+
virtual void write(std::ostream& os) const { std::cout <<"NOT OVERLOADED!" <<std::endl; }
|
|
85
85
|
};
|
|
86
86
|
inline std::ostream& operator<<(std::ostream& os, const TreeSearchDomain& E) { E.write(os); return os; }
|
|
87
87
|
inline std::ostream& operator<<(std::ostream& os, const TreeSearchDomain::SAO& x) { x.write(os); return os; }
|
|
@@ -11,30 +11,35 @@
|
|
|
11
11
|
#include "GlobalIterativeNewton.h"
|
|
12
12
|
#include "../Core/array.h"
|
|
13
13
|
|
|
14
|
+
struct KernelRidgeRegression;
|
|
15
|
+
struct DefaultKernelFunction;
|
|
16
|
+
|
|
17
|
+
namespace rai {
|
|
18
|
+
|
|
14
19
|
struct BayesOpt {
|
|
15
|
-
ScalarFunction
|
|
20
|
+
ScalarFunction f;
|
|
16
21
|
arr bounds;
|
|
17
22
|
|
|
18
23
|
arr data_X;
|
|
19
24
|
arr data_y;
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
KernelRidgeRegression* f_now;
|
|
27
|
+
KernelRidgeRegression* f_smaller;
|
|
23
28
|
|
|
24
29
|
GlobalIterativeNewton alphaMinima_now;
|
|
25
30
|
GlobalIterativeNewton alphaMinima_smaller;
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
DefaultKernelFunction* kernel_now;
|
|
33
|
+
DefaultKernelFunction* kernel_smaller;
|
|
29
34
|
double lengthScale;
|
|
30
35
|
|
|
31
36
|
//lengthScale is always relative to hi-lo
|
|
32
|
-
BayesOpt(ScalarFunction
|
|
37
|
+
BayesOpt(ScalarFunction f, const arr& bounds, shared_ptr<OptOptions> opt, double init_lengthScale=1., double prior_var=1.);
|
|
33
38
|
~BayesOpt();
|
|
34
39
|
|
|
35
40
|
void step();
|
|
36
41
|
void run(uint maxIt=10);
|
|
37
|
-
void report(bool display, ScalarFunction
|
|
42
|
+
void report(bool display, ScalarFunction f);
|
|
38
43
|
|
|
39
44
|
private:
|
|
40
45
|
void addDataPoint(const arr& x, double y); //and update the regressions
|
|
@@ -42,3 +47,5 @@ struct BayesOpt {
|
|
|
42
47
|
arr pickNextPoint();
|
|
43
48
|
void reduceLengthScale();
|
|
44
49
|
};
|
|
50
|
+
|
|
51
|
+
} //namespace
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* INTERFACE: the relevant functions are
|
|
3
|
+
*
|
|
4
|
+
* * cmaes_boundary_transformation_init(this, l_bound, u_bound, len)
|
|
5
|
+
* * cmaes_boundary_transformation_exit(this)
|
|
6
|
+
* * cmaes_boundary_transformation(this, x, y, len)
|
|
7
|
+
*
|
|
8
|
+
* implements a smooth mapping double *x -> double *y that guarantees
|
|
9
|
+
* elements of y to be within specified boundaries. The mapping is piecewise
|
|
10
|
+
* either linear or quadratic and can achieve values arbitrarily close to and
|
|
11
|
+
* on the boundaries. The middle of the domain l_bound + (u_bound-l_bound) / 2.0
|
|
12
|
+
* always maps to itself. Typically, 90% of feasible values (those not close
|
|
13
|
+
* to the boundaries) are mapped to themselves, preventing any numerical subtleties.
|
|
14
|
+
* Specifically, al, au > 0 are internally chosen offsets. The mapping
|
|
15
|
+
* [l_bound - al, u_bound + au] <-> [l_bound, u_bound] is monotonous, bijective
|
|
16
|
+
* and invertible. It is the identity within [l_bound + al, u_bound - au] and
|
|
17
|
+
* quadratic for [l_bound - 3*al, l_bound + al] (with l_bound - al -> l_bound)
|
|
18
|
+
* and for [u_bound - au, u_bound + 3*au] (with u_bound + au -> u_bound).
|
|
19
|
+
*
|
|
20
|
+
* The method is robust against very small/large boundary values, say
|
|
21
|
+
* -1e99 and/or 1e99, to emulated unbounded variables. In this case values
|
|
22
|
+
* between -1e98 and 1e98 are never changed, i.e. mapped to itself.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
typedef struct {
|
|
27
|
+
double const *lower_bounds; /* array of size len_of_bounds */
|
|
28
|
+
double const *upper_bounds; /* array of size len_of_bounds */
|
|
29
|
+
unsigned long len_of_bounds; /* in case, last value is recycled */
|
|
30
|
+
double *al; /* "add"-on to lower boundary preimage, same length as bounds */
|
|
31
|
+
double *au; /* add-on to upper boundary preimage, same length as bounds */
|
|
32
|
+
} cmaes_boundary_transformation_t;
|
|
33
|
+
|
|
34
|
+
/* set lower and upper bounds, the values lower_bounds[len_of_bounds - 1] and
|
|
35
|
+
* upper_bounds[len_of_bounds - 1] are recycled for any element >= len_of_bounds.
|
|
36
|
+
* If len_of_bounds == 0, no bounds are assumed. If len_of_bounds == 1, the
|
|
37
|
+
* zero pointer is allowed for lower_bounds or upper_bounds and indicates no
|
|
38
|
+
* respective bounds. "no bounds" is "emulated" using the very small/large value
|
|
39
|
+
* of DBL_MAX / -1e2 and DBL_MAX / 1e2, respectively. */
|
|
40
|
+
void cmaes_boundary_transformation_init(cmaes_boundary_transformation_t *,
|
|
41
|
+
double const *lower_bounds, double const *upper_bounds, unsigned long len_of_bounds);
|
|
42
|
+
|
|
43
|
+
/* release memory */
|
|
44
|
+
void cmaes_boundary_transformation_exit(cmaes_boundary_transformation_t *);
|
|
45
|
+
|
|
46
|
+
/* on return, y is guaranteed to have all values within the boundaries.
|
|
47
|
+
* The caller inputs x and is responsible for having allocated y in that
|
|
48
|
+
* y[len-1] = x[len-1] is a valid operation. x==y is valid input, but
|
|
49
|
+
* will fail together with cmaes when x is an element of the population
|
|
50
|
+
* returned by cmaes_SamplePopulation (these elements are of type
|
|
51
|
+
* double const * for a reason).
|
|
52
|
+
* */
|
|
53
|
+
void cmaes_boundary_transformation(cmaes_boundary_transformation_t *,
|
|
54
|
+
double const *x, double *y, unsigned long len); /* new value into y */
|
|
55
|
+
|
|
56
|
+
/* after
|
|
57
|
+
* cmaes_boundary_transformation(b,x,y,l) ;
|
|
58
|
+
* the two consecutive calls
|
|
59
|
+
* cmaes_boundary_transformation_inverse(b,y,x,l) ; cmaes_boundary_transformation(b,x,y,l) ;
|
|
60
|
+
* have no effect on y anymore (but they might change x!).
|
|
61
|
+
* */
|
|
62
|
+
void cmaes_boundary_transformation_inverse(cmaes_boundary_transformation_t *t,
|
|
63
|
+
double const *y, double *x, unsigned long len); /* new value into x */
|
|
64
|
+
|
|
65
|
+
/* used by function cmaes_boundary_transformation. After applying the shift,
|
|
66
|
+
* cmaes_boundary_transformation_shift_into_feasible_preimage(b,x,x,l)
|
|
67
|
+
* the two consecutive calls
|
|
68
|
+
* cmaes_boundary_transformation(b,x,y,l) ; cmaes_boundary_transformation_inverse(b,y,x,l) ;
|
|
69
|
+
* have no effect on x anymore */
|
|
70
|
+
void cmaes_boundary_transformation_shift_into_feasible_preimage(cmaes_boundary_transformation_t *t,
|
|
71
|
+
double const *x, double *x_shifted, unsigned long len); /* new value into x_shifted */
|
|
72
|
+
|
|
73
|
+
|