forked from facebookresearch/habitat-sim
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCoreBindings.cpp
More file actions
54 lines (47 loc) · 2.06 KB
/
CoreBindings.cpp
File metadata and controls
54 lines (47 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Facebook, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include "esp/bindings/bindings.h"
#include "esp/core/random.h"
namespace py = pybind11;
using py::literals::operator""_a;
using esp::logging::LoggingContext;
namespace esp {
namespace core {
void initCoreBindings(py::module& m) {
// ==== struct RigidState ===
py::class_<RigidState, RigidState::ptr>(m, "RigidState")
.def(py::init(&RigidState::create<>))
.def(py::init(&RigidState::create<const Magnum::Quaternion&,
const Magnum::Vector3&>))
.def_readwrite("rotation", &RigidState::rotation)
.def_readwrite("translation", &RigidState::translation);
py::class_<Random, Random::ptr>(m, "Random")
.def(py::init(&Random::create<>))
.def("seed", &Random::seed)
.def("uniform_float_01", &Random::uniform_float_01)
.def("uniform_float", &Random::uniform_float)
.def("uniform_int", py::overload_cast<>(&Random::uniform_int))
.def("uniform_int", py::overload_cast<int, int>(&Random::uniform_int))
.def("uniform_uint", &Random::uniform_uint)
.def("normal_float_01", &Random::normal_float_01);
auto core = m.def_submodule("core");
py::class_<LoggingContext>(core, "LoggingContext")
.def_static(
"reinitialize_from_env",
[]() {
auto core = py::module_::import(
"habitat_sim._ext.habitat_sim_bindings.core");
delete core.attr("_logging_context").cast<LoggingContext*>();
core.attr("_logging_context") = new LoggingContext{};
})
.def_static("current", &LoggingContext::current,
py::return_value_policy::reference)
.def_property_readonly("sim_is_quiet", [](LoggingContext& self) -> bool {
return self.levelFor(logging::Subsystem::sim) >=
logging::LoggingLevel::Debug;
});
core.attr("_logging_context") = new LoggingContext{};
}
} // namespace core
} // namespace esp