[Opal-commits] opal/src AttractorMotor.cpp,1.16,1.17 AttractorMotor.h,1.23,1.24 AttractorMotorData.h
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27565/src Modified Files: AttractorMotor.cpp AttractorMotor.h AttractorMotorData.h Blueprint.cpp Blueprint.h BlueprintInstance.cpp BlueprintInstance.h BlueprintManager.cpp BlueprintManager.h Defines.h GearedMotor.cpp GearedMotor.h GearedMotorData.h Joint.cpp Joint.h JointData.h Logger.cpp Logger.h SConscript ServoMotor.cpp ServoMotor.h ServoMotorData.h Simulator.cpp Solid.cpp Solid.h SpringMotor.cpp SpringMotor.h SpringMotorData.h ThrusterMotor.cpp ThrusterMotor.h ThrusterMotorData.h opal.h Log Message: finished overhauling xml loader Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** opal.h 25 Feb 2005 06:40:26 -0000 1.17 --- opal.h 26 Feb 2005 10:22:23 -0000 1.18 *************** *** 43,49 **** #include "AttractorMotor.h" #include "AttractorMotorData.h" #include "ServoMotor.h" #include "ThrusterMotor.h" ! #include "GearedMotor.h" #include "Joint.h" #include "JointData.h" --- 43,54 ---- #include "AttractorMotor.h" #include "AttractorMotorData.h" + #include "GearedMotor.h" + #include "GearedMotorData.h" #include "ServoMotor.h" + #include "ServoMotorData.h" #include "ThrusterMotor.h" ! #include "ThrusterMotorData.h" ! #include "SpringMotor.h" ! #include "SpringMotorData.h" #include "Joint.h" #include "JointData.h" *************** *** 52,55 **** --- 57,61 ---- #include "EventHandler.h" #include "Blueprint.h" + #include "BlueprintInstance.h" #include "BlueprintManager.h" #include "Defines.h" *************** *** 63,69 **** OPAL_EXPORT void OPAL_CALL loadFile(Blueprint& bp, const std::string& filename); - { - BlueprintManager::instance().loadFile(bp, filename); - } /// Saves a Blueprint in an OPAL XML file. --- 69,72 ---- Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SConscript 25 Feb 2005 06:40:26 -0000 1.10 --- SConscript 26 Feb 2005 10:22:23 -0000 1.11 *************** *** 7,10 **** --- 7,11 ---- AttractorMotorData.h Blueprint.h + BlueprintInstance.h BlueprintManager.h BoxShapeData.h *************** *** 51,54 **** --- 52,56 ---- AttractorMotor.cpp Blueprint.cpp + BlueprintInstance.cpp BlueprintManager.cpp GearedMotor.cpp Index: Logger.h =================================================================== RCS file: /cvsroot/opal/opal/src/Logger.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Logger.h 25 Feb 2005 06:40:26 -0000 1.1 --- Logger.h 26 Feb 2005 10:22:23 -0000 1.2 *************** *** 1,2 **** --- 1,29 ---- + /************************************************************************* + * * + * Open Physics Abstraction Layer * + * Copyright (C) 2004-2005 * + * Alan Fischer ala...@gm... * + * Andres Reinot an...@re... * + * Tyler Streeter tyl...@gm... * + * All rights reserved. * + * Web: opal.sourceforge.net * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file license-LGPL.txt. * + * (2) The BSD-style license that is included with this library in * + * the file license-BSD.txt. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * license-LGPL.txt and license-BSD.txt for more details. * + * * + *************************************************************************/ + #ifndef OPAL_LOGGER_H #define OPAL_LOGGER_H *************** *** 11,54 **** #include <stdexcept> namespace opal { ! /// This class is used to log any events, errors, or warnings that may ! /// come up. Calls to this class should replace all cout << statements ! /// in the form: Logger::stream("myStreamName") << ... ! /// where myStreamName was registered as a cout stream or file stream ! /// using the setStream function. ! class Logger { ! public: ! Logger(); ! ~Logger(); ! /// Register a new stream for later use. ! static void setStream(const std::string& name, std::ostream *stream, ! const std::string& prefix="", char mark='\0'); ! //static void silenceStream(const std::string& name); ! //static void unsilenceStream(const std::string& name); ! static std::ostream &stream(const std::string& name); ! private: ! struct Stream ! { ! std::ostream *nullStream; ! std::ostream *stream; ! bool silent; ! char mark; ! std::string prefix; ! }; ! static void init(); ! //static bool mInitCalled; ! static std::map<std::string, Stream> mStreams; ! }; } #endif - --- 38,89 ---- #include <stdexcept> + #include "defines.h" + #include "Singleton.h" + + #define OPAL_LOGGER Logger::instance().stream + namespace opal { ! namespace logger { ! /// This class is used to log any events, errors, or warnings that may ! /// come up. Calls to this class should replace all cout << statements ! /// in the form: Logger::stream("myStreamName") << ... ! /// where myStreamName was registered as a cout stream or file stream ! /// using the setStream function. ! class Logger ! { ! public: ! Logger(); ! ~Logger(); ! /// Register a new stream for later use. ! void OPAL_CALL setStream(const std::string& name, ! std::ostream *stream, const std::string& prefix="", ! char mark='\0'); ! //static void silenceStream(const std::string& name); ! //static void unsilenceStream(const std::string& name); ! std::ostream& OPAL_CALL stream(const std::string& name); ! private: ! struct Stream ! { ! std::ostream *nullStream; ! std::ostream *stream; ! bool silent; ! char mark; ! std::string prefix; ! }; ! void init(); ! std::map<std::string, Stream> mStreams; ! }; ! } ! typedef Singleton<logger::Logger> Logger; } #endif Index: Blueprint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Blueprint.cpp 25 Feb 2005 16:43:19 -0000 1.15 --- Blueprint.cpp 26 Feb 2005 10:22:23 -0000 1.16 *************** *** 41,44 **** --- 41,45 ---- Blueprint::Blueprint() { + mFinalized = false; } *************** *** 70,80 **** } void Blueprint::addSolid(SolidData* data) { if (solidExists(data->name)) { ! Logger::stream("warning") << "opal::Blueprint::addSolid: Solid " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else --- 71,235 ---- } + void Blueprint::finalize() + { + // Setup Joint reference indices. + for (size_t i=0; i<mJointList.size();) + { + JointData* data = mJointList.at(i); + + // Find the indices of the references. + int solid0Index = getSolidIndex(data->internal_solid0Name); + int solid1Index = getSolidIndex(data->internal_solid1Name); + + if (-1 == solid0Index || -1 == solid1Index) + { + OPAL_LOGGER("warning") << + "opal::Blueprint::finalize: Invalid reference \ + in Joint " << data->name << ". Removing the Joint from the Blueprint." + << std::endl; + + delete data; + mJointList.at(i) = mJointList.back(); + mJointList.pop_back(); + } + else + { + data->internal_solid0Index = solid0Index; + data->internal_solid1Index = solid1Index; + ++i; + } + } + + // Setup Motor reference indices. + for (size_t i=0; i<mMotorList.size();) + { + MotorData* m = mMotorList.at(i); + bool error = false; + + switch(m->getType()) + { + case ATTRACTOR_MOTOR: + { + AttractorMotorData* data = + (AttractorMotorData*)mMotorList.at(i); + int solid0Index = + getSolidIndex(data->internal_solid0Name); + int solid1Index = + getSolidIndex(data->internal_solid1Name); + if (-1 == solid0Index || -1 == solid1Index) + { + error = true; + } + else + { + data->internal_solid0Index = solid0Index; + data->internal_solid1Index = solid1Index; + } + break; + } + case GEARED_MOTOR: + { + GearedMotorData* data = + (GearedMotorData*)mMotorList.at(i); + int jointIndex = getJointIndex(data->internal_jointName); + if (-1 == jointIndex) + { + error = true; + } + else + { + data->internal_jointIndex = jointIndex; + } + break; + } + case SERVO_MOTOR: + { + ServoMotorData* data = (ServoMotorData*)mMotorList.at(i); + int jointIndex = getJointIndex(data->internal_jointName); + if (-1 == jointIndex) + { + error = true; + } + else + { + data->internal_jointIndex = jointIndex; + } + break; + } + case SPRING_MOTOR: + { + SpringMotorData* data = + (SpringMotorData*)mMotorList.at(i); + int solidIndex = getSolidIndex(data->internal_solidName); + if (-1 == solidIndex) + { + error = true; + } + else + { + data->internal_solidIndex = solidIndex; + } + break; + } + case THRUSTER_MOTOR: + { + ThrusterMotorData* data = + (ThrusterMotorData*)mMotorList.at(i); + int solidIndex = getSolidIndex(data->internal_solidName); + if (-1 == solidIndex) + { + error = true; + } + else + { + data->internal_solidIndex = solidIndex; + } + break; + } + default: + assert(false); + } + + if (error) + { + OPAL_LOGGER("warning") << + "opal::Blueprint::finalize: Invalid reference in Motor " + << mMotorList.at(i)->name + << ". Removing the Motor from the Blueprint." + << std::endl; + + delete mMotorList.at(i); + mMotorList.at(i) = mMotorList.back(); + mMotorList.pop_back(); + } + else + { + ++i; + } + } + + // TODO: once we have Sensors, loop over them here. + + mFinalized = true; + } + + bool Blueprint::isFinalized()const + { + return mFinalized; + } + void Blueprint::addSolid(SolidData* data) { + if (mFinalized) + { + printFinalizedMessage(); + return; + } + if (solidExists(data->name)) { ! OPAL_LOGGER("warning") << "opal::Blueprint::addSolid: Solid " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else *************** *** 87,95 **** void Blueprint::addJoint(JointData* data) { if (jointExists(data->name)) { ! Logger::stream("warning") << "opal::Blueprint::addJoint: Joint " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else --- 242,256 ---- void Blueprint::addJoint(JointData* data) { + if (mFinalized) + { + printFinalizedMessage(); + return; + } + if (jointExists(data->name)) { ! OPAL_LOGGER("warning") << "opal::Blueprint::addJoint: Joint " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else *************** *** 102,110 **** void Blueprint::addMotor(MotorData* data) { if (motorExists(data->name)) { ! Logger::stream("warning") << "opal::Blueprint::addMotor: Motor " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else --- 263,277 ---- void Blueprint::addMotor(MotorData* data) { + if (mFinalized) + { + printFinalizedMessage(); + return; + } + if (motorExists(data->name)) { ! OPAL_LOGGER("warning") << "opal::Blueprint::addMotor: Motor " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else *************** *** 145,153 **** void Blueprint::addSensor(SensorData* data) { if (sensorExists(data->name)) { ! Logger::stream("warning") << "opal::Blueprint::addSensor: Sensor " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else --- 312,326 ---- void Blueprint::addSensor(SensorData* data) { + if (mFinalized) + { + printFinalizedMessage(); + return; + } + if (sensorExists(data->name)) { ! OPAL_LOGGER("warning") << "opal::Blueprint::addSensor: Sensor " << data->name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; } else *************** *** 291,295 **** } ! int Blueprint::internal_getSolidIndex(const std::string& name)const { if (name.empty()) --- 464,468 ---- } ! int Blueprint::getSolidIndex(const std::string& name)const { if (name.empty()) *************** *** 308,310 **** --- 481,507 ---- return -1; } + + int Blueprint::getJointIndex(const std::string& name)const + { + if (name.empty()) + { + return -1; + } + + for (unsigned int i=0; i<mJointList.size(); ++i) + { + if (mJointList[i]->name == name) + { + return (int)i; + } + } + + return -1; + } + + void Blueprint::printFinalizedMessage() + { + OPAL_LOGGER("warning") << "Cannot add objects to a finalized \ + Blueprint. The operation will be ignored." << std::endl; + } } Index: ServoMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ServoMotor.cpp 25 Feb 2005 06:40:26 -0000 1.11 --- ServoMotor.cpp 26 Feb 2005 10:22:23 -0000 1.12 *************** *** 72,78 **** --- 72,80 ---- } + assert(data.joint); assert(data.jointAxisNum >= 0 && data.jointAxisNum < data.joint->getNumAxes()); Motor::init(); + assert(data.joint->isRotational(data.jointAxisNum)); mData = data; } *************** *** 113,123 **** mData.joint->internal_setDesiredVel(mData.jointAxisNum, mData.desiredVel); ! mData.joint->internal_setMaxForce(mData.jointAxisNum, ! mData.maxForce); } else { mData.joint->internal_setDesiredVel(mData.jointAxisNum, 0); ! mData.joint->internal_setMaxForce(mData.jointAxisNum, 0); } } --- 115,125 ---- mData.joint->internal_setDesiredVel(mData.jointAxisNum, mData.desiredVel); ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, ! mData.maxTorque); } else { mData.joint->internal_setDesiredVel(mData.jointAxisNum, 0); ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, 0); } } *************** *** 131,151 **** mData.joint->wakeSolids(); ! if (DESIRED_POS_MODE == mData.mode) { ! if (true == mData.joint->isRotational(mData.jointAxisNum)) ! { ! real velocity = mData.desiredPos - ! mData.joint->getState(mData.jointAxisNum); ! mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! mData.restoreSpeed * velocity); ! } ! else ! { ! // This axis must be a linear degree of freedom. ! real velocity = mData.desiredPos - ! mData.joint->getState(mData.jointAxisNum); mData.joint->internal_setDesiredVel(mData.jointAxisNum, mData.restoreSpeed * velocity); ! } } else --- 133,154 ---- mData.joint->wakeSolids(); ! if (DESIRED_ANGLE_MODE == mData.mode) { ! // No longer support linear degrees of freedom. ! //if (true == mData.joint->isRotational(mData.jointAxisNum)) ! //{ ! real velocity = mData.desiredAngle - ! mData.joint->getAngle(mData.jointAxisNum); mData.joint->internal_setDesiredVel(mData.jointAxisNum, mData.restoreSpeed * velocity); ! //} ! //else ! //{ ! // // This axis must be a linear degree of freedom. ! // real velocity = mData.desiredPos - ! // mData.joint->getState(mData.jointAxisNum); ! // mData.joint->internal_setDesiredVel(mData.jointAxisNum, ! // mData.restoreSpeed * velocity); ! //} } else *************** *** 157,171 **** } ! void ServoMotor::setDesiredPos(real pos) { ! assert(pos >= mData.joint->getLowLimit(mData.jointAxisNum) ! && pos <= mData.joint->getHighLimit(mData.jointAxisNum)); ! mData.desiredPos = pos; } ! void ServoMotor::setDesiredPosNorm(real pos) { ! assert(pos >= 0.0 && pos <= 1.0); real lowLimit = mData.joint->getLowLimit(mData.jointAxisNum); --- 160,174 ---- } ! void ServoMotor::setDesiredAngle(real a) { ! assert(a >= mData.joint->getLowLimit(mData.jointAxisNum) ! && a <= mData.joint->getHighLimit(mData.jointAxisNum)); ! mData.desiredAngle = a; } ! void ServoMotor::setDesiredAngleNorm(real a) { ! assert(a >= 0.0 && a <= 1.0); real lowLimit = mData.joint->getLowLimit(mData.jointAxisNum); *************** *** 173,187 **** // map the pos value onto the joint limits ! mData.desiredPos = pos * (highLimit - lowLimit) + lowLimit; // Keep desired angle slightly away from the limit to avoid jitter. // TODO: fix this; this should just keep the thing away from the // limit when it's close, not all the time. ! mData.desiredPos *= (real)0.99; } ! real ServoMotor::getDesiredPos()const { ! return mData.desiredPos; } --- 176,190 ---- // map the pos value onto the joint limits ! mData.desiredAngle = a * (highLimit - lowLimit) + lowLimit; // Keep desired angle slightly away from the limit to avoid jitter. // TODO: fix this; this should just keep the thing away from the // limit when it's close, not all the time. ! mData.desiredAngle *= (real)0.99; } ! real ServoMotor::getDesiredAngle()const { ! return mData.desiredAngle; } *************** *** 197,209 **** } ! void ServoMotor::setMaxForce(real max) { ! mData.maxForce = max; ! mData.joint->internal_setMaxForce(mData.jointAxisNum, max); } ! real ServoMotor::getMaxForce()const { ! return mData.maxForce; } --- 200,212 ---- } ! void ServoMotor::setMaxTorque(real max) { ! mData.maxTorque = max; ! mData.joint->internal_setMaxTorque(mData.jointAxisNum, max); } ! real ServoMotor::getMaxTorque()const { ! return mData.maxTorque; } Index: GearedMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GearedMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 --- GearedMotorData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 43,46 **** --- 43,48 ---- mType = GEARED_MOTOR; joint = NULL; + internal_jointIndex = 0; + internal_jointName = ""; jointAxisNum = 0; maxTorque = defaults::motor::geared::maxTorque; *************** *** 66,69 **** --- 68,73 ---- name = data.name; joint = data.joint; + internal_jointIndex = data.internal_jointIndex; + internal_jointName = data.internal_jointName; jointAxisNum = data.jointAxisNum; maxTorque = data.maxTorque; *************** *** 75,78 **** --- 79,88 ---- Joint* joint; + /// Internal data used for Blueprint instantiation. + int internal_jointIndex; + + /// Internal data used for Blueprint instantiation. + std::string internal_jointName; + /// The index of the specific Joint axis affected by this Motor. int jointAxisNum; *************** *** 82,86 **** real maxTorque; ! /// The maximum velocity that can be achieved by the Motor. real maxVelocity; --- 92,96 ---- real maxTorque; ! /// The maximum angular velocity that can be achieved by the Motor. real maxVelocity; Index: BlueprintManager.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** BlueprintManager.h 25 Feb 2005 16:43:20 -0000 1.16 --- BlueprintManager.h 26 Feb 2005 10:22:23 -0000 1.17 *************** *** 37,41 **** namespace opal { ! namespace impl { class BlueprintManager --- 37,47 ---- namespace opal { ! class AttractorMotorData; ! class GearedMotorData; ! class ServoMotorData; ! class SpringMotorData; ! class ThrusterMotorData; ! ! namespace blueprint_manager { class BlueprintManager *************** *** 52,57 **** /// object parameters are optional, in which case the usual, /// default values will be used. The only required ! /// parameters are references to other objects (i.e. the ! /// "References" elements in an XML file. For example, /// a Joint refers to two Solids; if either of those Solids /// are not in the file, the Joint will be ignored. For a --- 58,63 ---- /// object parameters are optional, in which case the usual, /// default values will be used. The only required ! /// parameters are object types and references to other objects ! /// (i.e. the "References" elements in an XML file. For example, /// a Joint refers to two Solids; if either of those Solids /// are not in the file, the Joint will be ignored. For a *************** *** 84,87 **** --- 90,123 ---- const Blueprint& bp, const std::string& filename); + /// Helper function for parsing AttractorMotor XML elements. + /// Allocates and returns a pointer to a new AttractorMotorData + /// object. Returns NULL if the element could not be loaded. + AttractorMotorData* loadAttractorMotor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + + /// Helper function for parsing GearedMotor XML elements. + /// Allocates and returns a pointer to a new GearedMotorData + /// object. Returns NULL if the element could not be loaded. + GearedMotorData* loadGearedMotor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + + /// Helper function for parsing ServoMotor XML elements. + /// Allocates and returns a pointer to a new ServoMotorData + /// object. Returns NULL if the element could not be loaded. + ServoMotorData* loadServoMotor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + + /// Helper function for parsing SpringMotor XML elements. + /// Allocates and returns a pointer to a new SpringMotorData + /// object. Returns NULL if the element could not be loaded. + SpringMotorData* loadSpringMotor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + + /// Helper function for parsing ThrusterMotor XML elements. + /// Allocates and returns a pointer to a new ThrusterMotorData + /// object. Returns NULL if the element could not be loaded. + ThrusterMotorData* loadThrusterMotor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + /// Helper function for parsing Sensor XML elements. Allocates /// and returns a pointer to a new SensorData object. Returns *************** *** 111,115 **** }; } ! typedef Singleton<impl::BlueprintManager> BlueprintManager; } --- 147,151 ---- }; } ! typedef Singleton<blueprint_manager::BlueprintManager> BlueprintManager; } Index: BlueprintInstance.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintInstance.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BlueprintInstance.h 25 Feb 2005 06:40:26 -0000 1.1 --- BlueprintInstance.h 26 Feb 2005 10:22:23 -0000 1.2 *************** *** 45,113 **** { public: ! BlueprintInstance(); ! virtual ~BlueprintInstance(); /// Finds a Solid by name and returns its pointer. Returns NULL if /// the name is not found. ! virtual Solid* OPAL_CALL getSolid(const std::string& name)const; /// Finds a Joint by name and returns its pointer. Returns NULL if /// the name is not found. ! virtual Joint* OPAL_CALL getJoint(const std::string& name)const; /// Finds a Motor by name and returns its pointer. Returns NULL if /// the name is not found. ! virtual Motor* OPAL_CALL getMotor(const std::string& name)const; /// Finds a Sensor by name and returns its pointer. Returns NULL if /// the name is not found. ! virtual Sensor* OPAL_CALL getSensor(const std::string& name)const; /// Adds a new Solid pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! virtual void OPAL_CALL internal_addSolidPtr(Solid* s); /// Adds a new Joint pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! virtual void OPAL_CALL internal_addJoint(Joint* j); /// Adds a new Motor pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! virtual void OPAL_CALL internal_addMotor(Motor* m); /// Adds a new Sensor pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! virtual void OPAL_CALL internal_addSensor(Sensor* s); private: ! ///// Helper function that returns true if a Solid of the given ! ///// name already exists in the Blueprint. Ignores empty name ! ///// strings. ! //bool solidExists(const std::string& name); ! ! ///// Helper function that returns true if a Joint of the given ! ///// name already exists in the Blueprint. Ignores empty name ! ///// strings. ! //bool jointExists(const std::string& name); ! ! ///// Helper function that returns true if a Motor of the given ! ///// name already exists in the Blueprint. Ignores empty name ! ///// strings. ! //bool motorExists(const std::string& name); ! ! ///// Helper function that returns true if a Sensor of the given ! ///// name already exists in the Blueprint. Ignores empty name ! ///// strings. ! //bool sensorExists(const std::string& name); ! ! //std::vector<SolidData*> mSolidList; ! //std::vector<JointData*> mJointList; ! //std::vector<MotorData*> mMotorList; ! //std::vector<SensorData*> mSensorList; ! std::map<std::string, Solid*> mSolidMap; std::map<std::string, Joint*> mJointMap; std::map<std::string, Motor*> mMotorMap; std::map<std::string, Sensor*> mSensorMap; }; --- 45,99 ---- { public: ! OPAL_DECL BlueprintInstance(); ! OPAL_DECL virtual ~BlueprintInstance(); /// Finds a Solid by name and returns its pointer. Returns NULL if /// the name is not found. ! OPAL_DECL virtual Solid* OPAL_CALL getSolid( ! const std::string& name)const; /// Finds a Joint by name and returns its pointer. Returns NULL if /// the name is not found. ! OPAL_DECL virtual Joint* OPAL_CALL getJoint( ! const std::string& name)const; /// Finds a Motor by name and returns its pointer. Returns NULL if /// the name is not found. ! OPAL_DECL virtual Motor* OPAL_CALL getMotor( ! const std::string& name)const; /// Finds a Sensor by name and returns its pointer. Returns NULL if /// the name is not found. ! OPAL_DECL virtual Sensor* OPAL_CALL getSensor( ! const std::string& name)const; /// Adds a new Solid pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! OPAL_DECL virtual void OPAL_CALL internal_addSolid(Solid* s); /// Adds a new Joint pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! OPAL_DECL virtual void OPAL_CALL internal_addJoint(Joint* j); /// Adds a new Motor pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! OPAL_DECL virtual void OPAL_CALL internal_addMotor(Motor* m); /// Adds a new Sensor pointer. If the pointer is NULL or the /// object's name is an empty string, this will do nothing. ! OPAL_DECL virtual void OPAL_CALL internal_addSensor(Sensor* s); private: ! /// Map of Solid names to Solid pointers. std::map<std::string, Solid*> mSolidMap; + + /// Map of Joint names to Joint pointers. std::map<std::string, Joint*> mJointMap; + + /// Map of Motor names to Motor pointers. std::map<std::string, Motor*> mMotorMap; + + /// Map of Sensor names to Sensor pointers. std::map<std::string, Sensor*> mSensorMap; }; Index: ServoMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ServoMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 --- ServoMotorData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 37,43 **** enum ServoMotorMode { ! /// The ServoMotor tries to achieve a desired position for /// the Joint axis. ! DESIRED_POS_MODE, /// The ServoMotor tries to achieve a desired velocity for --- 37,43 ---- enum ServoMotorMode { ! /// The ServoMotor tries to achieve a desired angle for /// the Joint axis. ! DESIRED_ANGLE_MODE, /// The ServoMotor tries to achieve a desired velocity for *************** *** 55,63 **** mType = SERVO_MOTOR; joint = NULL; ! mode = DESIRED_POS_MODE; jointAxisNum = 0; ! desiredPos = 0; desiredVel = 0; ! maxForce = defaults::motor::servo::maxForce; restoreSpeed = defaults::motor::servo::restoreSpeed; } --- 55,65 ---- mType = SERVO_MOTOR; joint = NULL; ! internal_jointIndex = 0; ! internal_jointName = ""; ! mode = DESIRED_ANGLE_MODE; jointAxisNum = 0; ! desiredAngle = 0; desiredVel = 0; ! maxTorque = defaults::motor::servo::maxTorque; restoreSpeed = defaults::motor::servo::restoreSpeed; } *************** *** 80,88 **** name = data.name; joint = data.joint; mode = data.mode; jointAxisNum = data.jointAxisNum; ! desiredPos = data.desiredPos; desiredVel = data.desiredVel; ! maxForce = data.maxForce; restoreSpeed = data.restoreSpeed; } --- 82,92 ---- name = data.name; joint = data.joint; + internal_jointIndex = data.internal_jointIndex; + internal_jointName = data.internal_jointName; mode = data.mode; jointAxisNum = data.jointAxisNum; ! desiredAngle = data.desiredAngle; desiredVel = data.desiredVel; ! maxTorque = data.maxTorque; restoreSpeed = data.restoreSpeed; } *************** *** 91,94 **** --- 95,104 ---- Joint* joint; + /// Internal data used for Blueprint instantiation. + int internal_jointIndex; + + /// Internal data used for Blueprint instantiation. + std::string internal_jointName; + /// The Motor's mode of operation. ServoMotorMode mode; *************** *** 97,114 **** int jointAxisNum; ! /// The Motor's desired position. This is only used if the /// appropriate mode is set. ! real desiredPos; ! ! /// The Motor's desired position. This is only used if the /// appropriate mode is set. real desiredVel; ! /// The maximum amount of force that can be used to help the ! /// Joint axis achieve its desired position or velocity. ! real maxForce; ! /// A constant used in desired position mode that scaled how fast ! /// the Joint axis will achieve its desired position. real restoreSpeed; --- 107,124 ---- int jointAxisNum; ! /// The Motor's desired angle. This is only used if the /// appropriate mode is set. ! real desiredAngle; ! ! /// The Motor's desired velocity. This is only used if the /// appropriate mode is set. real desiredVel; ! /// The maximum amount of torque that can be used to help the ! /// Joint axis achieve its desired angle or velocity. ! real maxTorque; ! /// A constant used in desired angle mode that scales how fast ! /// the Joint axis will achieve its desired angle. real restoreSpeed; Index: SpringMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SpringMotor.h 25 Feb 2005 06:40:26 -0000 1.7 --- SpringMotor.h 26 Feb 2005 10:22:23 -0000 1.8 *************** *** 52,56 **** //virtual void OPAL_CALL init(Mode m, Solid* s); ! /// Initializes the Motor with the given data structure. virtual void OPAL_CALL init(const SpringMotorData& data); --- 52,57 ---- //virtual void OPAL_CALL init(Mode m, Solid* s); ! /// Initializes the Motor with the given data structure. Solid ! /// pointer in the data must be valid. virtual void OPAL_CALL init(const SpringMotorData& data); Index: ThrusterMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ThrusterMotor.h 25 Feb 2005 06:40:26 -0000 1.7 --- ThrusterMotor.h 26 Feb 2005 10:22:23 -0000 1.8 *************** *** 51,55 **** //virtual void OPAL_CALL init(Solid* solid); ! /// Initializes the Motor with the given data structure. virtual void OPAL_CALL init(const ThrusterMotorData& data); --- 51,56 ---- //virtual void OPAL_CALL init(Solid* solid); ! /// Initializes the Motor with the given data structure. Solid ! /// pointer in the data must be valid. virtual void OPAL_CALL init(const ThrusterMotorData& data); Index: BlueprintInstance.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintInstance.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BlueprintInstance.cpp 25 Feb 2005 06:40:26 -0000 1.1 --- BlueprintInstance.cpp 26 Feb 2005 10:22:23 -0000 1.2 *************** *** 102,106 **** } ! void BlueprintInstance::internal_addSolidPtr(Solid* s) { if (NULL == s) --- 102,106 ---- } ! void BlueprintInstance::internal_addSolid(Solid* s) { if (NULL == s) *************** *** 169,329 **** mSensorMap[name] = s; } - - //void Blueprint::addSolid(const SolidData& data) - //{ - // if (solidExists(data.name)) - // { - // Logger::stream("warning") << "opal::Blueprint::addSolid: Solid " - // << data.name << " already exists in this Blueprint. \ - // Ignoring the new one." << std::endl; - // } - // else - // { - // SolidData* newData = new SolidData(data); - // mSolidList.push_back(newData); - // } - //} - - //void Blueprint::addJoint(const JointData& data) - //{ - // if (jointExists(data.name)) - // { - // Logger::stream("warning") << "opal::Blueprint::addJoint: Joint " - // << data.name << " already exists in this Blueprint. \ - // Ignoring the new one." << std::endl; - // } - // else - // { - // JointData* newData = new JointData(data); - // mJointList.push_back(newData); - // } - //} - - //void Blueprint::addMotor(const MotorData& data) - //{ - // if (motorExists(data.name)) - // { - // Logger::stream("warning") << "opal::Blueprint::addMotor: Motor " - // << data.name << " already exists in this Blueprint. \ - // Ignoring the new one." << std::endl; - // } - // else - // { - // MotorData* newData = new MotorData(data); - // mMotorList.push_back(newData); - // } - //} - - //void Blueprint::addSensor(const SensorData& data) - //{ - // if (sensorExists(data.name)) - // { - // Logger::stream("warning") << "opal::Blueprint::addSensor: Sensor " - // << data.name << " already exists in this Blueprint. \ - // Ignoring the new one." << std::endl; - // } - // else - // { - // SensorData* newData = new SensorData(data); - // mSensorList.push_back(newData); - // } - //} - - //bool Blueprint::solidExists(const std::string& name) - //{ - // /// Ignore empty name strings. - // if (name.empty()) - // { - // return false; - // } - - // std::vector<SolidData*>::iterator iter; - // for (iter = mSolidList.begin(); iter != mSolidList.end(); ++iter) - // { - // if ((*iter)->name == name) - // { - // return true; - // } - // } - - // return false; - //} - - //bool Blueprint::jointExists(const std::string& name) - //{ - // /// Ignore empty name strings. - // if (name.empty()) - // { - // return false; - // } - - // std::vector<JointData*>::iterator iter; - // for (iter = mJointList.begin(); iter != mJointList.end(); ++iter) - // { - // if ((*iter)->name == name) - // { - // return true; - // } - // } - - // return false; - //} - - //bool Blueprint::motorExists(const std::string& name) - //{ - // /// Ignore empty name strings. - // if (name.empty()) - // { - // return false; - // } - - // std::vector<MotorData*>::iterator iter; - // for (iter = mMotorList.begin(); iter != mMotorList.end(); ++iter) - // { - // if ((*iter)->name == name) - // { - // return true; - // } - // } - - // return false; - //} - - //bool Blueprint::sensorExists(const std::string& name) - //{ - // /// Ignore empty name strings. - // if (name.empty()) - // { - // return false; - // } - - // std::vector<SensorData*>::iterator iter; - // for (iter = mSensorList.begin(); iter != mSensorList.end(); ++iter) - // { - // if ((*iter)->name == name) - // { - // return true; - // } - // } - - // return false; - //} - - //int Blueprint::internal_getSolidIndex(const std::string& name)const - //{ - // if (name.empty()) - // { - // return -1; - // } - - // for (unsigned int i=0; i<mSolidList.size(); ++i) - // { - // if (mSolidList[i]->name == name) - // { - // return (int)i; - // } - // } - - // return -1; - //} } --- 169,171 ---- Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Solid.h 25 Feb 2005 06:40:26 -0000 1.77 --- Solid.h 26 Feb 2005 10:22:23 -0000 1.78 *************** *** 256,260 **** /// Returns true if this is a static Solid. ! virtual bool OPAL_CALL isStatic(); /// Sets whether the Solid should be static or dynamic. --- 256,260 ---- /// Returns true if this is a static Solid. ! virtual bool OPAL_CALL isStatic()const; /// Sets whether the Solid should be static or dynamic. Index: GearedMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GearedMotor.cpp 25 Feb 2005 06:40:26 -0000 1.7 --- GearedMotor.cpp 26 Feb 2005 10:22:23 -0000 1.8 *************** *** 51,54 **** --- 51,55 ---- void GearedMotor::init(const GearedMotorData& data) { + assert(data.joint); Motor::init(); assert(data.joint->isRotational(data.jointAxisNum)); Index: ServoMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ServoMotor.h 25 Feb 2005 06:40:26 -0000 1.21 --- ServoMotor.h 26 Feb 2005 10:22:23 -0000 1.22 *************** *** 37,45 **** { /// This is a Motor with an internal feedback loop, allowing ! /// precise positioning control with minimal overshooting. It /// controls a single Joint axis. Depending on the desired mode of ! /// operation, it tries to achieve a desired position or velocity ! /// using up to a set maximum force. The Joint axis can be either ! /// linear or rotational. class ServoMotor : public Motor { --- 37,45 ---- { /// This is a Motor with an internal feedback loop, allowing ! /// precise positioning control with minimal overshooting. This ! /// Motor only works on rotational Joint axes. It /// controls a single Joint axis. Depending on the desired mode of ! /// operation, it tries to achieve a desired angle or angular velocity ! /// using up to a limited maximum force. class ServoMotor : public Motor { *************** *** 54,58 **** //virtual void OPAL_CALL init(Mode m, Joint* j, int axisNum); ! /// Initializes the Motor with the given data structure. virtual void OPAL_CALL init(const ServoMotorData& data); --- 54,59 ---- //virtual void OPAL_CALL init(Mode m, Joint* j, int axisNum); ! /// Initializes the Motor with the given data structure. Joint ! /// pointer in the data must be valid. virtual void OPAL_CALL init(const ServoMotorData& data); *************** *** 68,82 **** virtual void OPAL_CALL setEnabled(bool e); ! /// Sets the desired position to a value between the Joint axis' /// limits. ! virtual void OPAL_CALL setDesiredPos(real pos); ! /// Sets the desired position to a value between 0.0 and 1.0 which /// will be mapped to the Joint axis' limits. ! virtual void OPAL_CALL setDesiredPosNorm(real pos); ! /// Gets the desired position, a value between the Joint axis' /// limits. ! virtual real OPAL_CALL getDesiredPos()const; /// Sets the desired velocity. --- 69,83 ---- virtual void OPAL_CALL setEnabled(bool e); ! /// Sets the desired angle to a value between the Joint axis' /// limits. ! virtual void OPAL_CALL setDesiredAngle(real a); ! /// Sets the desired angle to a value between 0.0 and 1.0 which /// will be mapped to the Joint axis' limits. ! virtual void OPAL_CALL setDesiredAngleNorm(real a); ! /// Gets the desired angle, a value between the Joint axis' /// limits. ! virtual real OPAL_CALL getDesiredAngle()const; /// Sets the desired velocity. *************** *** 86,94 **** virtual real OPAL_CALL getDesiredVel()const; ! /// Sets the maximum amount of force/torque this Motor can use. ! virtual void OPAL_CALL setMaxForce(real max); ! /// Returns the maximum amount of force/torque this Motor can use. ! virtual real OPAL_CALL getMaxForce()const; /// Sets the restore speed, the parameter used to scale how fast --- 87,95 ---- virtual real OPAL_CALL getDesiredVel()const; ! /// Sets the maximum amount of torque this Motor can use. ! virtual void OPAL_CALL setMaxTorque(real max); ! /// Returns the maximum amount of torque this Motor can use. ! virtual real OPAL_CALL getMaxTorque()const; /// Sets the restore speed, the parameter used to scale how fast Index: AttractorMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/AttractorMotor.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AttractorMotor.h 25 Feb 2005 06:40:26 -0000 1.23 --- AttractorMotor.h 26 Feb 2005 10:22:23 -0000 1.24 *************** *** 53,57 **** //virtual void OPAL_CALL init(Solid* solid0, Solid* solid1); ! /// Initializes the Motor with the given data structure. virtual void OPAL_CALL init(const AttractorMotorData& data); --- 53,58 ---- //virtual void OPAL_CALL init(Solid* solid0, Solid* solid1); ! /// Initializes the Motor with the given data structure. Solid ! /// pointers in the data must be valid. virtual void OPAL_CALL init(const AttractorMotorData& data); Index: ThrusterMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ThrusterMotor.cpp 25 Feb 2005 06:40:26 -0000 1.6 --- ThrusterMotor.cpp 26 Feb 2005 10:22:23 -0000 1.7 *************** *** 50,53 **** --- 50,54 ---- void ThrusterMotor::init(const ThrusterMotorData& data) { + assert(data.solid); Motor::init(); mData = data; Index: AttractorMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/AttractorMotorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AttractorMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 --- AttractorMotorData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 46,49 **** --- 46,51 ---- internal_solid0Index = 0; internal_solid1Index = 0; + internal_solid0Name = ""; + internal_solid1Name = ""; strength = defaults::motor::attractor::strength; exponent = defaults::motor::attractor::exponent; *************** *** 68,71 **** --- 70,77 ---- solid0 = data.solid0; solid1 = data.solid1; + internal_solid0Index = data.internal_solid0Index; + internal_solid1Index = data.internal_solid1Index; + internal_solid0Name = data.internal_solid0Name; + internal_solid1Name = data.internal_solid1Name; strength = data.strength; exponent = data.exponent; *************** *** 84,87 **** --- 90,99 ---- int internal_solid1Index; + /// Internal data used for Blueprint instantiation. + std::string internal_solid0Name; + + /// Internal data used for Blueprint instantiation. + std::string internal_solid1Name; + /// Constant used to scale attraction (repulsion if strength < 0). real strength; Index: Blueprint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Blueprint.h 25 Feb 2005 16:43:19 -0000 1.23 --- Blueprint.h 26 Feb 2005 10:22:23 -0000 1.24 *************** *** 43,99 **** /// Joints, Motors, and/or Sensors. They are created by OPAL when /// an OPAL XML file is loaded. They can also be created by users ! /// and saved to an OPAL XML file. They are not guaranteed to yield /// perfect repeatability after a save/restore sequence. class Blueprint { public: ! Blueprint(); ! virtual ~Blueprint(); /// Adds a new SolidData object to the Blueprint. Makes a /// deep copy of the given data. ! virtual void OPAL_CALL addSolid(SolidData* data); /// Adds a new JointData object to the Blueprint. Makes a /// deep copy of the given data. ! virtual void OPAL_CALL addJoint(JointData* data); /// Adds a new MotorData object to the Blueprint. Makes a /// deep copy of the given data. ! virtual void OPAL_CALL addMotor(MotorData* data); /// Adds a new SensorData object to the Blueprint. Makes a /// deep copy of the given data. ! virtual void OPAL_CALL addSensor(SensorData* data); /// Returns the number of SolidData objects. ! virtual int OPAL_CALL getNumSolids()const; /// Returns the number of JointData objects. ! virtual int OPAL_CALL getNumJoints()const; /// Returns the number of MotorData objects. ! virtual int OPAL_CALL getNumMotors()const; /// Returns the number of SensorData objects. ! virtual int OPAL_CALL getNumSensors()const; /// Returns a pointer to the SolidData at the given index. ! virtual SolidData* OPAL_CALL getSolidData(unsigned int i)const; /// Returns a pointer to the JointData at the given index. ! virtual JointData* OPAL_CALL getJointData(unsigned int i)const; /// Returns a pointer to the MotorData at the given index. ! virtual MotorData* OPAL_CALL getMotorData(unsigned int i)const; /// Returns a pointer to the SensorData at the given index. ! virtual SensorData* OPAL_CALL getSensorData(unsigned int i)const; ! ! /// Returns the index of the given Solid name in the Blueprint's ! /// list of SolidData. Returns -1 if the Solid name is not found ! /// or if the given name is an empty string. ! int internal_getSolidIndex(const std::string& name)const; private: --- 43,109 ---- /// Joints, Motors, and/or Sensors. They are created by OPAL when /// an OPAL XML file is loaded. They can also be created by users ! /// and saved to an OPAL XML file. When setting up a Blueprint ! /// manually add all object data to the Blueprint and call finalize ! /// when finished. Blueprints are not guaranteed to yield /// perfect repeatability after a save/restore sequence. class Blueprint { public: ! OPAL_DECL Blueprint(); ! OPAL_DECL virtual ~Blueprint(); ! ! /// Updates references among internal objects. This must ! /// be called before the Blueprint can be instantiated. This ! /// is automatically called on Blueprints loaded from files. ! OPAL_DECL virtual void OPAL_CALL finalize(); ! ! /// Returns true if this Blueprint has been finalized (via the ! /// finalize function). ! OPAL_DECL virtual bool OPAL_CALL isFinalized()const; /// Adds a new SolidData object to the Blueprint. Makes a /// deep copy of the given data. ! OPAL_DECL virtual void OPAL_CALL addSolid(SolidData* data); /// Adds a new JointData object to the Blueprint. Makes a /// deep copy of the given data. ! OPAL_DECL virtual void OPAL_CALL addJoint(JointData* data); /// Adds a new MotorData object to the Blueprint. Makes a /// deep copy of the given data. ! OPAL_DECL virtual void OPAL_CALL addMotor(MotorData* data); /// Adds a new SensorData object to the Blueprint. Makes a /// deep copy of the given data. ! OPAL_DECL virtual void OPAL_CALL addSensor(SensorData* data); /// Returns the number of SolidData objects. ! OPAL_DECL virtual int OPAL_CALL getNumSolids()const; /// Returns the number of JointData objects. ! OPAL_DECL virtual int OPAL_CALL getNumJoints()const; /// Returns the number of MotorData objects. ! OPAL_DECL virtual int OPAL_CALL getNumMotors()const; /// Returns the number of SensorData objects. ! OPAL_DECL virtual int OPAL_CALL getNumSensors()const; /// Returns a pointer to the SolidData at the given index. ! OPAL_DECL virtual SolidData* OPAL_CALL getSolidData( ! unsigned int i)const; /// Returns a pointer to the JointData at the given index. ! OPAL_DECL virtual JointData* OPAL_CALL getJointData( ! unsigned int i)const; /// Returns a pointer to the MotorData at the given index. ! OPAL_DECL virtual MotorData* OPAL_CALL getMotorData( ! unsigned int i)const; /// Returns a pointer to the SensorData at the given index. ! OPAL_DECL virtual SensorData* OPAL_CALL getSensorData( ! unsigned int i)const; private: *************** *** 118,124 **** --- 128,158 ---- bool sensorExists(const std::string& name); + /// Returns the index of the given Solid name in the Blueprint's + /// list of SolidData. Returns -1 if the Solid name is not found + /// or if the given name is an empty string. + int getSolidIndex(const std::string& name)const; + + /// Returns the index of the given Joint name in the Blueprint's + /// list of JointData. Returns -1 if the Joint name is not found + /// or if the given name is an empty string. + int getJointIndex(const std::string& name)const; + + /// Prints a warning message saying that the Blueprint has already + /// been finalized. + void printFinalizedMessage(); + + /// True if the Blueprint has been finalized. + bool mFinalized; + + /// The set of all Solid pointers in this Blueprint. std::vector<SolidData*> mSolidList; + + /// The set of all Joint pointers in this Blueprint. std::vector<JointData*> mJointList; + + /// The set of all Motor pointers in this Blueprint. std::vector<MotorData*> mMotorList; + + /// The set of all Sensor pointers in this Blueprint. std::vector<SensorData*> mSensorList; }; Index: GearedMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GearedMotor.h 25 Feb 2005 06:40:26 -0000 1.7 --- GearedMotor.h 26 Feb 2005 10:22:23 -0000 1.8 *************** *** 36,41 **** { /// The GearedMotor is intended to simulate an automobile engine. ! /// This Motor applies to a rotational Joint. It applies a torque to ! /// one of its degrees of freedom, but the amount of torque decreases /// linearly as the angular velocity increases, similar to an automobile /// engine. The Motor's max torque is applied when angular velocity is --- 36,41 ---- { /// The GearedMotor is intended to simulate an automobile engine. ! /// This Motor only works on rotational Joint axes. It applies a torque ! /// to one of its degrees of freedom, but the amount of torque decreases /// linearly as the angular velocity increases, similar to an automobile /// engine. The Motor's max torque is applied when angular velocity is *************** *** 58,62 **** //virtual void OPAL_CALL init(Joint* joint, int axisNum); ! /// Initializes the Motor with the given data structure. virtual void OPAL_CALL init(const GearedMotorData& data); --- 58,63 ---- //virtual void OPAL_CALL init(Joint* joint, int axisNum); ! /// Initializes the Motor with the given data structure. Joint ! /// pointer in the data must be valid. virtual void OPAL_CALL init(const GearedMotorData& data); Index: JointData.h =================================================================== RCS file: /cvsroot/opal/opal/src/JointData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JointData.h 25 Feb 2005 06:40:26 -0000 1.2 --- JointData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 91,94 **** --- 91,96 ---- internal_solid0Index = 0; internal_solid1Index = 0; + internal_solid0Name = ""; + internal_solid1Name = ""; anchor = defaults::joint::anchor; axis[0].direction = defaults::joint::axis0Direction; *************** *** 121,124 **** --- 123,130 ---- solid0 = data.solid0; solid1 = data.solid1; + internal_solid0Index = data.internal_solid0Index; + internal_solid1Index = data.internal_solid1Index; + internal_solid0Name = data.internal_solid0Name; + internal_solid1Name = data.internal_solid1Name; anchor = data.anchor; *************** *** 164,167 **** --- 170,179 ---- int internal_solid1Index; + /// Internal data used for Blueprint instantiation. + std::string internal_solid0Name; + + /// Internal data used for Blueprint instantiation. + std::string internal_solid1Name; + /// The anchor point for this Joint. This is not used for every /// Joint type. Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Solid.cpp 25 Feb 2005 06:40:26 -0000 1.23 --- Solid.cpp 26 Feb 2005 10:22:23 -0000 1.24 *************** *** 89,93 **** //} ! bool Solid::isStatic() { return mData.isStatic; --- 89,93 ---- //} ! bool Solid::isStatic()const { return mData.isStatic; Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** Defines.h 25 Feb 2005 06:40:26 -0000 1.60 --- Defines.h 26 Feb 2005 10:22:23 -0000 1.61 *************** *** 221,225 **** /// Axis 1: rotational ("wheel axis") /// Axis 2: not used ! HINGE_2_JOINT, /// Anchor: not used --- 221,225 ---- /// Axis 1: rotational ("wheel axis") /// Axis 2: not used ! WHEEL_JOINT, /// Anchor: not used *************** *** 332,336 **** namespace servo { ! const real maxForce = (real)10.0; const real restoreSpeed = (real)1.0; } --- 332,336 ---- namespace servo { ! const real maxTorque = (real)10.0; const real restoreSpeed = (real)1.0; } *************** *** 343,346 **** --- 343,349 ---- const real angularKd = (real)0.1; const real angularKs = (real)1.0; + const Vec3r desiredForward = Vec3r(0, 0, -1); + const Vec3r desiredUp = Vec3r(0, 1, 0); + const Vec3r desiredRight = Vec3r(1, 0, 0); } } Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Joint.cpp 25 Feb 2005 06:40:26 -0000 1.21 --- Joint.cpp 26 Feb 2005 10:22:23 -0000 1.22 *************** *** 286,290 **** } ! bool Joint::isRotational(int axisNum) { assert(axisNum >= 0 && axisNum < mNumAxes); --- 286,290 ---- } ! bool Joint::isRotational(int axisNum)const { assert(axisNum >= 0 && axisNum < mNumAxes); Index: SpringMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SpringMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 --- SpringMotorData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 57,65 **** mType = SPRING_MOTOR; solid = NULL; mode = LINEAR_MODE; // "desiredPos" is initialized in its own constructor. ! // "desiredForward" is initialized in its own constructor. ! // "desiredUp" is initialized in its own constructor. ! // "desiredRight" is initialized in its own constructor. linearKd = defaults::motor::spring::linearKd; linearKs = defaults::motor::spring::linearKs; --- 57,67 ---- mType = SPRING_MOTOR; solid = NULL; + internal_solidIndex = 0; + internal_solidName = ""; mode = LINEAR_MODE; // "desiredPos" is initialized in its own constructor. ! desiredForward = defaults::motor::spring::desiredForward; ! desiredUp = defaults::motor::spring::desiredUp; ! desiredRight = defaults::motor::spring::desiredRight; linearKd = defaults::motor::spring::linearKd; linearKs = defaults::motor::spring::linearKs; *************** *** 85,88 **** --- 87,92 ---- name = data.name; solid = data.solid; + internal_solidIndex = data.internal_solidIndex; + internal_solidName = data.internal_solidName; mode = data.mode; desiredPos = data.desiredPos; *************** *** 99,102 **** --- 103,112 ---- Solid* solid; + /// Internal data used for Blueprint instantiation. + int internal_solidIndex; + + /// Internal data used for Blueprint instantiation. + std::string internal_solidName; + /// The Motor's mode of operation. SpringMotorMode mode; Index: ThrusterMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ThrusterMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 --- ThrusterMotorData.h 26 Feb 2005 10:22:23 -0000 1.3 *************** *** 43,46 **** --- 43,48 ---- mType = THRUSTER_MOTOR; solid = NULL; + internal_solidIndex = 0; + internal_solidName = ""; force.singleStep = true; } ******... [truncated message content] |