display-robot.cc 2.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright (C) 2012 by Antonio El Khoury.
//
// This file is part of the hpp-model-urdf.
//
// hpp-model-urdf 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.
//
// hpp-model-urdf 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with hpp-model-urdf.  If not, see
// <http://www.gnu.org/licenses/>.

#define BOOST_TEST_MODULE display-robot

21
22
#include <fstream>

23
24
25
26
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>

#include <KineoModel/kppLicense.h>
27
#include <KineoModel/kppJointComponent.h>
28
29

#include "hpp/model/urdf/parser.hh"
30
#include "hpp/model/srdf/parser.hh"
31
#include "hpp/model/rcpdf/parser.hh"
32
33
34
35
36
37
38
39
40
41
42
43

using boost::test_tools::output_test_stream;

BOOST_AUTO_TEST_CASE (display_robot)
{
  // Validate Kineo license.
  if (!CkppLicense::initialize ())
    {
      std::cout << "Failed to validate Kineo license." << std::endl;
      return;
    }
  
44
45
46
  using namespace hpp::model::urdf;
  hpp::model::urdf::Parser urdfParser; 
  hpp::model::srdf::Parser srdfParser; 
47
  hpp::model::rcpdf::Parser rcpdfParser; 
48
49
  hpp::model::HumanoidRobotShPtr humanoidRobot;

50
  humanoidRobot = urdfParser.parse ("package://hrp2_14_description/urdf/hrp2_capsule.urdf");
51

52
53
54
  srdfParser.parse ("package://hrp2_14_description/urdf/hrp2_capsule.urdf",
  		    "package://hrp2_14_description/srdf/hrp2_capsule.srdf",
  		    humanoidRobot);
55

56
  BOOST_CHECK_EQUAL (!!humanoidRobot, 1);
57

58
59
  hpp::model::srdf::Parser::HppConfigurationType config
    = srdfParser.getHppReferenceConfig ("all", "half_sitting");
60

61
  humanoidRobot->hppSetCurrentConfig (config);
62

63
64
65
66
67
  rcpdfParser.parse ("package://hrp2_14_description/rcpdf/hrp2.rcpdf",
		     humanoidRobot);

  std::ofstream log ("./display-robot.log");
  log << *(humanoidRobot.get ()) << std::endl;
68

69
}