Thread: [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 2... [truncated message content] |