Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65173707
Oncilla.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 1, 12:24
Size
2 KB
Mime Type
text/x-c
Expires
Mon, Jun 3, 12:24 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18018597
Attached To
R6622 liboncilla
Oncilla.cpp
View Options
/*
* Oncilla.cpp
*
* Created on: 15 dec. 2011
* Author: Alexandre Tuleu, Arne Nordmann
*/
#include "Oncilla.h"
#include "OncillaTrunk.h"
#include "OncillaL01.h"
#include "OncillaL2.h"
#include "OncillaL3.h"
#include "OncillaL4.h"
namespace
rci
{
namespace
oncilla
{
Oncilla
::
LegNames
Oncilla
::
s_legNames
;
const
std
::
string
&
Oncilla
::
nameOfLeg
(
Leg
l
){
if
(
s_legNames
.
empty
()){
s_legNames
.
push_back
(
"Left Fore"
);
s_legNames
.
push_back
(
"Right Fore"
);
s_legNames
.
push_back
(
"Left Hind"
);
s_legNames
.
push_back
(
"Right Hind"
);
s_legNames
.
push_back
(
"Undefined"
);
}
if
(
l
>=
NUM_LEGS
){
return
s_legNames
.
back
();
}
return
s_legNames
[
l
];
}
Oncilla
::
Oncilla
(
OncillaSynchronizerPtr
synchronizer
)
:
d_synchronizer
(
synchronizer
){
init
();
}
Oncilla
::~
Oncilla
()
{
}
#define CREATE_NODES(LegName)do{\
d_L0s.push_back(OncillaL0Ptr(new OncillaL0(LegName " Oncilla L0" )));\
d_L1s.push_back(OncillaL1Ptr(new OncillaL1(*d_synchronizer,\
LegName " Oncilla L1")));\
d_L2s.push_back(OncillaL2Ptr(new OncillaL2(*d_synchronizer,\
LegName " Oncilla L2")));\
d_L3s.push_back(OncillaL3Ptr(new OncillaL3(LegName " Oncilla L3")));\
d_L4s.push_back(OncillaL4Ptr(new OncillaL4(LegName " Oncilla L4")));\
}while(0)
#define REGISTER_NODES(Type)do{\
for(std::vector < Oncilla ## Type ## Ptr >::const_iterator n = d_ ## Type ## s.begin();\
n != d_ ## Type ## s.end();\
++n){\
Oncilla::Leg l = static_cast<Oncilla::Leg>(n - d_ ## Type ## s.begin());\
d_synchronizer->register ## Type ## Node(l,*n);\
}\
}while(0)
void
Oncilla
::
init
()
{
d_L0s
.
reserve
(
4
);
d_L1s
.
reserve
(
4
);
d_L2s
.
reserve
(
4
);
d_L3s
.
reserve
(
4
);
d_L4s
.
reserve
(
4
);
CREATE_NODES
(
"Left Fore"
);
CREATE_NODES
(
"Right Fore"
);
CREATE_NODES
(
"Left Hind"
);
CREATE_NODES
(
"Right Hind"
);
d_trunk
=
OncillaTrunkPtr
(
new
OncillaTrunk
(
"Oncilla Trunk"
));
REGISTER_NODES
(
L0
);
REGISTER_NODES
(
L1
);
REGISTER_NODES
(
L2
);
REGISTER_NODES
(
L3
);
REGISTER_NODES
(
L4
);
d_synchronizer
->
registerTrunkNode
(
d_trunk
);
}
OncillaL0Ptr
Oncilla
::
getL0
(
Leg
l
)
const
{
return
this
->
d_L0s
[
l
];
}
OncillaL1Ptr
Oncilla
::
getL1
(
Leg
l
)
const
{
return
this
->
d_L1s
[
l
];
}
OncillaL2Ptr
Oncilla
::
getL2
(
Leg
l
)
const
{
return
this
->
d_L2s
[
l
];
}
OncillaL3Ptr
Oncilla
::
getL3
(
Leg
l
)
const
{
return
this
->
d_L3s
[
l
];
}
OncillaL4Ptr
Oncilla
::
getL4
(
Leg
l
)
const
{
return
this
->
d_L4s
[
l
];
}
OncillaTrunkPtr
Oncilla
::
getTrunk
()
const
{
return
this
->
d_trunk
;
}
}
}
Event Timeline
Log In to Comment