diff --git a/benchmark/sandbox/test1.cpp b/benchmark/sandbox/test1.cpp new file mode 100644 index 0000000000..ea54b5f49e --- /dev/null +++ b/benchmark/sandbox/test1.cpp @@ -0,0 +1,106 @@ +#include +#include +#include "pinocchio/parsers/sample-models.hpp" +#include "pinocchio/algorithm/joint-configuration.hpp" +#include "pinocchio/algorithm/rnea.hpp" +#include + + +using namespace std; +using namespace pinocchio; + +class fun: serialization::Serializable{ + + private: + int num1; + + public: + fun(int n):num1{n}{cout << "calling fun constructor!" << endl;}; + void print_num1(){cout << "num1 = " << num1 << endl;} + void set_num1(int n){num1=n;}; + + ~fun(){cout << "calling fun destructor!" << endl;}; + +}; + +int main(){ + + + pinocchio::Model model; + buildModels::humanoidRandom(model,true); + Data data(model); + + Eigen::VectorXd q = pinocchio::neutral(model); + Eigen::VectorXd v = Eigen::VectorXd::Random(model.nv); + Eigen::VectorXd a = Eigen::VectorXd::Zero(model.nv); + + const Eigen::VectorXd & tau = pinocchio::rnea(model,data,q,v,a); + std::cout << "tau = " << tau.transpose() << std::endl; + + // ...Testing some data structures... + + // cout << "model njoints = " << model.njoints << endl; + + + // Testng serializable derived objects + fun f1{56}; + f1.set_num1(12); + f1.print_num1(); + + serialization::Serializable f2; + + // testing JointCollectionDefaultTpl + + JointCollectionDefaultTpl ::JointModelRX j1; + auto data1 = j1.createData(); + Eigen::VectorXd v1(3); + + j1.calc(data1,v1); + cout << j1.classname() << endl; + + // testing SE3 class objects + + cout << "---------------------------------" << endl; + + SE3Tpl s1; + + Eigen::Quaterniond quat(1.0,1.0,1.0,0.0); + Eigen::Vector3d trans(1.0,2.0,3.0); + + SE3Tpl s2(quat, trans); + + cout << "s2 rot = " << s2.rotation() << endl; + cout << "s2 trans = " << s2.translation() << endl; + + cout << "s2 homo = " << s2.toHomogeneousMatrix() << endl; + + pinocchio::traits< SE3Tpl>::ActionMatrixType action_matrix = s2; + cout << "action_matrix-1 = " << action_matrix << endl; + + cout << "to action matrix-2 =" << s2.toActionMatrix() << endl; + cout << "to action matrix-3 =" << s2.toActionMatrix_impl() << endl; + + Eigen::Vector3d vec1{1.0,2.0,1.0}; + cout << "action on vec1 = \n" << s2.actOnEigenObject(vec1) << endl; + + + cout << "------------------------- Testing ForceTpl------------------------" << endl; + + // pinocchio::ForceBase>> f3; // causing error + pinocchio::ForceDense> f3; + f3.setRandom(); + cout << "f3 linear part = \n" << f3.linear() << endl; + // cout << "f3 angular part =" << f3.angular() << endl; + + + + + + + + + +return 0; + + +} \ No newline at end of file diff --git a/benchmark/sandbox/test1_c b/benchmark/sandbox/test1_c new file mode 100755 index 0000000000..a0b4d5f3d1 Binary files /dev/null and b/benchmark/sandbox/test1_c differ diff --git a/benchmark/sandbox/test2.cpp b/benchmark/sandbox/test2.cpp new file mode 100644 index 0000000000..7e7b53d993 --- /dev/null +++ b/benchmark/sandbox/test2.cpp @@ -0,0 +1,64 @@ +#include +#include + +using namespace std; + +template +class Ability{ + + public: + T strength, hit; + Ability(T n, T m):strength{n}, hit{m}{}; + void get_ability(){ + cout << "strength , hit =" << strength << ", " << hit << endl; + } + + +}; + +template +class Warrior{ + + public: + T power, health; + Warrior(T n,T m):power{n},health{m}{}; + void print_stat(){ + cout << "power, health = " << power << ", " << health << endl; + } + static void fun1(){ + cout << "this is inside the fun1" << endl; + } + ~Warrior(){}; + + typedef Ability ability; + +}; + + + +int main(){ + + typedef Warrior Saint; + typedef Warrior Archer; + typedef Warrior Sepoy; + + Saint s{12.4,5.4}; + Archer a{34,67}; + Sepoy b{12.3,54.1}; + + s.print_stat(); + a.print_stat(); + b.print_stat(); + + s.fun1(); + Warrior::fun1(); + + Saint::ability s_ab(23.1,45.1); + s_ab.get_ability(); + + + + + + return 0; +} \ No newline at end of file diff --git a/benchmark/sandbox/test2_c b/benchmark/sandbox/test2_c new file mode 100755 index 0000000000..da5833f9e8 Binary files /dev/null and b/benchmark/sandbox/test2_c differ diff --git a/benchmark/sandbox/test3 b/benchmark/sandbox/test3 new file mode 100755 index 0000000000..c1fc445028 Binary files /dev/null and b/benchmark/sandbox/test3 differ diff --git a/benchmark/sandbox/test3.cpp b/benchmark/sandbox/test3.cpp new file mode 100644 index 0000000000..8ece4a991b --- /dev/null +++ b/benchmark/sandbox/test3.cpp @@ -0,0 +1,44 @@ +// template specialization + +#include +#include +using namespace std; + +template +class Nums{ + + public: + T num1, num2; + Nums(){}; + void print_nums(){ + cout << "type of num1 and num2 = " << typeid(num1).name() << endl; + } + +}; + +// class template specialization for int +template <> +class Nums{ + public: + int num1, num2; + Nums(int n, int m):num1{n},num2{m}{}; + void print_nums(){ + cout << "type of num1 and num2 is integer " << endl; + } + +}; + +int main(){ + + Nums n; + n.print_nums(); + + Nums m; + m.print_nums(); + + Nums p(12,4); + p.print_nums(); + + + return 0; +} \ No newline at end of file diff --git a/benchmark/sandbox/test4 b/benchmark/sandbox/test4 new file mode 100755 index 0000000000..6cbde5150c Binary files /dev/null and b/benchmark/sandbox/test4 differ diff --git a/benchmark/sandbox/test4.cpp b/benchmark/sandbox/test4.cpp new file mode 100644 index 0000000000..52ba749302 --- /dev/null +++ b/benchmark/sandbox/test4.cpp @@ -0,0 +1,40 @@ +#include +#include +using namespace std; + +template +class test{ + + public: + template + void myfun(U var) + { + std::cout << "value of var is = " << var << endl; + } + + + +}; + +// template specialization +template<> +template<> // need 2 template keywords since specialized for the class and function +void test::myfun(double var){ + std::cout << "Value of var for double now is " << var << endl; +} + + +int main(){ + + + test intstance; + test doubstance; + + intstance.myfun(12); + intstance.myfun(34.1); + + intstance.template myfun(56.1); + + + +} \ No newline at end of file