Page MenuHomec4science

OncillaL01.cpp
No OneTemporary

File Metadata

Created
Mon, Nov 4, 12:18

OncillaL01.cpp

#include "OncillaL01.h"
using namespace std;
namespace rci {
namespace oncilla {
OncillaL0::OncillaL0(const std::string &name) :
ResourceNode(name), Controlled(), PositionControlled() {
}
bool OncillaL0::isConverged() const {
return false;
}
bool OncillaL0::setJointPosition(JointAnglesPtr position) {
// Successfull
this->_lastCommandedPosition = position;
return true;
}
JointAnglesPtr OncillaL0::getLastPositionCommand() const {
if (this->_lastCommandedPosition) {
return this->_lastCommandedPosition;
}
throw runtime_error("No position command received yet.");
}
OncillaL0::~OncillaL0() {
}
std::string OncillaL0::print() const {
ostringstream outstream(ostringstream::out);
outstream.precision(3); // Precision when printing double values
outstream << "<Oncilla Hip>" << endl;
return outstream.str();
}
OncillaL1::OncillaL1(OncillaSynchronizer &s, const std::string &name) :
ResourceNode(name), Controlled(), Sensing(), PositionControlled(), PositionSensing(), TorqueControlled(), ImpedanceControlled(), synchronizer(
s) {
this->_dimension = 2; // Two encoder values - should always be the same
}
bool OncillaL1::isConverged() const {
throw std::runtime_error("Not yet implemented.");
return false;
}
bool OncillaL1::setJointPosition(JointAnglesPtr position) {
// Successfull
this->_lastCommandedPosition = position;
return true;
}
JointAnglesPtr OncillaL1::getJointPosition() const {
return this->_latestJointPosition;
}
bool OncillaL1::setJointVelocity(JointVelocitiesPtr vel) {
throw std::runtime_error("Not yet implemented.");
}
bool OncillaL1::setJointTorque(JointTorquesPtr torque) {
throw std::runtime_error("Not yet implemented.");
}
bool OncillaL1::setJointImpedance(JointImpedancePtr imped) {
if (this->synchronizer.tooBusy()) {
throw std::runtime_error(
"Synchronizer has to be switched off to change JointImpedance.");
} else {
throw std::runtime_error("Not yet implemented.");
}
}
JointAnglesPtr OncillaL1::getLastPositionCommand() const {
if (this->_lastCommandedPosition) {
return this->_lastCommandedPosition;
}
// If we don`t have a command yet, we return the latest sensor value
if (this->_latestJointPosition) {
// TODO: Log
return this->_latestJointPosition;
}
throw runtime_error("No position command received yet.");
}
OncillaL1::~OncillaL1() {
}
std::string OncillaL1::print() const {
ostringstream outstream(ostringstream::out);
outstream.precision(3); // Precision when printing double values
outstream << "<Oncilla Hip>" << endl;
return outstream.str();
}
}
}

Event Timeline