Newer
Older

Nicolas Mansard
committed
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// Copyright (c) 2015-2016 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#include <iostream>
#include <pinocchio/multibody/joint/joint.hpp>
#include <pinocchio/multibody/model.hpp>
#include "pinocchio/multibody/visitor.hpp"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE ModuleTestVisitor
#include <boost/test/unit_test.hpp>
#include <boost/utility/binary.hpp>
namespace se3
{
struct SimpleVisitor : public se3::fusion::JointVisitor<SimpleVisitor>
{
typedef boost::fusion::vector<const se3::Model &,
se3::Data &,
int
> ArgsType;
JOINT_VISITOR_INIT(SimpleVisitor);
template<typename JointModel>
static void algo(const se3::JointModelBase<JointModel> & jmodel,
se3::JointDataBase<typename JointModel::JointDataDerived> & jdata,
const se3::Model & model,
se3::Data & data,
int jointId);
};
template<typename JointModel>
void SimpleVisitor::algo(const se3::JointModelBase<JointModel> & /*jmodel*/,
se3::JointDataBase<typename JointModel::JointDataDerived> & /*jdata*/,
const se3::Model & /*model*/,
se3::Data & /*data*/,
int /*dummy*/)
{ /* --- do nothing --- */ }
template<>
void SimpleVisitor::algo(const se3::JointModelBase<JointModelRevoluteUnaligned> & jmodel,
se3::JointDataBase<JointDataRevoluteUnaligned> & /*jdata*/,
const se3::Model & /*model*/,
se3::Data & /*data*/,
int /*dummy*/)
{
BOOST_CHECK( jmodel.shortname() == JointModelRevoluteUnaligned::classname() );
Eigen::Vector3d axis = jmodel.derived().axis;
Eigen::Vector3d axis_z; axis_z << 0,0,1;
BOOST_CHECK ( axis == axis_z );
}
} // namespace se3
/* Validates the access to memory stored in joint models, by using the class
* joint model revolute unaligned.
*/
BOOST_AUTO_TEST_SUITE ( TestVisitor )
BOOST_AUTO_TEST_CASE ( test_runal )
{
using namespace se3;
se3::Model model;
model.addJoint(0,se3::JointModelRevoluteUnaligned(0,0,1),se3::SE3::Random());
Data data(model);
for( Model::JointIndex i=1;i<(Model::JointIndex)model.njoint;++i )
{
SimpleVisitor::run(model.joints[i],data.joints[i],
SimpleVisitor::ArgsType(model,data,i));
}
}
BOOST_AUTO_TEST_SUITE_END ()