Skip to content

Commit

Permalink
Implement framework for the JointLimitceptor. #172.
Browse files Browse the repository at this point in the history
  • Loading branch information
benelot committed Nov 16, 2015
1 parent 3309c70 commit 3643ff6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
//# corresponding header
#include <model/universe/evolution/population/creature/phenome/morphology/effector/motor/SRBServoMotor.hpp>
#include <model/universe/evolution/population/creature/phenome/morphology/sensor/proprioceptor/JointLimitceptor.hpp>
#include <model/universe/evolution/population/creature/phenome/PhenomeModel.hpp>

//## view headers
//## utils headers

JointLimitceptor::JointLimitceptor(
std::vector<CONSTRAINT_TYPE*>::size_type jointIndex,
JointLimitceptor::JointLimitceptor() :
mLimitError(0), mLimit(JointLimitceptor::BOTH_LIMITS) {
}

JointLimitceptor::JointLimitceptor(JointModel* jointModel,
JointPhysics::RotationalDegreeOfFreedom rotationalDOF, Limit limit) :
JointProprioceptor(jointIndex, rotationalDOF), mLimitError(0), mLimit(limit) {
JointProprioceptor(jointModel, rotationalDOF), mLimitError(0), mLimit(
limit) {

}

JointLimitceptor::~JointLimitceptor() {

}

void JointLimitceptor::initialize() {
JointProprioceptor::initialize();
}

void JointLimitceptor::update(double timeSinceLastTick) {
// MOTOR_TYPE* motor = mG6DofJoint->getRotationalLimitMotor(mMotorIndex);
// switch (mLimit) {
Expand All @@ -37,5 +45,4 @@ void JointLimitceptor::update(double timeSinceLastTick) {
// setLimitError(motor->m_currentLimitError);
// break;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
#include <model/universe/evolution/population/creature/phenome/morphology/sensor/proprioceptor/JointProprioceptor.hpp>

//# forward declarations
class PhenomeModel;

//# system headers
//## controller headers
//## model headers
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>

//## view headers
//# custom headers
//## base headers
Expand All @@ -28,10 +33,14 @@ class JointLimitceptor: public JointProprioceptor {
enum Limit {
LOWER_LIMIT, UPPER_LIMIT, BOTH_LIMITS
};
JointLimitceptor(std::vector<CONSTRAINT_TYPE*>::size_type jointIndex,

JointLimitceptor();
JointLimitceptor(JointModel* jointModel,
JointPhysics::RotationalDegreeOfFreedom rotationalDOF, Limit limit);
virtual ~JointLimitceptor();

virtual void initialize();

virtual void update(double timeSinceLastTick);

//Accessor methods
Expand All @@ -44,9 +53,41 @@ class JointLimitceptor: public JointProprioceptor {
setOutputValue(limitError);
}

//Serialization
/**
* Give access to boost serialization
*/
friend class boost::serialization::access;

/**
* Serializes the joint limit proprioceptor to a string.
* @param os The ostream.
* @param jointLimitProprioceptor The joint limit proprioceptor we want to serialize.
* @return A string containing all information about the joint limit proprioceptor.
*/
friend std::ostream & operator<<(std::ostream &os,
const JointLimitceptor &jointProprioceptor) {
return os
/**The joint index*/
<< "JointAngleProprioceptor: Joint index="
// << jointProprioceptor.mJointIndex
/** The motor index*/
<< "/Motor index=" << jointProprioceptor.mMotorIndex;
}

/**
* Serializes the joint limit proprioceptor to an xml file.
* @param ar The archive.
* @param The file version.
*/
template<class Archive>
void serialize(Archive & ar, const unsigned int /* file_version */) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(JointProprioceptor); /**!< Serialize the base object */
}

private:
double mLimitError;
Limit mLimit;
};

BOOST_CLASS_VERSION(JointLimitceptor, 1)
#endif /* MODEL_UNIVERSE_EVOLUTION_POPULATION_CREATURE_PHENOME_MORPHOLOGY_SENSOR_PROPRIOCEPTOR_JOINTLIMITCEPTOR_HPP_ */

0 comments on commit 3643ff6

Please sign in to comment.