iCub-main
DebugInterfaces.cpp
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4  * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
5  * Author: Marco Randazzo
6  * email: marco.randazzo@iit.it
7  * website: www.robotcub.org
8  * Permission is granted to copy, distribute, and/or modify this program
9  * under the terms of the GNU General Public License, version 2 or any
10  * later version published by the Free Software Foundation.
11  *
12  * A copy of the license can be found at
13  * http://www.robotcub.org/icub/license/gpl.txt
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18  * Public License for more details
19 */
20 
21 #include <iCub/DebugInterfaces.h>
22 //A collection of debug methods useful to send raw commands directly to the control boards.
23 
24 bool yarp::dev::ImplementDebugInterface::setParameter(int j, unsigned int type, double value)
25 {
26  int k=castToMapper2(helper)->toHw(j);
27  return raw->setParameterRaw(j, type, value);
28 }
29 
30 bool yarp::dev::ImplementDebugInterface::getParameter(int j, unsigned int type, double* value)
31 {
32  int k=castToMapper2(helper)->toHw(j);
33  return raw->getParameterRaw(j, type, value);
34 }
35 
36 bool yarp::dev::ImplementDebugInterface::setDebugParameter(int j, unsigned int index, double value)
37 {
38  int k=castToMapper2(helper)->toHw(j);
39  return raw->setDebugParameterRaw(j, index, value);
40 }
41 
42 bool yarp::dev::ImplementDebugInterface::getDebugParameter(int j, unsigned int index, double* value)
43 {
44  int k=castToMapper2(helper)->toHw(j);
45  return raw->getDebugParameterRaw(j, index, value);
46 }
47 
49 {
50  raw=r;
51  helper=0;
52 }
53 
54 bool yarp::dev::ImplementDebugInterface::initialize(int size, const int *amap, const double *angleToEncoder, const double *zeros, const double *rotToEncoder)
55 {
56  if (helper!=0)
57  return false;
58 
59  double *dummy=new double [size];
60  for(int k=0;k<size;k++)
61  dummy[k]=0;
62 
63  helper=(void *)(new ControlBoardHelper2(size, amap, angleToEncoder, zeros, dummy, rotToEncoder));
64  _YARP_ASSERT_DEBUG(helper != 0);
65 
66  delete [] dummy;
67  return true;
68 }
69 
71 {
72  uninitialize();
73 }
74 
76 {
77  if (helper!=0)
78  {
79  delete castToMapper2(helper);
80  helper=0;
81  }
82 
83  return true;
84 }
85 
A collection of debug methods useful to send raw commands directly to the control boards.
ControlBoardHelper2 * castToMapper2(void *p)
#define _YARP_ASSERT_DEBUG(x)
virtual bool setParameterRaw(int j, unsigned int type, double value)=0
bool setDebugParameter(int j, unsigned int index, double value)
bool setParameter(int j, unsigned int type, double value)
bool initialize(int k, const int *amap, const double *angleToEncoder, const double *zeros, const double *rotToEncoder)
bool getDebugParameter(int j, unsigned int index, double *value)
bool getParameter(int j, unsigned int type, double *value)
ImplementDebugInterface(IDebugInterfaceRaw *v)
zeros(2, 2) eye(2