7 #include <dynamic-graph/signal.h> 10 #include <boost/python.hpp> 32 typedef Eigen::Matrix<double, 7, 1>
Vector7;
36 typedef Eigen::Matrix<double, 4, 4>
Matrix4;
40 template <
typename Time>
43 bp::class_<S_t, boost::noncopyable>(
name, bp::no_init)
47 bp::return_value_policy<bp::copy_const_reference>()),
52 bp::return_value_policy<bp::copy_const_reference>()))
54 .def(
"getName", &S_t::getName,
55 bp::return_value_policy<bp::copy_const_reference>())
58 +[](
const S_t& s) -> std::string {
64 .def(
"plug", &
S_t::plug,
"Plug the signal to another signal")
65 .def(
"unplug", &S_t::unplug,
"Unplug the signal")
66 .def(
"isPlugged", &S_t::isPlugged,
"Whether the signal is plugged")
67 .def(
"getPlugged", &S_t::getPluged,
68 bp::return_value_policy<bp::reference_existing_object>(),
69 "To which signal the signal is plugged")
71 .def(
"recompute", &S_t::recompute,
"Recompute the signal at given time")
75 +[](
const S_t& s) -> std::string {
76 std::ostringstream oss;
81 "displayDependencies",
82 +[](
const S_t& s,
int time) -> std::string {
83 std::ostringstream oss;
84 s.displayDependencies(oss, time);
87 "Print the signal dependencies in a string");
93 bp::class_<S_t, bp::bases<SignalBase<time_type> >, boost::noncopyable> obj(
94 name.c_str(), bp::init<std::string>());
97 +[](
const S_t& signal) -> Matrix4 {
98 return signal.accessCopy().matrix();
100 +[](S_t& signal,
const Matrix4&
v) {
105 "the signal value.");
110 exposeSignalBase<time_type>(
"SignalBase");
112 exposeSignalsOfType<bool, time_type>(
"Bool");
113 exposeSignalsOfType<int, time_type>(
"Int");
114 exposeSignalsOfType<double, time_type>(
"Double");
116 exposeSignalsOfType<Vector, time_type>(
"Vector");
117 exposeSignalsOfType<Vector3, time_type>(
"Vector3");
118 exposeSignalsOfType<Vector7, time_type>(
"Vector7");
120 exposeSignalsOfType<Matrix, time_type>(
"Matrix");
121 exposeSignalsOfType<MatrixRotation, time_type>(
"MatrixRotation");
122 exposeSignalsOfType<MatrixHomogeneous, time_type>(
"MatrixHomogeneous");
123 exposeSignalsOfType<MatrixTwist, time_type>(
"MatrixTwist");
125 exposeSignalsOfType<Quaternion, time_type>(
"Quaternion");
126 exposeSignalsOfType<VectorUTheta, time_type>(
"VectorUTheta");
129 namespace signalBase {
133 std::string& error) {
135 if (!SignalWrapper_t::checkCallable(o, error)) {
139 SignalWrapper_t* obj =
new SignalWrapper_t(name, o);
148 #define SIGNAL_WRAPPER_TYPE(IF, Enum, Type) \ 149 IF(command::Value::typeName(command::Value::Enum).compare(type) == 0) { \ 150 obj = createSignalWrapperTpl<Type>(name, object, error); \ 159 if (psc == NULL)
return NULL;
173 error =
"Type not understood";
176 if (obj == NULL)
throw std::runtime_error(error);
Eigen::Matrix< double, 6, 6 > MatrixTwist
#define SIGNAL_WRAPPER_TYPE(IF, Enum, Type)
Eigen::Quaternion< double > Quaternion
Eigen::Matrix< double, 7, 1 > Vector7
Eigen::Transform< double, 3, Eigen::Affine > MatrixHomogeneous
Eigen::Matrix< double, 3, 3 > MatrixRotation
PythonSignalContainer * getPythonSignalContainer()
void plug(SignalBase< int > *signalOut, SignalBase< int > *signalIn)
plug a signal into another one.
Eigen::AngleAxis< double > VectorUTheta
Eigen::Matrix< double, 4, 4 > Matrix4
void exposeSignalBase(const char *name)
SignalWrapper< T, int > * createSignalWrapperTpl(const char *name, bp::object o, std::string &error)
SignalBase< int > * createSignalWrapper(const char *name, const char *type, bp::object object)
Create an instance of SignalWrapper.
void signalRegistration(const SignalArray< int > &signals)
auto exposeSignal< MatrixHomogeneous, time_type >(const std::string &name)
Entity * create(const char *type, const char *name)
Create an instance of Entity.