diff --git a/.gitignore b/.gitignore index 1aafec0..ae5db51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,17 @@ CMakeFiles Makefile CMakeCache.txt cmake_install.cmake *~ .cproject .project \#*# .project .cproject +CPackConfig.cmake +CPackSourceConfig.cmake +build +install_manifest.txt +libOncillaConfig.cmake +test/CTestTestfile.cmake +liboncilla.pc diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..5fdc064 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +libOncillaConfig.h diff --git a/src/Oncilla.cpp b/src/Oncilla.cpp index 98ec867..550ae20 100644 --- a/src/Oncilla.cpp +++ b/src/Oncilla.cpp @@ -1,92 +1,93 @@ /* * 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::Oncilla() : - synchronizer(), d_l0s(), d_l1s(), d_l2s(), d_l3s(), d_l4s(), d_trunk() { -} - -Oncilla::~Oncilla() { - // TODO Auto-generated destructor stub -} - -void Oncilla::init() { - d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 LEFT FORE"))); - d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 RIGHT FORE"))); - d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 LEFT HIND"))); - d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 RIGHT HIND"))); - - d_l1s.push_back( - OncillaL1Ptr(new OncillaL1(*synchronizer, "Oncilla L1 LEFT FORE"))); - d_l1s.push_back( - OncillaL1Ptr(new OncillaL1(*synchronizer, "Oncilla L1 RIGHT FORE"))); - d_l1s.push_back( - OncillaL1Ptr(new OncillaL1(*synchronizer, "Oncilla L1 LEFT HIND"))); - d_l1s.push_back( - OncillaL1Ptr(new OncillaL1(*synchronizer, "Oncilla L1 RIGHT HIND"))); - - d_l2s.push_back( - OncillaL2Ptr(new OncillaL2(*synchronizer, "Oncilla L2 LEFT FORE"))); - d_l2s.push_back( - OncillaL2Ptr(new OncillaL2(*synchronizer, "Oncilla L2 RIGHT FORE"))); - d_l2s.push_back( - OncillaL2Ptr(new OncillaL2(*synchronizer, "Oncilla L2 LEFT HIND"))); - d_l2s.push_back( - OncillaL2Ptr(new OncillaL2(*synchronizer, "Oncilla L2 RIGHT HIND"))); - - d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 LEFT FORE"))); - d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 RIGHT FORE"))); - d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 LEFT HIND"))); - d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 RIGHT HIND"))); - - d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 LEFT FORE"))); - d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 RIGHT FORE"))); - d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 LEFT HIND"))); - d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 RIGHT HIND"))); - - d_trunk = OncillaTrunkPtr(new OncillaTrunk("Oncilla 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; -} - -void Oncilla::setSynchronizer(OncillaSynchronizerPtr sync) { - this->synchronizer = sync; -} + Oncilla::Oncilla() : + synchronizer(), d_l0s(), d_l1s(), d_l2s(), d_l3s(), d_l4s(), d_trunk() { + } + + Oncilla::~Oncilla() { + // TODO Auto-generated destructor stub + } + + void Oncilla::init() { + d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 LEFT FORE"))); + d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 RIGHT FORE"))); + d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 LEFT HIND"))); + d_l0s.push_back(OncillaL0Ptr(new OncillaL0("Oncilla L0 RIGHT HIND"))); + + d_l1s.push_back(OncillaL1Ptr(new OncillaL1(*synchronizer, + "Oncilla L1 LEFT FORE"))); + d_l1s.push_back(OncillaL1Ptr(new OncillaL1(*synchronizer, + "Oncilla L1 RIGHT FORE"))); + + d_l1s.push_back(OncillaL1Ptr(new OncillaL1(*synchronizer, + "Oncilla L1 LEFT HIND"))); + d_l1s.push_back(OncillaL1Ptr(new OncillaL1(*synchronizer, + "Oncilla L1 RIGHT HIND"))); + + d_l2s.push_back(OncillaL2Ptr(new OncillaL2(*synchronizer, + "Oncilla L2 LEFT FORE"))); + d_l2s.push_back(OncillaL2Ptr(new OncillaL2(*synchronizer, + "Oncilla L2 RIGHT FORE"))); + d_l2s.push_back(OncillaL2Ptr(new OncillaL2(*synchronizer, + "Oncilla L2 LEFT HIND"))); + d_l2s.push_back(OncillaL2Ptr(new OncillaL2(*synchronizer, + "Oncilla L2 RIGHT HIND"))); + + d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 LEFT FORE"))); + d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 RIGHT FORE"))); + d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 LEFT HIND"))); + d_l3s.push_back(OncillaL3Ptr(new OncillaL3("Oncilla L3 RIGHT HIND"))); + + d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 LEFT FORE"))); + d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 RIGHT FORE"))); + d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 LEFT HIND"))); + d_l4s.push_back(OncillaL4Ptr(new OncillaL4("L4 RIGHT HIND"))); + + d_trunk = OncillaTrunkPtr(new OncillaTrunk("Oncilla 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; + } + + void Oncilla::setSynchronizer(OncillaSynchronizerPtr sync) { + this->synchronizer = sync; + } } } diff --git a/src/Oncilla.h b/src/Oncilla.h index 0dcdbe5..4d403fc 100644 --- a/src/Oncilla.h +++ b/src/Oncilla.h @@ -1,78 +1,80 @@ /* * Oncilla.h * * Created on: 15 dec. 2011 * Author: Alexandre Tuleu, Arne Nordmann */ #pragma once #include <vector> #include <iostream> #include <boost/shared_ptr.hpp> /* * */ /* * */ namespace rci { namespace oncilla { class Oncilla; typedef boost::shared_ptr<Oncilla> OncillaPtr; class OncillaSynchronizer; typedef boost::shared_ptr<OncillaSynchronizer> OncillaSynchronizerPtr; class OncillaTrunk; typedef boost::shared_ptr<OncillaTrunk> OncillaTrunkPtr; class OncillaL0; typedef boost::shared_ptr<OncillaL0> OncillaL0Ptr; class OncillaL1; typedef boost::shared_ptr<OncillaL1> OncillaL1Ptr; class OncillaL2; typedef boost::shared_ptr<OncillaL2> OncillaL2Ptr; class OncillaL3; typedef boost::shared_ptr<OncillaL3> OncillaL3Ptr; class OncillaL4; typedef boost::shared_ptr<OncillaL4> OncillaL4Ptr; class Oncilla { public: - enum Leg { - LEFT_FORE = 0, - RIGHT_FORE = 1, - LEFT_HIND = 2, - RIGHT_HIND = 3, - NUM_LEGS = 4 - }; - - Oncilla(); - virtual ~Oncilla(); - - OncillaL0Ptr getL0(Leg l) const; - OncillaL1Ptr getL1(Leg l) const; - OncillaL2Ptr getL2(Leg l) const; - OncillaL3Ptr getL3(Leg l) const; - OncillaL4Ptr getL4(Leg l) const; - OncillaTrunkPtr getTrunk() const; - - void setSynchronizer(OncillaSynchronizerPtr synchronizer); + enum Leg { + LEFT_FORE = 0, + RIGHT_FORE = 1, + LEFT_HIND = 2, + RIGHT_HIND = 3, + NUM_LEGS = 4 + }; + + Oncilla(); + virtual ~Oncilla(); + + OncillaL0Ptr getL0(Leg l) const; + OncillaL1Ptr getL1(Leg l) const; + OncillaL2Ptr getL2(Leg l) const; + OncillaL3Ptr getL3(Leg l) const; + OncillaL4Ptr getL4(Leg l) const; + OncillaTrunkPtr getTrunk() const; + + void setSynchronizer(OncillaSynchronizerPtr synchronizer); + + private: - void init(); + void init(); - OncillaSynchronizerPtr synchronizer; + OncillaSynchronizerPtr synchronizer; - std::vector<OncillaL0Ptr> d_l0s; - std::vector<OncillaL1Ptr> d_l1s; - std::vector<OncillaL2Ptr> d_l2s; - std::vector<OncillaL3Ptr> d_l3s; - std::vector<OncillaL4Ptr> d_l4s; + std::vector<OncillaL0Ptr> d_l0s; + std::vector<OncillaL1Ptr> d_l1s; + std::vector<OncillaL2Ptr> d_l2s; + std::vector<OncillaL3Ptr> d_l3s; + std::vector<OncillaL4Ptr> d_l4s; - OncillaTrunkPtr d_trunk; + OncillaTrunkPtr d_trunk; }; } } diff --git a/src/OncillaL01.cpp b/src/OncillaL01.cpp index ec020db..aac219c 100644 --- a/src/OncillaL01.cpp +++ b/src/OncillaL01.cpp @@ -1,101 +1,106 @@ #include "OncillaL01.h" using namespace std; namespace rci { namespace oncilla { OncillaL0::OncillaL0(const std::string &name) : - ResourceNode(name), Controlled(), PositionControlled() { + ResourceNode(name), Controlled(), PositionControlled() { } bool OncillaL0::isConverged() const { - return false; + return false; } bool OncillaL0::setJointPosition(JointAnglesPtr position) { - // Successfull - this->_lastCommandedPosition = position; - return true; + // Successfull + this->_lastCommandedPosition = position; + return true; } JointAnglesPtr OncillaL0::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; - } - return JointAnglesPtr(); + // 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; + } + return JointAnglesPtr(); } 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(); + 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 +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; + throw std::runtime_error("Not yet implemented."); + return false; } bool OncillaL1::setJointPosition(JointAnglesPtr position) { - // Successfull - this->_lastCommandedPosition = position; - return true; + // Successfull + this->_lastCommandedPosition = position; + return true; } JointAnglesPtr OncillaL1::getJointPosition() const { - return this->_latestJointPosition; + return this->_latestJointPosition; } bool OncillaL1::setJointVelocity(JointVelocitiesPtr vel) { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } bool OncillaL1::setJointTorque(JointTorquesPtr torque) { - throw std::runtime_error("Not yet implemented."); + 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."); - } + 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 { - // 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; + // 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; } 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(); + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "<Oncilla Hip>" << endl; + return outstream.str(); } } } diff --git a/src/OncillaL01.h b/src/OncillaL01.h index 0341a78..c18c4fd 100644 --- a/src/OncillaL01.h +++ b/src/OncillaL01.h @@ -1,153 +1,153 @@ #pragma once #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/ResourceNode.h> #include <rci/Controlled.h> #include <rci/Configurable.h> #include <rci/Sensing.h> #include <rci/dto/JointAngles.h> #include "OncillaSynchronizer.h" namespace rci { namespace oncilla { class OncillaL0; typedef boost::shared_ptr<OncillaL0> OncillaL0Ptr; /** * Node class, representing the hip node of the quadruped robot. * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL0: public rci::ResourceNode, - public rci::Controlled, - public rci::PositionControlled { +public rci::Controlled, +public rci::PositionControlled { public: - /** - * Special constructor to also link to webots - */ - OncillaL0(const std::string &name = "Oncilla Hip"); - - virtual ~OncillaL0(); - - /** - * Returns, if controller is converged. - * @return True, if controller is converged after last command. - */ - bool isConverged() const; - - /** - * Commanding a joint position. - * @param position Position command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - bool setJointPosition(JointAnglesPtr position); - - /** - * Returns latest position command. Note, that this is the latest valid - * commanded position. If the position command exceeds limits and is - * therefore rejected, it .. - */ - virtual JointAnglesPtr getLastPositionCommand() const; - - /** - * Print - */ - std::string print() const; + /** + * Special constructor to also link to webots + */ + OncillaL0(const std::string &name = "Oncilla Hip"); + + virtual ~OncillaL0(); + + /** + * Returns, if controller is converged. + * @return True, if controller is converged after last command. + */ + bool isConverged() const; + + /** + * Commanding a joint position. + * @param position Position command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + bool setJointPosition(JointAnglesPtr position); + + /** + * Returns latest position command. Note, that this is the latest valid + * commanded position. If the position command exceeds limits and is + * therefore rejected, it .. + */ + virtual JointAnglesPtr getLastPositionCommand() const; + + /** + * Print + */ + std::string print() const; }; class OncillaL1; typedef boost::shared_ptr<OncillaL1> OncillaL1Ptr; /** * Node class, representing the hip node of the quadruped robot. * * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL1: public rci::ResourceNode, - public rci::Controlled, - public rci::Sensing, - public rci::PositionControlled, - public rci::PositionSensing, // Two encoder values - public rci::VelocityControlled, - public rci::TorqueControlled, - public rci::ImpedanceControlled { + public rci::Controlled, + public rci::Sensing, + public rci::PositionControlled, + public rci::PositionSensing, // Two encoder values + public rci::VelocityControlled, + public rci::TorqueControlled, + public rci::ImpedanceControlled { public: - /** - * Special constructor to also link to webots - */ - OncillaL1(OncillaSynchronizer &s, const std::string &name = "Oncilla Hip"); - - virtual ~OncillaL1(); - - /** - * Returns, if controller is converged. - * @return True, if controller is converged after last command. - */ - bool isConverged() const; - - /** - * Commanding a joint position. - * @param position Position command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - bool setJointPosition(JointAnglesPtr position); - - /** - * Returns current joint position. - * @return Current joint position - */ - virtual JointAnglesPtr getJointPosition() const; - - /** - * Commanding a joint velocity. - * @param position Position command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - virtual bool setJointVelocity(rci::JointVelocitiesPtr vel); - - /** - * Returns current joint torque. - * @return Current joint torque - */ - virtual bool setJointTorque(JointTorquesPtr torque); - - /** - * Returns current joint torque. - * @return Current joint torque - */ - virtual bool setJointImpedance(JointImpedancePtr imped); - - /** - * Returns latest position command. Note, that this is the latest valid - * commanded position. If the position command exceeds limits and is - * therefore rejected, it .. - */ - virtual JointAnglesPtr getLastPositionCommand() const; - - /** - * Print - */ - std::string print() const; + /** + * Special constructor to also link to webots + */ + OncillaL1(OncillaSynchronizer &s, const std::string &name = "Oncilla Hip"); + + virtual ~OncillaL1(); + + /** + * Returns, if controller is converged. + * @return True, if controller is converged after last command. + */ + bool isConverged() const; + + /** + * Commanding a joint position. + * @param position Position command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + bool setJointPosition(JointAnglesPtr position); + + /** + * Returns current joint position. + * @return Current joint position + */ + virtual JointAnglesPtr getJointPosition() const; + + /** + * Commanding a joint velocity. + * @param position Position command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + virtual bool setJointVelocity(rci::JointVelocitiesPtr vel); + + /** + * Returns current joint torque. + * @return Current joint torque + */ + virtual bool setJointTorque(JointTorquesPtr torque); + + /** + * Returns current joint torque. + * @return Current joint torque + */ + virtual bool setJointImpedance(JointImpedancePtr imped); + + /** + * Returns latest position command. Note, that this is the latest valid + * commanded position. If the position command exceeds limits and is + * therefore rejected, it .. + */ + virtual JointAnglesPtr getLastPositionCommand() const; + + /** + * Print + */ + std::string print() const; private: - /** - * Reference to OncillaSynchronizer - * @todo This is a dangerous reference which will become invalid as soon as - * OncillaSynchronizer gets deleted outside. - */ - OncillaSynchronizer &synchronizer; + /** + * Reference to OncillaSynchronizer + * @todo This is a dangerous reference which will become invalid as soon as + * OncillaSynchronizer gets deleted outside. + */ + OncillaSynchronizer &synchronizer; }; } } diff --git a/src/OncillaL2.cpp b/src/OncillaL2.cpp index 880c970..0c0c75e 100644 --- a/src/OncillaL2.cpp +++ b/src/OncillaL2.cpp @@ -1,71 +1,77 @@ #include "OncillaL2.h" using namespace std; using namespace boost; namespace rci { namespace oncilla { -OncillaL2::OncillaL2(OncillaSynchronizer &s, const std::string &name) : - ResourceNode(name), Controlled(), Sensing(), PositionControlled(), - PositionSensing(), VelocityControlled(), TorqueControlled(), - ImpedanceControlled(), synchronizer(s) { - // Two encoder values - difference is due to passive compliance - this->_dimension = 2; +OncillaL2::OncillaL2(OncillaSynchronizer &s, const std::string &name) + : ResourceNode(name) + , Controlled() + , Sensing() + , PositionControlled() + , PositionSensing() + , VelocityControlled() + , TorqueControlled() + , ImpedanceControlled() + , synchronizer(s) { + // Two encoder values - difference is due to passive compliance + this->_dimension = 2; } bool OncillaL2::isConverged() const { - return false; + return false; } bool OncillaL2::setJointPosition(JointAnglesPtr position) { - // Successfull - // std::cerr << "[OncillaKnee] " << position << std::endl; - this->_lastCommandedPosition = position; - return true; + // Successfull + // std::cerr << "[OncillaKnee] " << position << std::endl; + this->_lastCommandedPosition = position; + return true; } JointAnglesPtr OncillaL2::getJointPosition() const { - return this->_latestJointPosition; + return this->_latestJointPosition; } OncillaL2::~OncillaL2() { } std::string OncillaL2::print() const { - ostringstream outstream(ostringstream::out); - outstream.precision(3); // Precision when printing double values - outstream << "<Oncilla Knee>" << endl; - return outstream.str(); + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "<Oncilla Knee>" << endl; + return outstream.str(); } bool OncillaL2::setJointTorque(JointTorquesPtr torques) { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } bool OncillaL2::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."); - } + 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."); + } } bool OncillaL2::setJointVelocity(JointVelocitiesPtr vel) { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } JointAnglesPtr OncillaL2::getLastPositionCommand() const { - // TODO: The second part f this condition shouldn`t be necessary - if (!this->_lastCommandedPosition || !this->_lastCommandedPosition.get()) { - // No command set yet. Returning current joint values instead - // FIXME: Instead of return current position set command to current position - return this->_latestJointPosition; - } + // TODO: The second part f this condition shouldn`t be necessary + if (!this->_lastCommandedPosition || !this->_lastCommandedPosition.get()) { + // No command set yet. Returning current joint values instead + // FIXME: Instead of return current position set command to current position + return this->_latestJointPosition; + } - return this->_lastCommandedPosition; + return this->_lastCommandedPosition; } } } diff --git a/src/OncillaL2.h b/src/OncillaL2.h index fe3cdba..32c0c31 100644 --- a/src/OncillaL2.h +++ b/src/OncillaL2.h @@ -1,100 +1,100 @@ #pragma once #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/ResourceNode.h> #include <rci/Controlled.h> #include <rci/Configurable.h> #include <rci/Sensing.h> #include <rci/dto/JointAngles.h> #include "OncillaSynchronizer.h" namespace rci { namespace oncilla { class OncillaL2; typedef boost::shared_ptr<OncillaL2> OncillaL2Ptr; /** * Node class, representing the knee node of the quadruped robot. * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL2: public rci::ResourceNode, - public rci::Controlled, - public rci::Sensing, - public rci::PositionControlled, - public rci::PositionSensing, - public rci::VelocityControlled, - public rci::TorqueControlled, - public rci::ImpedanceControlled { + public rci::Controlled, + public rci::Sensing, + public rci::PositionControlled, + public rci::PositionSensing, + public rci::VelocityControlled, + public rci::TorqueControlled, + public rci::ImpedanceControlled { public: - OncillaL2(OncillaSynchronizer &s, const std::string &name = "Oncilla Knee"); - virtual ~OncillaL2(); - - /** - * Returns, if controller is converged. - * @return True, if controller is converged after last command. - */ - bool isConverged() const; - - /** - * Commanding a joint position. - * @param position Position command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - bool setJointPosition(JointAnglesPtr position); - - /** - * Returns current joint position. - * @return Current joint position - */ - virtual JointAnglesPtr getJointPosition() const; - - /** - * Commanding a joint velocity. - * @param position Velocity command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - bool setJointVelocity(JointVelocitiesPtr vel); - - /** - * Commanding a joint velocity. - * @param position Velocity command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - bool setJointImpedance(JointImpedancePtr imped); - - /** - * Commanding a joint torque. - * @param position Torque command - * @return Return, if successfull. (e.g. not exceeding joint limits) - * @todo Check for correct control mode - */ - virtual bool setJointTorque(rci::JointTorquesPtr torques); - - /** - * Returns latest position command. Note, that this is the latest valid - * commanded position. If the position command exceeds limits and is - * therefore rejected, it .. - */ - virtual JointAnglesPtr getLastPositionCommand() const; - - /** - * Print - */ - std::string print() const; + OncillaL2(OncillaSynchronizer &s, const std::string &name = "Oncilla Knee"); + virtual ~OncillaL2(); + + /** + * Returns, if controller is converged. + * @return True, if controller is converged after last command. + */ + bool isConverged() const; + + /** + * Commanding a joint position. + * @param position Position command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + bool setJointPosition(JointAnglesPtr position); + + /** + * Returns current joint position. + * @return Current joint position + */ + virtual JointAnglesPtr getJointPosition() const; + + /** + * Commanding a joint velocity. + * @param position Velocity command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + bool setJointVelocity(JointVelocitiesPtr vel); + + /** + * Commanding a joint velocity. + * @param position Velocity command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + bool setJointImpedance(JointImpedancePtr imped); + + /** + * Commanding a joint torque. + * @param position Torque command + * @return Return, if successfull. (e.g. not exceeding joint limits) + * @todo Check for correct control mode + */ + virtual bool setJointTorque(rci::JointTorquesPtr torques); + + /** + * Returns latest position command. Note, that this is the latest valid + * commanded position. If the position command exceeds limits and is + * therefore rejected, it .. + */ + virtual JointAnglesPtr getLastPositionCommand() const; + + /** + * Print + */ + std::string print() const; private: - OncillaSynchronizer &synchronizer; + OncillaSynchronizer &synchronizer; }; } } diff --git a/src/OncillaL3.cpp b/src/OncillaL3.cpp index fd0adc2..a58bfbc 100644 --- a/src/OncillaL3.cpp +++ b/src/OncillaL3.cpp @@ -1,28 +1,30 @@ #include "OncillaL3.h" using namespace std; namespace rci { namespace oncilla { -OncillaL3::OncillaL3(const std::string & name) : - rci::ResourceNode(name), rci::Sensing(), rci::PositionSensing() { - this->_dimension = 1; +OncillaL3::OncillaL3(const std::string & name) + : rci::ResourceNode(name) + , rci::Sensing() + , rci::PositionSensing() { + this->_dimension = 1; } JointAnglesPtr OncillaL3::getJointPosition() const { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } OncillaL3::~OncillaL3() { } std::string OncillaL3::print() const { - ostringstream outstream(ostringstream::out); - outstream.precision(3); // Precision when printing double values - outstream << "<Oncilla Ankle>" << endl; - return outstream.str(); + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "<Oncilla Ankle>" << endl; + return outstream.str(); } } } diff --git a/src/OncillaL3.h b/src/OncillaL3.h index caaf629..be10b07 100644 --- a/src/OncillaL3.h +++ b/src/OncillaL3.h @@ -1,45 +1,45 @@ #pragma once #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/ResourceNode.h> #include <rci/Controlled.h> #include <rci/Configurable.h> #include <rci/Sensing.h> #include <rci/dto/JointAngles.h> namespace rci { namespace oncilla { class OncillaL3; typedef boost::shared_ptr<OncillaL3> OncillaL3Ptr; /** * Node class, representing the foot/ankle of the quadruped robot. Not actuated, * but force sensing. */ class OncillaL3: public rci::ResourceNode, - public rci::Sensing, - public rci::PositionSensing { + public rci::Sensing, + public rci::PositionSensing { public: - OncillaL3(const std::string & name = "Oncilla Ankle"); + OncillaL3(const std::string & name = "Oncilla Ankle"); - virtual ~OncillaL3(); + virtual ~OncillaL3(); - /** - * Returns contact forces - */ - JointAnglesPtr getJointPosition() const; + /** + * Returns contact forces + */ + JointAnglesPtr getJointPosition() const; - /** - * Print - */ - std::string print() const; + /** + * Print + */ + std::string print() const; }; } } diff --git a/src/OncillaL4.cpp b/src/OncillaL4.cpp index 6383dca..ec8e822 100644 --- a/src/OncillaL4.cpp +++ b/src/OncillaL4.cpp @@ -1,28 +1,30 @@ #include "OncillaL4.h" using namespace std; namespace rci { namespace oncilla { -OncillaL4::OncillaL4(const std::string & name) : - rci::ResourceNode(name), rci::Sensing(), rci::ForceSensing() { - this->_dimension = 1; +OncillaL4::OncillaL4(const std::string & name) + : rci::ResourceNode(name) + , rci::Sensing() + , rci::ForceSensing() { + this->_dimension = 1; } ForcesPtr OncillaL4::getForces() const { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } OncillaL4::~OncillaL4() { } std::string OncillaL4::print() const { - ostringstream outstream(ostringstream::out); - outstream.precision(3); // Precision when printing double values - outstream << "<Oncilla Foot>" << endl; - return outstream.str(); + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "<Oncilla Foot>" << endl; + return outstream.str(); } } } diff --git a/src/OncillaL4.h b/src/OncillaL4.h index 1b1ec24..3cb016b 100644 --- a/src/OncillaL4.h +++ b/src/OncillaL4.h @@ -1,45 +1,45 @@ #pragma once #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/ResourceNode.h> #include <rci/Controlled.h> #include <rci/Configurable.h> #include <rci/Sensing.h> #include <rci/dto/JointAngles.h> namespace rci { namespace oncilla { class OncillaL4; typedef boost::shared_ptr<OncillaL4> OncillaL4Ptr; /** * Node class, representing the foot of the quadruped robot. Not actuated, * but force sensing. */ class OncillaL4: public rci::ResourceNode, - public rci::Sensing, - public rci::ForceSensing { + public rci::Sensing, + public rci::ForceSensing { public: - OncillaL4(const std::string & name = "Oncilla Foot"); + OncillaL4(const std::string & name = "Oncilla Foot"); - virtual ~OncillaL4(); + virtual ~OncillaL4(); - /** - * Returns contact forces - */ - ForcesPtr getForces() const; + /** + * Returns contact forces + */ + ForcesPtr getForces() const; - /** - * Print - */ - std::string print() const; + /** + * Print + */ + std::string print() const; }; } } diff --git a/src/OncillaSynchronizer.h b/src/OncillaSynchronizer.h index 176588f..a24af44 100644 --- a/src/OncillaSynchronizer.h +++ b/src/OncillaSynchronizer.h @@ -1,87 +1,87 @@ #pragma once #include <vector> #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/Synchronizer.h> namespace rci { namespace oncilla { class OncillaSynchronizer; typedef boost::shared_ptr<OncillaSynchronizer> OncillaSynchronizerPtr; class OncillaTrunk; typedef boost::shared_ptr<OncillaTrunk> OncillaTrunkPtr; class OncillaL0; typedef boost::shared_ptr<OncillaL0> OncillaL0Ptr; class OncillaL1; typedef boost::shared_ptr<OncillaL1> OncillaL1Ptr; class OncillaL2; typedef boost::shared_ptr<OncillaL2> OncillaL2Ptr; class OncillaL3; typedef boost::shared_ptr<OncillaL3> OncillaL3Ptr; class OncillaL4; typedef boost::shared_ptr<OncillaL4> OncillaL4Ptr; /** * OncillaSynchronizer * Different OncillaSynchronizers may be for example: * * Update with a given frequency * ** Send data every time * ** Send only if new data * * Update only if new data (event-based) * * Triggered from robot side (e.g. FRI) */ class OncillaSynchronizer: public Synchronizer { public: - OncillaSynchronizer(const std::string &name); - virtual ~OncillaSynchronizer(); + OncillaSynchronizer(const std::string &name); + virtual ~OncillaSynchronizer(); - /** - * Registers a trunk node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerTrunkNode(unsigned int index, OncillaTrunkPtr node) = 0; + /** + * Registers a trunk node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerTrunkNode(unsigned int index, OncillaTrunkPtr node) = 0; - /** - * Registers an L0 node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerL0Node(unsigned int index, OncillaL0Ptr node) = 0; + /** + * Registers an L0 node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerL0Node(unsigned int index, OncillaL0Ptr node) = 0; - /** - * Registers an L1 node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerL1Node(unsigned int index, OncillaL1Ptr node) = 0; + /** + * Registers an L1 node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerL1Node(unsigned int index, OncillaL1Ptr node) = 0; - /** - * Registers an L2 node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerL2Node(unsigned int index, OncillaL2Ptr node) = 0; + /** + * Registers an L2 node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerL2Node(unsigned int index, OncillaL2Ptr node) = 0; - /** - * Registers an L3 node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerL3Node(unsigned int index, OncillaL3Ptr node) = 0; + /** + * Registers an L3 node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerL3Node(unsigned int index, OncillaL3Ptr node) = 0; - /** - * Registers an L4 node. - * @todo use Oncilla::Leg as index (problem with cyclic includes) - */ - virtual void registerL4Node(unsigned int index, OncillaL4Ptr node) = 0; + /** + * Registers an L4 node. + * @todo use Oncilla::Leg as index (problem with cyclic includes) + */ + virtual void registerL4Node(unsigned int index, OncillaL4Ptr node) = 0; - /** - * - */ - friend std::ostream - & operator<<(std::ostream& os, const OncillaSynchronizer& val); + /** + * + */ + friend std::ostream + & operator<<(std::ostream& os, const OncillaSynchronizer& val); }; } } diff --git a/src/OncillaTrunk.cpp b/src/OncillaTrunk.cpp index b8e46a5..7b84474 100644 --- a/src/OncillaTrunk.cpp +++ b/src/OncillaTrunk.cpp @@ -1,36 +1,38 @@ #include "OncillaTrunk.h" using namespace std; namespace rci { namespace oncilla { -OncillaTrunk::OncillaTrunk(const std::string & name) : - ResourceNode(name), Sensing(), PoseSensing() { - this->_dimension = 1; +OncillaTrunk::OncillaTrunk(const std::string & name) + : ResourceNode(name) + , Sensing() + , PoseSensing() { + this->_dimension = 1; } PosePtr OncillaTrunk::getAbsolutePose() const { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } PosePtr OncillaTrunk::getDisplacement() const { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } PosePtr OncillaTrunk::getAcceleration() const { - throw std::runtime_error("Not yet implemented."); + throw std::runtime_error("Not yet implemented."); } OncillaTrunk::~OncillaTrunk() { } std::string OncillaTrunk::print() const { - ostringstream outstream(ostringstream::out); - outstream.precision(3); // Precision when printing double values - outstream << "<Oncilla Trunk>" << endl; - return outstream.str(); + ostringstream outstream(ostringstream::out); + outstream.precision(3); // Precision when printing double values + outstream << "<Oncilla Trunk>" << endl; + return outstream.str(); } } } diff --git a/src/OncillaTrunk.h b/src/OncillaTrunk.h index 74540cc..510e07d 100644 --- a/src/OncillaTrunk.h +++ b/src/OncillaTrunk.h @@ -1,55 +1,55 @@ #pragma once #include <iostream> #include <boost/shared_ptr.hpp> #include <rci/ResourceNode.h> #include <rci/Controlled.h> #include <rci/Configurable.h> #include <rci/Sensing.h> namespace rci { namespace oncilla { class OncillaTrunk; typedef boost::shared_ptr<OncillaTrunk> OncillaTrunkPtr; /** * Node class, representing the quadruped trunk, including pose sensing. */ class OncillaTrunk: public rci::ResourceNode, - public Sensing, - public PoseSensing { + public Sensing, + public PoseSensing { public: - OncillaTrunk(const std::string & name = "Oncilla Trunk"); - virtual ~OncillaTrunk(); - - /** - * Returns current pose. - * @return Current pose - */ - virtual PosePtr getAbsolutePose() const; - - /** - * Returns current displacement. - * @return Current pose - */ - virtual PosePtr getDisplacement() const; - - /** - * Returns current translational and rotational acceleration. - * @return Current pose - */ - virtual PosePtr getAcceleration() const; - - /** - * Print - */ - std::string print() const; + OncillaTrunk(const std::string & name = "Oncilla Trunk"); + virtual ~OncillaTrunk(); + + /** + * Returns current pose. + * @return Current pose + */ + virtual PosePtr getAbsolutePose() const; + + /** + * Returns current displacement. + * @return Current pose + */ + virtual PosePtr getDisplacement() const; + + /** + * Returns current translational and rotational acceleration. + * @return Current pose + */ + virtual PosePtr getAcceleration() const; + + /** + * Print + */ + std::string print() const; }; } }