robotic 0.3.1.dev1__cp39-cp39-manylinux2014_x86_64.whl → 0.3.1.dev3__cp39-cp39-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 +35 -14
- robotic/_robotic.so +0 -0
- robotic/include/rai/Control/CtrlSolver.h +1 -1
- robotic/include/rai/Core/defines.h +7 -8
- robotic/include/rai/Core/graph.h +4 -21
- robotic/include/rai/Core/thread.h +11 -11
- robotic/include/rai/Core/util.h +48 -72
- robotic/include/rai/Geo/geo.h +1 -0
- robotic/include/rai/Geo/mesh.h +2 -1
- robotic/include/rai/Gui/RenderData.h +2 -2
- robotic/include/rai/Gui/opengl.h +2 -2
- robotic/include/rai/Gui/plot.h +1 -1
- robotic/include/rai/KOMO/komo.h +1 -1
- robotic/include/rai/KOMO/testProblems_KOMO.h +12 -9
- robotic/include/rai/Kin/frame.h +1 -1
- robotic/include/rai/Kin/kin.h +1 -1
- robotic/include/rai/Kin/kin_physx.h +2 -2
- robotic/include/rai/Kin/simulation.h +2 -2
- robotic/include/rai/Kin/viewer.h +1 -0
- robotic/include/rai/LGP/LGP_computers.h +1 -1
- robotic/include/rai/Optim/NLP.h +1 -1
- robotic/include/rai/Optim/NLP_GraphSolver.h +1 -1
- robotic/include/rai/Optim/testProblems_Opt.h +3 -9
- robotic/include/rai/PathAlgos/ConfigurationProblem.h +2 -2
- robotic/include/rai/PathAlgos/RRT_PathFinder.h +1 -1
- robotic/include/rai/Perception/surfels.h +1 -1
- robotic/include/rai/ry/types.h +1 -0
- robotic/librai.so +0 -0
- robotic/manipulation.py +5 -7
- robotic/meshTool +0 -0
- robotic/src/h5_helper.py +31 -0
- robotic/src/yaml_helper.py +10 -0
- robotic/version.py +1 -1
- {robotic-0.3.1.dev1.dist-info → robotic-0.3.1.dev3.dist-info}/METADATA +1 -1
- {robotic-0.3.1.dev1.dist-info → robotic-0.3.1.dev3.dist-info}/RECORD +45 -44
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-bot +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-h5info +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-info +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-meshTool +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-test +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-urdfConvert.py +0 -0
- {robotic-0.3.1.dev1.data → robotic-0.3.1.dev3.data}/scripts/ry-view +0 -0
- {robotic-0.3.1.dev1.dist-info → robotic-0.3.1.dev3.dist-info}/WHEEL +0 -0
- {robotic-0.3.1.dev1.dist-info → robotic-0.3.1.dev3.dist-info}/licenses/LICENSE +0 -0
- {robotic-0.3.1.dev1.dist-info → robotic-0.3.1.dev3.dist-info}/top_level.txt +0 -0
robotic/_robotic.pyi
CHANGED
|
@@ -6,7 +6,7 @@ import numpy
|
|
|
6
6
|
import typing
|
|
7
7
|
from . import DataGen
|
|
8
8
|
from . import test
|
|
9
|
-
__all__ = ['Actions2KOMO_Translator', 'ArgWord', 'BSpline', 'BotOp', 'CameraView', 'CameraViewSensor', 'Config', 'ConfigurationViewer', 'ControlMode', 'DataGen', 'FS', 'Frame', 'JT', 'KOMO', 'KOMO_Objective', 'LGP_Tool', 'NLP', 'NLP_Factory', 'NLP_Sampler', 'NLP_Solver', 'NLP_SolverOptions', 'OT', 'OptBench_Skeleton_Handover', 'OptBench_Skeleton_Pick', 'OptBench_Skeleton_StackAndBalance', 'OptBenchmark_InvKin_Endeff', 'OptMethod', 'Quaternion', 'RRT_PathFinder', 'ST', 'SY', 'Simulation', 'SimulationEngine', 'Skeleton', 'SolverReturn', 'TAMP_Provider', 'compiled', 'default_Actions2KOMO_Translator', 'default_TAMP_Provider', 'depthImage2PointCloud', 'params_add', 'params_clear', 'params_file', 'params_print', 'raiPath', 'setRaiPath', 'test']
|
|
9
|
+
__all__ = ['Actions2KOMO_Translator', 'ArgWord', 'BSpline', 'BotOp', 'CameraView', 'CameraViewSensor', 'Config', 'ConfigurationViewer', 'ControlMode', 'DataGen', 'FS', 'Frame', 'JT', 'KOMO', 'KOMO_Objective', 'LGP_Tool', 'NLP', 'NLP_Factory', 'NLP_Sampler', 'NLP_Solver', 'NLP_SolverOptions', 'OT', 'OptBench_Skeleton_Handover', 'OptBench_Skeleton_Pick', 'OptBench_Skeleton_StackAndBalance', 'OptBenchmark_InvKin_Endeff', 'OptMethod', 'Quaternion', 'RRT_PathFinder', 'ST', 'SY', 'Simulation', 'SimulationEngine', 'Skeleton', 'SolverReturn', 'TAMP_Provider', 'compiled', 'default_Actions2KOMO_Translator', 'default_TAMP_Provider', 'depthImage2PointCloud', 'get_NLP_Problem_names', 'make_NLP_Problem', 'params_add', 'params_clear', 'params_file', 'params_print', 'raiPath', 'rnd_seed', 'rnd_seed_random', 'setRaiPath', 'test']
|
|
10
10
|
class Actions2KOMO_Translator:
|
|
11
11
|
"""
|
|
12
12
|
Actions2KOMO_Translator
|
|
@@ -103,11 +103,11 @@ class BotOp:
|
|
|
103
103
|
"""
|
|
104
104
|
constructor
|
|
105
105
|
"""
|
|
106
|
-
def attach(self,
|
|
106
|
+
def attach(self, from: ..., to: ...) -> None:
|
|
107
107
|
"""
|
|
108
108
|
cheating: attach two objects kinematically
|
|
109
109
|
"""
|
|
110
|
-
def detach(self,
|
|
110
|
+
def detach(self, from: ..., to: ...) -> None:
|
|
111
111
|
"""
|
|
112
112
|
cheating: detach two previously attached objects
|
|
113
113
|
"""
|
|
@@ -365,7 +365,7 @@ class Config:
|
|
|
365
365
|
"""
|
|
366
366
|
get the joint state as a numpy vector, optionally only for a subset of joints specified as list of joint names
|
|
367
367
|
"""
|
|
368
|
-
def get_viewer(self
|
|
368
|
+
def get_viewer(self) -> ConfigurationViewer:
|
|
369
369
|
...
|
|
370
370
|
def processInertias(self, recomputeInertias: bool = True, transformToDiagInertia: bool = False) -> None:
|
|
371
371
|
"""
|
|
@@ -401,7 +401,7 @@ class Config:
|
|
|
401
401
|
"""
|
|
402
402
|
def setJointStateSlice(self, arg0: list[float], arg1: int) -> None:
|
|
403
403
|
...
|
|
404
|
-
def set_viewer(self, arg0:
|
|
404
|
+
def set_viewer(self, arg0: ConfigurationViewer) -> None:
|
|
405
405
|
...
|
|
406
406
|
def view(self, pause: bool = False, message: str = None) -> int:
|
|
407
407
|
"""
|
|
@@ -413,7 +413,7 @@ class Config:
|
|
|
413
413
|
"""
|
|
414
414
|
def view_recopyMeshes(self) -> None:
|
|
415
415
|
...
|
|
416
|
-
def viewer(self
|
|
416
|
+
def viewer(self) -> ConfigurationViewer:
|
|
417
417
|
...
|
|
418
418
|
def watchFile(self, arg0: str) -> None:
|
|
419
419
|
"""
|
|
@@ -498,6 +498,10 @@ class ConfigurationViewer:
|
|
|
498
498
|
"""
|
|
499
499
|
set the camera pose directly
|
|
500
500
|
"""
|
|
501
|
+
def setWindow(self, title: str, width: int, height: int) -> None:
|
|
502
|
+
"""
|
|
503
|
+
set title, width, and height
|
|
504
|
+
"""
|
|
501
505
|
def setupEventHandler(self, blockDefaultHandler: bool) -> None:
|
|
502
506
|
"""
|
|
503
507
|
setup callbacks to grab window events and return them with methods below
|
|
@@ -842,17 +846,17 @@ class Frame:
|
|
|
842
846
|
"""
|
|
843
847
|
attach a point cloud shape
|
|
844
848
|
"""
|
|
845
|
-
def setPose(self, arg0: arr) ->
|
|
849
|
+
def setPose(self, arg0: arr) -> Frame:
|
|
846
850
|
...
|
|
847
|
-
def setPoseByText(self, arg0: str) ->
|
|
851
|
+
def setPoseByText(self, arg0: str) -> Frame:
|
|
848
852
|
...
|
|
849
853
|
def setPosition(self, arg0: arr) -> Frame:
|
|
850
854
|
...
|
|
851
855
|
def setQuaternion(self, arg0: arr) -> Frame:
|
|
852
856
|
...
|
|
853
|
-
def setRelativePose(self, arg0: arr) ->
|
|
857
|
+
def setRelativePose(self, arg0: arr) -> Frame:
|
|
854
858
|
...
|
|
855
|
-
def setRelativePoseByText(self, arg0: str) ->
|
|
859
|
+
def setRelativePoseByText(self, arg0: str) -> Frame:
|
|
856
860
|
...
|
|
857
861
|
def setRelativePosition(self, arg0: arr) -> Frame:
|
|
858
862
|
...
|
|
@@ -1184,7 +1188,7 @@ class NLP:
|
|
|
1184
1188
|
"""
|
|
1185
1189
|
def getBounds(self) -> arr:
|
|
1186
1190
|
"""
|
|
1187
|
-
returns
|
|
1191
|
+
returns a 2xn array with lower and upper bounds as rows (or size zero, if there are no bounds)
|
|
1188
1192
|
"""
|
|
1189
1193
|
def getDimension(self) -> int:
|
|
1190
1194
|
"""
|
|
@@ -1501,6 +1505,7 @@ class OptMethod:
|
|
|
1501
1505
|
...
|
|
1502
1506
|
class Quaternion:
|
|
1503
1507
|
"""
|
|
1508
|
+
See the Quaternion Lecture Note https://www.user.tu-berlin.de/mtoussai/notes/quaternions.html for details
|
|
1504
1509
|
"""
|
|
1505
1510
|
@staticmethod
|
|
1506
1511
|
def _pybind11_conduit_v1_(*args, **kwargs):
|
|
@@ -1843,11 +1848,11 @@ class Simulation:
|
|
|
1843
1848
|
"""
|
|
1844
1849
|
def addSensor(self, sensorName: str, width: int = 640, height: int = 360, focalLength: float = -1.0, orthoAbsHeight: float = -1.0, zRange: arr = []) -> ...:
|
|
1845
1850
|
...
|
|
1846
|
-
def attach(self,
|
|
1851
|
+
def attach(self, from: Frame, to: Frame) -> None:
|
|
1847
1852
|
...
|
|
1848
1853
|
def depthData2pointCloud(self, arg0: numpy.ndarray[numpy.float32], arg1: list[float]) -> numpy.ndarray[numpy.float64]:
|
|
1849
1854
|
...
|
|
1850
|
-
def detach(self,
|
|
1855
|
+
def detach(self, from: Frame, to: Frame) -> None:
|
|
1851
1856
|
...
|
|
1852
1857
|
def getGripperWidth(self, gripperFrameName: str) -> float:
|
|
1853
1858
|
...
|
|
@@ -1892,7 +1897,7 @@ class Simulation:
|
|
|
1892
1897
|
"""
|
|
1893
1898
|
def setState(self, frameState: arr, jointState: arr = ..., frameVelocities: arr = ..., jointVelocities: arr = ...) -> None:
|
|
1894
1899
|
...
|
|
1895
|
-
def step(self, u_control: arr
|
|
1900
|
+
def step(self, u_control: arr = ..., tau: float = 0.01, u_mode: ControlMode = ...) -> None:
|
|
1896
1901
|
...
|
|
1897
1902
|
class SimulationEngine:
|
|
1898
1903
|
"""
|
|
@@ -2004,6 +2009,14 @@ def depthImage2PointCloud(depth: numpy.ndarray[numpy.float32], fxycxy: arr) -> a
|
|
|
2004
2009
|
"""
|
|
2005
2010
|
return the point cloud from the depth image
|
|
2006
2011
|
"""
|
|
2012
|
+
def get_NLP_Problem_names() -> StringA:
|
|
2013
|
+
"""
|
|
2014
|
+
return all problem names
|
|
2015
|
+
"""
|
|
2016
|
+
def make_NLP_Problem(problem_name: ...) -> NLP:
|
|
2017
|
+
"""
|
|
2018
|
+
create a benchmark NLP
|
|
2019
|
+
"""
|
|
2007
2020
|
def params_add(*args, **kwargs) -> None:
|
|
2008
2021
|
"""
|
|
2009
2022
|
add/set parameters
|
|
@@ -2024,6 +2037,14 @@ def raiPath(arg0: str) -> ...:
|
|
|
2024
2037
|
"""
|
|
2025
2038
|
get a path relative to rai base path
|
|
2026
2039
|
"""
|
|
2040
|
+
def rnd_seed(s: int) -> None:
|
|
2041
|
+
"""
|
|
2042
|
+
seed rnd with s
|
|
2043
|
+
"""
|
|
2044
|
+
def rnd_seed_random() -> None:
|
|
2045
|
+
"""
|
|
2046
|
+
seed rnd randomly
|
|
2047
|
+
"""
|
|
2027
2048
|
def setRaiPath(arg0: str) -> None:
|
|
2028
2049
|
"""
|
|
2029
2050
|
redefine the rai (or rai-robotModels) path
|
robotic/_robotic.so
CHANGED
|
Binary file
|
|
@@ -52,14 +52,16 @@ using std::istream;
|
|
|
52
52
|
using std::ofstream;
|
|
53
53
|
using std::ifstream;
|
|
54
54
|
|
|
55
|
+
namespace rai {
|
|
56
|
+
|
|
57
|
+
struct String;
|
|
58
|
+
|
|
55
59
|
//===========================================================================
|
|
56
60
|
//
|
|
57
61
|
// enums
|
|
58
62
|
//
|
|
59
63
|
|
|
60
|
-
namespace rai {
|
|
61
64
|
enum ArgWord { _left, _right, _sequence, _path, _xAxis, _yAxis, _zAxis, _xNegAxis, _yNegAxis, _zNegAxis };
|
|
62
|
-
}
|
|
63
65
|
|
|
64
66
|
//===========================================================================
|
|
65
67
|
|
|
@@ -84,9 +86,6 @@ struct Stepper {
|
|
|
84
86
|
// logging
|
|
85
87
|
//
|
|
86
88
|
|
|
87
|
-
namespace rai {
|
|
88
|
-
struct String;
|
|
89
|
-
|
|
90
89
|
/// An object that represents a log file and/or cout logging, together with log levels read from a cfg file
|
|
91
90
|
struct LogObject {
|
|
92
91
|
std::ofstream* fil=0;
|
|
@@ -117,12 +116,12 @@ extern LogObject _log;
|
|
|
117
116
|
const char* errString();
|
|
118
117
|
String& errStringStream();
|
|
119
118
|
|
|
120
|
-
}
|
|
121
|
-
|
|
122
119
|
//----- parsing strings in a stream
|
|
123
120
|
struct PARSE { const char* str; PARSE(const char* _str):str(_str) {} };
|
|
124
121
|
std::istream& operator>>(std::istream& is, const PARSE&);
|
|
125
122
|
|
|
123
|
+
} //namespace
|
|
124
|
+
|
|
126
125
|
//===========================================================================
|
|
127
126
|
//
|
|
128
127
|
// macros for LOG and CHECK
|
|
@@ -177,7 +176,7 @@ std::istream& operator>>(std::istream& is, const PARSE&);
|
|
|
177
176
|
// macros to define the standard <<and >>operatos for most classes
|
|
178
177
|
//
|
|
179
178
|
|
|
180
|
-
#define stdInPipe(type)\
|
|
179
|
+
#define stdInPipe(type) \
|
|
181
180
|
inline std::istream& operator>>(std::istream& is, type& x){ x.read(is); return is; }
|
|
182
181
|
#define stdOutPipe(type)\
|
|
183
182
|
inline std::ostream& operator<<(std::ostream& os, const type& x){ x.write(os); return os; }
|
robotic/include/rai/Core/graph.h
CHANGED
|
@@ -53,7 +53,6 @@ struct Node {
|
|
|
53
53
|
void swapParent(uint i, Node* p);
|
|
54
54
|
|
|
55
55
|
//-- get value
|
|
56
|
-
//get() -> as()
|
|
57
56
|
template<class T> bool is() const { return type==typeid(T); }
|
|
58
57
|
template<class T> T& as() { T* x=getValue<T>(); CHECK(x, "this node '" <<*this <<"' is not of type '" <<typeid(T).name() <<"' but type '" <<type.name() <<"'"); return *x; }
|
|
59
58
|
template<class T> const T& as() const { const T* x=getValue<T>(); CHECK(x, "this node '" <<*this <<"'is not of type '" <<typeid(T).name() <<"' but type '" <<type.name() <<"'"); return *x; }
|
|
@@ -61,10 +60,9 @@ struct Node {
|
|
|
61
60
|
|
|
62
61
|
template<class T> T* getValue(); ///< query whether node type is equal to (or derived from) T, return the value if so
|
|
63
62
|
template<class T> const T* getValue() const; ///< as above
|
|
64
|
-
template<class T>
|
|
65
|
-
template<class T> bool getFromDouble(T& x) const; ///< return value = false means parsing object of type T from the string failed
|
|
63
|
+
template<class T> bool getFromDouble(T& x) const; ///< return value = false means parsing object of type T from the double failed
|
|
66
64
|
template<class T> bool getFromString(T& x) const; ///< return value = false means parsing object of type T from the string failed
|
|
67
|
-
template<class T> bool getFromArr(T& x) const; ///< return value = false means parsing object of type T from the
|
|
65
|
+
template<class T> bool getFromArr(T& x) const; ///< return value = false means parsing object of type T from the arr failed
|
|
68
66
|
bool isBoolAndTrue() const { if(type!=typeid(bool)) return false; return *getValue<bool>() == true; }
|
|
69
67
|
bool isBoolAndFalse() const { if(type!=typeid(bool)) return false; return *getValue<bool>() == false; }
|
|
70
68
|
|
|
@@ -82,12 +80,10 @@ struct Node {
|
|
|
82
80
|
virtual void copyValue(Node*) {NIY}
|
|
83
81
|
virtual bool hasEqualValue(Node*) {NIY}
|
|
84
82
|
virtual void writeValue(std::ostream& os) const {NIY}
|
|
85
|
-
// virtual void copyValueInto(void*) const {NIY}
|
|
86
83
|
virtual Node* newClone(Graph& container) const {NIY}
|
|
87
84
|
};
|
|
88
|
-
|
|
89
|
-
inline std::istream& operator>>(std::istream& is, Node*& x) { HALT("prohibited"); return is; }
|
|
90
85
|
stdOutPipe(Node)
|
|
86
|
+
|
|
91
87
|
} //namespace
|
|
92
88
|
|
|
93
89
|
//===========================================================================
|
|
@@ -189,7 +185,7 @@ struct Graph : NodeL {
|
|
|
189
185
|
Node* readNode(std::istream& is, bool verbose, bool parseInfo); //used only internally..
|
|
190
186
|
void readJson(std::istream& is);
|
|
191
187
|
void writeJson(std::istream& is);
|
|
192
|
-
void write(std::ostream& os=cout, const char* ELEMSEP="
|
|
188
|
+
void write(std::ostream& os=cout, const char* ELEMSEP="\n", const char* BRACKETS=0, int indent=-1, bool yamlMode=false, bool binary=false) const;
|
|
193
189
|
void writeDot(std::ostream& os, bool withoutHeader=false, bool defaultEdges=false, int nodesOrEdges=0, int focusIndex=-1, bool subGraphsAsNodes=false);
|
|
194
190
|
void writeHtml(std::ostream& os, std::istream& is);
|
|
195
191
|
void writeYaml(std::ostream& os) const;
|
|
@@ -408,10 +404,6 @@ struct Node_typed : Node {
|
|
|
408
404
|
else os <<value;
|
|
409
405
|
}
|
|
410
406
|
|
|
411
|
-
// virtual void copyValueInto(void* value_ptr) const {
|
|
412
|
-
// *((T*)value_ptr) = value;
|
|
413
|
-
// }
|
|
414
|
-
|
|
415
407
|
virtual const std::type_info& getValueType() const {
|
|
416
408
|
return typeid(T);
|
|
417
409
|
}
|
|
@@ -445,15 +437,6 @@ template<class T> const T* Node::getValue() const {
|
|
|
445
437
|
return &typed->value;
|
|
446
438
|
}
|
|
447
439
|
|
|
448
|
-
template<class T> std::shared_ptr<T> Node::getPtr() const {
|
|
449
|
-
NIY
|
|
450
|
-
// std::shared_ptr<T> typed = std::dynamic_pointer_cast<T>(std::shared_ptr<T>(value_ptr));
|
|
451
|
-
return std::shared_ptr<T>();
|
|
452
|
-
// const Node_typed<std::shared_ptr<T>>* typed = dynamic_cast<const Node_typed<std::shared_ptr<T>>*>(this);
|
|
453
|
-
// if(!typed) return nullptr;
|
|
454
|
-
// return typed->value;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
440
|
template<class T> bool Node::getFromDouble(T& x) const {
|
|
458
441
|
if(!is<double>()) return false;
|
|
459
442
|
double y = as<double>();
|
|
@@ -51,7 +51,7 @@ struct CallbackL : rai::Array<Callback<F>*> {
|
|
|
51
51
|
struct RWLock {
|
|
52
52
|
std::shared_timed_mutex rwLock;
|
|
53
53
|
int rwCount=0; ///< -1==write locked, positive=numer of readers, 0=unlocked
|
|
54
|
-
Mutex rwCountMutex;
|
|
54
|
+
rai::Mutex rwCountMutex;
|
|
55
55
|
RWLock();
|
|
56
56
|
~RWLock();
|
|
57
57
|
void readLock(); ///< multiple threads may request 'lock for read'
|
|
@@ -67,7 +67,7 @@ struct RWLock {
|
|
|
67
67
|
//
|
|
68
68
|
|
|
69
69
|
/// This RW lock counts revisions and broadcasts accesses to listeners; who is accessing can be logged; it has a unique name
|
|
70
|
-
struct Var_base : NonCopyable {
|
|
70
|
+
struct Var_base : rai::NonCopyable {
|
|
71
71
|
RWLock rwlock; ///< rwLock (handled via read/writeAccess)
|
|
72
72
|
uint revision=0;
|
|
73
73
|
rai::String name; ///< name
|
|
@@ -227,7 +227,7 @@ template<class T> std::ostream& operator<<(std::ostream& os, Var<T>& x) { x.writ
|
|
|
227
227
|
/// a basic condition variable
|
|
228
228
|
struct Signaler {
|
|
229
229
|
int status;
|
|
230
|
-
Mutex statusMutex;
|
|
230
|
+
rai::Mutex statusMutex;
|
|
231
231
|
std::condition_variable cond;
|
|
232
232
|
|
|
233
233
|
Signaler(int initialStatus=0);
|
|
@@ -240,13 +240,13 @@ struct Signaler {
|
|
|
240
240
|
void statusLock(); //the user can manually lock/unlock, if he needs locked state access for longer -> use userHasLocked=true below!
|
|
241
241
|
void statusUnlock();
|
|
242
242
|
|
|
243
|
-
int getStatus(Mutex::Token* userHasLocked=0) const;
|
|
244
|
-
bool waitForSignal(Mutex::Token* userHasLocked=0, double timeout=-1.);
|
|
245
|
-
bool waitForEvent(std::function<bool()> f, Mutex::Token* userHasLocked=0);
|
|
246
|
-
bool waitForStatusEq(int i, Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
247
|
-
int waitForStatusNotEq(int i, Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
248
|
-
int waitForStatusGreaterThan(int i, Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
249
|
-
int waitForStatusSmallerThan(int i, Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
243
|
+
int getStatus(rai::Mutex::Token* userHasLocked=0) const;
|
|
244
|
+
bool waitForSignal(rai::Mutex::Token* userHasLocked=0, double timeout=-1.);
|
|
245
|
+
bool waitForEvent(std::function<bool()> f, rai::Mutex::Token* userHasLocked=0);
|
|
246
|
+
bool waitForStatusEq(int i, rai::Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
247
|
+
int waitForStatusNotEq(int i, rai::Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
248
|
+
int waitForStatusGreaterThan(int i, rai::Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
249
|
+
int waitForStatusSmallerThan(int i, rai::Mutex::Token* userHasLocked=0, double timeout=-1.); ///< return value is the state after the waiting
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
//===========================================================================
|
|
@@ -331,7 +331,7 @@ struct Thread {
|
|
|
331
331
|
rai::String name;
|
|
332
332
|
std::unique_ptr<std::thread> thread; ///< the underlying pthread; nullptr iff not opened
|
|
333
333
|
int tid; ///< system thread id
|
|
334
|
-
Mutex stepMutex; ///< This is set whenever the 'main' is in step (or open, or close) --- use this in all service methods callable from outside!!
|
|
334
|
+
rai::Mutex stepMutex; ///< This is set whenever the 'main' is in step (or open, or close) --- use this in all service methods callable from outside!!
|
|
335
335
|
uint step_count; ///< how often the step was called
|
|
336
336
|
Metronome metronome; ///< used for beat-looping
|
|
337
337
|
CycleTimer timer; ///< measure how the time spend per cycle, within step, idle
|
robotic/include/rai/Core/util.h
CHANGED
|
@@ -19,17 +19,19 @@
|
|
|
19
19
|
#include <climits>
|
|
20
20
|
#include <mutex>
|
|
21
21
|
#include <functional>
|
|
22
|
+
#include <random>
|
|
22
23
|
|
|
23
24
|
using std::cout;
|
|
24
25
|
using std::cerr;
|
|
25
26
|
using std::endl;
|
|
26
27
|
|
|
28
|
+
namespace rai {
|
|
29
|
+
|
|
27
30
|
//===========================================================================
|
|
28
31
|
//
|
|
29
32
|
// standard little methods (this needs cleanup)
|
|
30
33
|
//
|
|
31
34
|
|
|
32
|
-
namespace rai {
|
|
33
35
|
extern int argc;
|
|
34
36
|
extern char** argv;
|
|
35
37
|
extern std::string startDir;
|
|
@@ -121,7 +123,6 @@ const char* niceTypeidName(const std::type_info& type);
|
|
|
121
123
|
//----- get verbose level
|
|
122
124
|
bool getInteractivity();
|
|
123
125
|
bool getDisableGui();
|
|
124
|
-
}
|
|
125
126
|
|
|
126
127
|
//===========================================================================
|
|
127
128
|
//
|
|
@@ -132,7 +133,6 @@ bool getDisableGui();
|
|
|
132
133
|
#define STRINGF(format,...) (rai::String().printf(format, __VA_ARGS__))
|
|
133
134
|
#define STREAM(x) (((rai::String&)(rai::String().stream() <<x)).stream())
|
|
134
135
|
|
|
135
|
-
namespace rai {
|
|
136
136
|
/** @brief String implements the functionalities of an ostream and an
|
|
137
137
|
istream, but also can be send to an ostream or read from an
|
|
138
138
|
istream. It is based on a simple streambuf derived from the
|
|
@@ -214,16 +214,13 @@ struct String : public std::iostream {
|
|
|
214
214
|
|
|
215
215
|
/// @name I/O
|
|
216
216
|
void write(std::ostream& os) const;
|
|
217
|
-
uint read(std::istream& is, const char* skipSymbols=
|
|
217
|
+
uint read(std::istream& is, const char* skipSymbols=0, const char* stopSymbols=0, int eatStopSymbol=-1);
|
|
218
218
|
};
|
|
219
219
|
stdPipes(String)
|
|
220
220
|
|
|
221
221
|
inline String operator+(const String& a, const char* b) { String s=a; s <<b; return s; }
|
|
222
222
|
//template<class T> String operator+(const String& a, const T& b) { String s=a; s <<b; return s; }
|
|
223
223
|
|
|
224
|
-
} //namespace
|
|
225
|
-
|
|
226
|
-
typedef rai::String str;
|
|
227
224
|
|
|
228
225
|
void setLogLevels(int fileLogLevel=3, int consoleLogLevel=2);
|
|
229
226
|
|
|
@@ -236,26 +233,25 @@ void setLogLevels(int fileLogLevel=3, int consoleLogLevel=2);
|
|
|
236
233
|
// give names to Enum (for pipe << >> )
|
|
237
234
|
//
|
|
238
235
|
|
|
239
|
-
namespace rai {
|
|
240
236
|
template<class enum_T>
|
|
241
237
|
struct Enum {
|
|
242
238
|
enum_T x;
|
|
243
239
|
static const char* names [];
|
|
244
240
|
Enum():x((enum_T)-1) {}
|
|
245
241
|
Enum(enum_T y):x(y) {}
|
|
246
|
-
explicit Enum(const
|
|
242
|
+
explicit Enum(const String& str):Enum() { operator=(str); }
|
|
247
243
|
const enum_T& operator=(enum_T y) { x=y; return x; }
|
|
248
244
|
bool operator==(const enum_T& y) const { return x==y; }
|
|
249
245
|
bool operator!=(const enum_T& y) const { return x!=y; }
|
|
250
246
|
operator enum_T() const { return x; }
|
|
251
247
|
void read(std::istream& is) {
|
|
252
|
-
|
|
248
|
+
String str(is);
|
|
253
249
|
operator=(str);
|
|
254
250
|
}
|
|
255
251
|
void operator=(const char* str) {
|
|
256
252
|
operator=(STRING(str));
|
|
257
253
|
}
|
|
258
|
-
void operator=(const
|
|
254
|
+
void operator=(const String& str) {
|
|
259
255
|
bool good=false;
|
|
260
256
|
for(int i=0; names[i]; i++) {
|
|
261
257
|
const char* n = names[i];
|
|
@@ -263,14 +259,14 @@ struct Enum {
|
|
|
263
259
|
if(str==n) { x=(enum_T)(i); good=true; break; }
|
|
264
260
|
}
|
|
265
261
|
if(!good) {
|
|
266
|
-
|
|
262
|
+
String all;
|
|
267
263
|
for(int i=0; names[i]; i++) all <<names[i] <<' ';
|
|
268
264
|
HALT("Enum::read could not find the keyword '" <<str <<"'. Possible Enum keywords: " <<all);
|
|
269
265
|
} else {
|
|
270
266
|
CHECK(str.p && !strcmp(names[x], str.p), "");
|
|
271
267
|
}
|
|
272
268
|
}
|
|
273
|
-
static bool contains(const
|
|
269
|
+
static bool contains(const String& str) {
|
|
274
270
|
for(int i=0; names[i]; i++) {
|
|
275
271
|
if(str==names[i]) return true;
|
|
276
272
|
}
|
|
@@ -287,14 +283,12 @@ struct Enum {
|
|
|
287
283
|
};
|
|
288
284
|
template<class T> std::istream& operator>>(std::istream& is, Enum<T>& x) { x.read(is); return is; }
|
|
289
285
|
template<class T> std::ostream& operator<<(std::ostream& os, const Enum<T>& x) { x.write(os); return os; }
|
|
290
|
-
}
|
|
291
286
|
|
|
292
287
|
//===========================================================================
|
|
293
288
|
//
|
|
294
289
|
// parameters
|
|
295
290
|
//
|
|
296
291
|
|
|
297
|
-
namespace rai {
|
|
298
292
|
//----- parameter grabbing from command line, config file, or default value
|
|
299
293
|
template<class T> T getParameter(const char* tag);
|
|
300
294
|
template<class T> T getParameter(const char* tag, const T& Default);
|
|
@@ -331,8 +325,6 @@ template<class T> struct ParameterInitEnum {
|
|
|
331
325
|
auto& set_##name(type _##name){ name=_##name; return *this; } \
|
|
332
326
|
rai::ParameterInitEnum<type> __init_##name = {name, scope #name, Default};
|
|
333
327
|
|
|
334
|
-
}
|
|
335
|
-
|
|
336
328
|
//===========================================================================
|
|
337
329
|
//
|
|
338
330
|
// Testing
|
|
@@ -359,15 +351,13 @@ template<class T> struct ParameterInitEnum {
|
|
|
359
351
|
// FileToken
|
|
360
352
|
//
|
|
361
353
|
|
|
362
|
-
namespace rai {
|
|
363
|
-
|
|
364
354
|
/** @brief A ostream/istream wrapper that allows easier initialization of objects, like:
|
|
365
355
|
arr X = FILE("inname");
|
|
366
356
|
X >>FILE("outfile");
|
|
367
357
|
etc
|
|
368
358
|
*/
|
|
369
359
|
struct FileToken {
|
|
370
|
-
|
|
360
|
+
String path, name, baseDir;
|
|
371
361
|
std::shared_ptr<std::ofstream> os;
|
|
372
362
|
std::shared_ptr<std::ifstream> is;
|
|
373
363
|
|
|
@@ -386,9 +376,9 @@ struct FileToken {
|
|
|
386
376
|
operator std::istream& () { return getIs(); }
|
|
387
377
|
operator std::ostream& () { return getOs(); }
|
|
388
378
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
379
|
+
String autoPath() const;
|
|
380
|
+
String relPath() const;
|
|
381
|
+
String fullPath() const;
|
|
392
382
|
};
|
|
393
383
|
template<class T> FileToken& operator>>(FileToken& fil, T& x) { fil.getIs() >>x; return fil; }
|
|
394
384
|
template<class T> std::ostream& operator<<(FileToken& fil, const T& x) { fil.getOs() <<x; return fil.getOs(); }
|
|
@@ -396,7 +386,7 @@ inline std::ostream& operator<<(std::ostream& os, const FileToken& fil) { return
|
|
|
396
386
|
template<class T> FileToken& operator<<(T& x, FileToken& fil) { fil.getIs() >>x; return fil; }
|
|
397
387
|
template<class T> void operator>>(const T& x, FileToken& fil) { fil.getOs() <<x; }
|
|
398
388
|
inline bool operator==(const FileToken&, const FileToken&) { return false; }
|
|
399
|
-
|
|
389
|
+
|
|
400
390
|
#define FILE(filename) (rai::FileToken(filename)()) //it needs to return a REFERENCE to a local scope object
|
|
401
391
|
|
|
402
392
|
//===========================================================================
|
|
@@ -404,15 +394,17 @@ inline bool operator==(const FileToken&, const FileToken&) { return false; }
|
|
|
404
394
|
// random number generator
|
|
405
395
|
//
|
|
406
396
|
|
|
407
|
-
namespace rai {
|
|
408
397
|
/** @brief A random number generator. An global instantiation \c
|
|
409
|
-
|
|
398
|
+
rnd of a \c Rnd object is created. Use this one object to get
|
|
410
399
|
random numbers.*/
|
|
411
400
|
class Rnd {
|
|
412
401
|
private:
|
|
413
402
|
bool ready;
|
|
414
403
|
int32_t rpoint; /* Feldindex */
|
|
415
404
|
int32_t rfield[256]; /* Schieberegisterfeld */
|
|
405
|
+
public:
|
|
406
|
+
std::minstd_rand e1;
|
|
407
|
+
std::random_device r;
|
|
416
408
|
|
|
417
409
|
public:
|
|
418
410
|
/// ...
|
|
@@ -420,52 +412,23 @@ class Rnd {
|
|
|
420
412
|
|
|
421
413
|
public:/// @name initialization
|
|
422
414
|
/// initialize with a specific seed
|
|
423
|
-
|
|
415
|
+
void seed(int s){ e1.seed(s); ready=true; }
|
|
424
416
|
|
|
425
417
|
/// use Parameter<uint>("seed") as seed
|
|
426
|
-
|
|
418
|
+
void seed(){ e1.seed(getParameter<uint32_t>("seed", 0)); ready=true; }
|
|
427
419
|
|
|
428
420
|
/// uses the internal clock to generate a seed
|
|
429
|
-
|
|
421
|
+
void seed_random(){ e1.seed(r()); ready=true; }
|
|
430
422
|
|
|
431
423
|
public:/// @name access
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
uint32_t operator()() { return num(); }
|
|
436
|
-
/// a initeger random number uniformly distributed in [0, \c i-1]
|
|
437
|
-
uint32_t num(uint32_t limit) {
|
|
438
|
-
CHECK(limit, "zero limit in rnd.num()"); return num() % limit;
|
|
439
|
-
}
|
|
440
|
-
uint32_t num(int32_t lo, int32_t hi) { return lo+num(hi-lo+1); }
|
|
441
|
-
/// same as \c num(i)
|
|
442
|
-
uint32_t operator()(uint32_t i) { return num(i); }
|
|
443
|
-
uint32_t operator()(int32_t lo, int32_t hi) { return num(lo, hi); }
|
|
444
|
-
/// a random variable uniformly distributed in [0, 1]
|
|
445
|
-
double uni() { return ((double)num(1 <<22))/(1 <<22); }
|
|
446
|
-
/// a random variable uniformly distributed in [\c low, \c high]
|
|
447
|
-
double uni(double low, double high) { return low+uni()*(high-low); }
|
|
448
|
-
/// a gaussian random variable with mean zero
|
|
449
|
-
double gauss();
|
|
450
|
-
/** @brief a positive integer drawn from a poisson distribution with given
|
|
451
|
-
\c mean; is case \c mean>100, a (positive) gauss number
|
|
452
|
-
\c floor(mean+gauss(sqrt(mean))+.5) is returned */
|
|
453
|
-
uint32_t poisson(double mean);
|
|
424
|
+
int uni_int(int lo, int up) { if(!ready) seed(); std::uniform_int_distribution<int> dist(lo, up); return dist(e1); }
|
|
425
|
+
double uni(double lo=0., double up=1.) { if(!ready) seed(); std::uniform_real_distribution<double> dist(lo, up); return dist(e1); }
|
|
426
|
+
double gauss(double mean=0., double std=1.){ if(!ready) seed(); std::normal_distribution<double> dist(mean, std); return dist(e1); }
|
|
454
427
|
|
|
455
|
-
|
|
456
|
-
int32_t rnd250() {
|
|
457
|
-
rpoint = (rpoint+1) & 255; // Index erhoehen
|
|
458
|
-
return rfield[rpoint] = rfield[(rpoint-250) & 255]
|
|
459
|
-
^ rfield[(rpoint-103) & 255];
|
|
460
|
-
}
|
|
428
|
+
uint operator()(uint up) { return uint(uni_int(0, up-1)); }
|
|
461
429
|
|
|
462
|
-
void seed250(int32_t seed);
|
|
463
430
|
};
|
|
464
431
|
|
|
465
|
-
}
|
|
466
|
-
/// The global Rnd object
|
|
467
|
-
extern rai::Rnd rnd;
|
|
468
|
-
|
|
469
432
|
//===========================================================================
|
|
470
433
|
//
|
|
471
434
|
/// a little inotify wrapper
|
|
@@ -475,7 +438,7 @@ struct Inotify {
|
|
|
475
438
|
int fd, wd;
|
|
476
439
|
char* buffer;
|
|
477
440
|
uint buffer_size;
|
|
478
|
-
|
|
441
|
+
FileToken* fil;
|
|
479
442
|
Inotify(const char* filename);
|
|
480
443
|
~Inotify();
|
|
481
444
|
bool poll(bool block=false, bool verbose=false);
|
|
@@ -541,7 +504,6 @@ struct Singleton {
|
|
|
541
504
|
// just a hook to make things gl drawable
|
|
542
505
|
//
|
|
543
506
|
|
|
544
|
-
struct OpenGL;
|
|
545
507
|
struct OpenGLDrawOptions {
|
|
546
508
|
bool drawWires=false;
|
|
547
509
|
bool drawColors=true;
|
|
@@ -569,22 +531,20 @@ struct CoutToken {
|
|
|
569
531
|
~CoutToken() { coutMutex.unlock(); }
|
|
570
532
|
std::ostream& getOs() { return cout; }
|
|
571
533
|
};
|
|
572
|
-
#define COUT (CoutToken().getOs())
|
|
534
|
+
#define COUT (rai::CoutToken().getOs())
|
|
573
535
|
|
|
574
536
|
//===========================================================================
|
|
575
537
|
//
|
|
576
538
|
// to register a type
|
|
577
539
|
//
|
|
578
540
|
|
|
579
|
-
namespace rai {
|
|
580
541
|
struct Node;
|
|
581
542
|
struct Graph;
|
|
582
|
-
}
|
|
583
543
|
|
|
584
544
|
struct Type {
|
|
585
545
|
virtual ~Type() {}
|
|
586
546
|
virtual const std::type_info& typeId() const {NIY}
|
|
587
|
-
virtual struct
|
|
547
|
+
virtual struct Node* readIntoNewNode(struct Graph& container, std::istream&) const {NIY}
|
|
588
548
|
virtual void* newInstance() const {NIY}
|
|
589
549
|
void write(std::ostream& os) const { os <<"Type '" <<typeId().name() <<"' "; }
|
|
590
550
|
void read(std::istream& is) const {NIY}
|
|
@@ -606,7 +566,7 @@ inline bool operator==(Type& t1, Type& t2) { return t1.typeId() == t2.typeId();
|
|
|
606
566
|
//
|
|
607
567
|
|
|
608
568
|
template<class T> T fromFile(const char* filename) {
|
|
609
|
-
|
|
569
|
+
FileToken file(filename);
|
|
610
570
|
T x;
|
|
611
571
|
file.cd_file();
|
|
612
572
|
x.read(file.getIs());
|
|
@@ -621,13 +581,21 @@ inline bool operator==(Type& t1, Type& t2) { return t1.typeId() == t2.typeId();
|
|
|
621
581
|
// return x;
|
|
622
582
|
// }
|
|
623
583
|
|
|
584
|
+
} //namespace
|
|
585
|
+
|
|
586
|
+
//===========================================================================
|
|
587
|
+
|
|
588
|
+
typedef rai::String str;
|
|
589
|
+
extern rai::Rnd rnd;
|
|
590
|
+
std::istream& operator>>(std::istream& is, char* str);
|
|
591
|
+
|
|
624
592
|
//===========================================================================
|
|
625
593
|
//
|
|
626
|
-
|
|
594
|
+
// shared ptrs
|
|
627
595
|
//
|
|
628
596
|
|
|
629
|
-
|
|
630
|
-
|
|
597
|
+
template<class T> void _delete(T* ptr){}
|
|
598
|
+
template<class T> std::shared_ptr<T> _shared(T& x){ return std::shared_ptr<T>(&x, &_delete<T>); }
|
|
631
599
|
|
|
632
600
|
//===========================================================================
|
|
633
601
|
//
|
|
@@ -637,3 +605,11 @@ inline bool operator==(Type& t1, Type& t2) { return t1.typeId() == t2.typeId();
|
|
|
637
605
|
void gnuplot(const char* command, bool pause=false, bool persist=false, const char* PDFfile=nullptr);
|
|
638
606
|
void gnuplotClose();
|
|
639
607
|
|
|
608
|
+
//===========================================================================
|
|
609
|
+
//
|
|
610
|
+
/// running code on init (in cpp files)
|
|
611
|
+
//
|
|
612
|
+
|
|
613
|
+
#define RUN_ON_INIT_BEGIN(key) struct key##_RUN_ON_INIT{ key##_RUN_ON_INIT(){
|
|
614
|
+
#define RUN_ON_INIT_END(key) } } key##_RUN_ON_INIT_dummy;
|
|
615
|
+
|