7 #include <dynamic-graph/signal.h>
10 #include <boost/python.hpp>
30 typedef Eigen::Matrix<double, 7, 1>
Vector7;
34 typedef Eigen::Matrix<double, 4, 4>
Matrix4;
38 template <
typename Time>
41 bp::class_<S_t, boost::noncopyable>(
name, bp::no_init)
45 bp::return_value_policy<bp::copy_const_reference>()),
50 bp::return_value_policy<bp::copy_const_reference>()))
52 .def(
"getName", &S_t::getName,
53 bp::return_value_policy<bp::copy_const_reference>())
56 +[](
const S_t& s) -> std::string {
62 .def(
"plug", &
S_t::plug,
"Plug the signal to another signal")
63 .def(
"unplug", &S_t::unplug,
"Unplug the signal")
64 .def(
"isPlugged", &S_t::isPlugged,
"Whether the signal is plugged")
65 .def(
"getPlugged", &S_t::getPluged,
66 bp::return_value_policy<bp::reference_existing_object>(),
67 "To which signal the signal is plugged")
69 .def(
"recompute", &S_t::recompute,
"Recompute the signal at given time")
73 +[](
const S_t& s) -> std::string {
74 std::ostringstream oss;
79 "displayDependencies",
80 +[](
const S_t& s,
int depth) -> std::string {
81 std::ostringstream oss;
82 s.displayDependencies(oss, depth);
85 "Print the signal dependencies in a string");
91 bp::class_<S_t, bp::bases<SignalBase<sigtime_t> >, boost::noncopyable> obj(
92 name.c_str(), bp::init<std::string>());
95 +[](
const S_t& signal) ->
Matrix4 {
96 return signal.accessCopy().matrix();
103 "the signal value.");
108 exposeSignalBase<sigtime_t>(
"SignalBase");
110 exposeSignalsOfType<bool, sigtime_t>(
"Bool");
111 exposeSignalsOfType<unsigned int, sigtime_t>(
"UInt");
112 exposeSignalsOfType<int, sigtime_t>(
"Int");
113 exposeSignalsOfType<uint64_t, sigtime_t>(
"UInt64");
114 exposeSignalsOfType<int64_t, sigtime_t>(
"Int64");
115 exposeSignalsOfType<double, sigtime_t>(
"Double");
117 exposeSignalsOfType<Vector, sigtime_t>(
"Vector");
118 exposeSignalsOfType<Vector3, sigtime_t>(
"Vector3");
119 exposeSignalsOfType<Vector7, sigtime_t>(
"Vector7");
121 exposeSignalsOfType<Matrix, sigtime_t>(
"Matrix");
122 exposeSignalsOfType<MatrixRotation, sigtime_t>(
"MatrixRotation");
123 exposeSignalsOfType<MatrixHomogeneous, sigtime_t>(
"MatrixHomogeneous");
124 exposeSignalsOfType<MatrixTwist, sigtime_t>(
"MatrixTwist");
126 exposeSignalsOfType<Quaternion, sigtime_t>(
"Quaternion");
127 exposeSignalsOfType<VectorUTheta, sigtime_t>(
"VectorUTheta");
130 namespace signalBase {
135 std::string& error) {
137 if (!SignalWrapper_t::checkCallable(o, error)) {
141 SignalWrapper_t* obj =
new SignalWrapper_t(
name, o);
150 #define SIGNAL_WRAPPER_TYPE(IF, Enum, Type) \
151 IF(command::Value::typeName(command::Value::Enum).compare(type) == 0) { \
152 obj = createSignalWrapperTpl<Type>(name, object, error); \
161 if (psc == NULL)
return NULL;
166 obj = createSignalWrapperTpl<bool>(
name,
object, error);
169 obj = createSignalWrapperTpl<unsigned int>(
name,
object, error);
171 obj = createSignalWrapperTpl<int>(
name,
object, error);
173 .compare(type) == 0) {
174 obj = createSignalWrapperTpl<uint64_t>(
name,
object, error);
177 obj = createSignalWrapperTpl<int64_t>(
name,
object, error);
180 obj = createSignalWrapperTpl<float>(
name,
object, error);
183 obj = createSignalWrapperTpl<double>(
name,
object, error);
186 obj = createSignalWrapperTpl<Vector>(
name,
object, error);
188 error =
"Type not understood";
191 if (obj == NULL)
throw std::runtime_error(error);