Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79066809
OncillaHip.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, Aug 24, 14:14
Size
4 KB
Mime Type
text/x-c
Expires
Mon, Aug 26, 14:14 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20142980
Attached To
R6622 liboncilla
OncillaHip.cpp
View Options
#include "OncillaHip.h"
using
namespace
std
;
using
namespace
rsb
;
namespace
cca
{
namespace
rci
{
namespace
driver
{
OncillaHipSagittal
::
OncillaHipSagittal
(
std
::
string
name
)
:
ResourceNode
(
name
),
Controlled
(),
Sensing
(),
PositionControlled
(),
PositionSensing
(),
TorqueControlled
(),
ImpedanceControlled
()
{
this
->
_dimension
=
2
;
// Two encoder values - should always be the same
this
->
addInputPort
<
JointAngles
>
();
// PositionControlled
this
->
addInputPort
<
JointVelocities
>
();
// VelocityControlled
this
->
addInputPort
<
JointTorques
>
();
// TorqueControlled
this
->
addInputPort
<
JointImpedance
>
();
// ImpedanceControlled
this
->
addOutputPort
<
JointAngles
>
();
// PositionSensing
}
bool
OncillaHipSagittal
::
isConverged
()
const
{
throw
std
::
runtime_error
(
"Not yet implemented."
);
}
bool
OncillaHipSagittal
::
setJointPosition
(
JointAnglesPtr
position
)
{
// Successfull
this
->
_lastCommandedPosition
=
position
;
return
true
;
}
JointAnglesPtr
OncillaHipSagittal
::
getJointPosition
()
const
{
return
this
->
_latestJointPosition
;
}
bool
OncillaHipSagittal
::
setJointVelocity
(
JointVelocitiesPtr
vel
)
{
throw
std
::
runtime_error
(
"Not yet implemented."
);
}
bool
OncillaHipSagittal
::
setJointTorque
(
JointTorquesPtr
torque
)
{
throw
std
::
runtime_error
(
"Not yet implemented."
);
}
bool
OncillaHipSagittal
::
setJointImpedance
(
JointImpedancePtr
imped
)
{
throw
std
::
runtime_error
(
"Not yet implemented."
);
}
JointAnglesPtr
OncillaHipSagittal
::
getLastPositionCommand
()
const
{
// TODO: The second part f this condition shouldn`t be necessary
if
(
this
->
_lastCommandedPosition
&&
this
->
_lastCommandedPosition
.
get
())
{
//std::cout << this->_lastCommandedPosition->print();
return
this
->
_lastCommandedPosition
;
}
// No command set yet. Returning current joint values instead
return
this
->
_latestJointPosition
;
}
OncillaHipSagittal
::~
OncillaHipSagittal
()
{
}
void
OncillaHipSagittal
::
onProcess
()
{
// std::cout << "[Node " << this->getName() << "] Processing ..." << std::endl;
if
(
!
this
->
inputs
[
0
]
->
empty
()
&&
this
->
inputs
[
0
]
->
newItem
())
{
// Cache new value
this
->
setJointPosition
(
boost
::
static_pointer_cast
<
JointAngles
>
(
this
->
inputs
[
0
]
->
tryGet
()));
}
// Publish value
if
((
this
->
_latestJointPosition
!=
NULL
)
&&
(
this
->
_latestJointPosition
.
get
()
!=
NULL
))
{
Informer
<
JointAngles
>::
DataPtr
status
(
new
JointAngles
(
this
->
_latestJointPosition
->
asDouble
(
0
)));
this
->
publish
(
0
,
status
);
}
}
std
::
string
OncillaHipSagittal
::
print
()
const
{
ostringstream
outstream
(
ostringstream
::
out
);
outstream
.
precision
(
3
);
// Precision when printing double values
outstream
<<
"<Oncilla Hip>"
<<
endl
;
return
outstream
.
str
();
}
CCANodePtr
OncillaHipSagittal
::
create
(
string
name
)
{
CCANodePtr
hipnode
(
new
OncillaHipSagittal
(
name
));
return
hipnode
;
}
/** Oncilla Hip Transverse **/
OncillaHipTransverse
::
OncillaHipTransverse
(
std
::
string
name
)
:
ResourceNode
(
name
),
Controlled
(),
PositionControlled
()
{
this
->
addInputPort
<
JointAngles
>
();
// PositionControlled
}
bool
OncillaHipTransverse
::
isConverged
()
const
{
return
false
;
}
bool
OncillaHipTransverse
::
setJointPosition
(
JointAnglesPtr
position
)
{
// Successfull
this
->
_lastCommandedPosition
=
position
;
return
true
;
}
JointAnglesPtr
OncillaHipTransverse
::
getLastPositionCommand
()
const
{
// TODO: The second part f this condition shouldn`t be necessary
if
(
this
->
_lastCommandedPosition
&&
this
->
_lastCommandedPosition
.
get
())
{
//std::cout << this->_lastCommandedPosition->print();
return
this
->
_lastCommandedPosition
;
}
}
OncillaHipTransverse
::~
OncillaHipTransverse
()
{
}
void
OncillaHipTransverse
::
onProcess
()
{
// std::cout << "[Node " << this->getName() << "] Processing ..." << std::endl;
if
(
!
this
->
inputs
[
0
]
->
empty
()
&&
this
->
inputs
[
0
]
->
newItem
())
{
// Cache new value
this
->
setJointPosition
(
boost
::
static_pointer_cast
<
JointAngles
>
(
this
->
inputs
[
0
]
->
tryGet
()));
}
}
std
::
string
OncillaHipTransverse
::
print
()
const
{
ostringstream
outstream
(
ostringstream
::
out
);
outstream
.
precision
(
3
);
// Precision when printing double values
outstream
<<
"<Oncilla Hip>"
<<
endl
;
return
outstream
.
str
();
}
CCANodePtr
OncillaHipTransverse
::
create
(
string
name
)
{
CCANodePtr
hipnode
(
new
OncillaHipTransverse
(
name
));
return
hipnode
;
}
}
}
}
Event Timeline
Log In to Comment