From: Carle C. <car...@us...> - 2004-08-30 19:22:05
|
Update of /cvsroot/robotflow/RobotFlow/MARIE/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4910/MARIE/src Modified Files: Makefile.am MarieCommandCamera.cpp Added Files: MarieDataLocalisation.cpp Log Message: add localisation data type Index: Makefile.am =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/MARIE/src/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.am 4 Aug 2004 17:49:50 -0000 1.11 --- Makefile.am 30 Aug 2004 19:21:55 -0000 1.12 *************** *** 24,28 **** MarieCommandJoystick.cpp \ MarieDataIR.cpp \ ! MarieDataBumper.cpp install-data-local: --- 24,29 ---- MarieCommandJoystick.cpp \ MarieDataIR.cpp \ ! MarieDataBumper.cpp \ ! MarieDataLocalisation.cpp install-data-local: Index: MarieCommandCamera.cpp =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/MARIE/src/MarieCommandCamera.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MarieCommandCamera.cpp 24 Aug 2004 17:34:26 -0000 1.4 --- MarieCommandCamera.cpp 30 Aug 2004 19:21:55 -0000 1.5 *************** *** 55,60 **** * * @input_name REL_ZOOM ! * @input_type input zoom, nilObject if not used ! * @input_description * * @input_name ABS_BRIGHTNESS --- 55,60 ---- * * @input_name REL_ZOOM ! * @input_type int ! * @input_description input zoom, nilObject if not used * * @input_name ABS_BRIGHTNESS *************** *** 75,80 **** * * @input_name ABS_ZOOM ! * @input_type input zoom, nilObject if not used ! * @input_description * * @output_name COMMAND_CAMERA --- 75,80 ---- * * @input_name ABS_ZOOM ! * @input_type int ! * @input_description input zoom, nilObject if not used * * @output_name COMMAND_CAMERA *************** *** 99,103 **** * * @output_name REL_ZOOM ! * @output_type zoom * @output_description output zoom * --- 99,103 ---- * * @output_name REL_ZOOM ! * @output_type int * @output_description output zoom * *************** *** 119,123 **** * * @output_name ABS_ZOOM ! * @output_type zoom * @output_description output zoom * --- 119,123 ---- * * @output_name ABS_ZOOM ! * @output_type int * @output_description output zoom * --- NEW FILE: MarieDataLocalisation.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Carle Cote * * This library is free software; you can redistribute it and/or * modify it under the terms of 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. * * 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 GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * You can contact MARIE development team at http://marie.sourceforge.net */ #include "MarieDataLocalisation.h" #include <sstream> #include <string> #include "MarieXMLDataFactory.h" namespace marie { DECLARE_NODE(MarieDataLocalisation) /*Node * * @name MarieDataLocalisation * @category RobotFlow:MARIE:DATA * @description Read & Create MarieDataLocalisation data object * * @input_name DATA_LOCALISATION * @input_type Input MarieDataLocalisation * @input_description input DataLocalisation, nilObject if not used * * @input_name X * @input_type float * @input_description input X, nilObject if not used * * @input_name Y * @input_type float * @input_description input Y, nilObject if not used * * @input_name Z * @input_type float * @input_description input Z, nilObject if not used * * @input_name STRENGTH * @input_type float * @input_description input strength, nilObject if not used * * @input_name ID * @input_type string * @input_description input id, nilObject if not used * * @output_name DATA_LOCALISATION * @output_type MarieDataLocalisation * @output_description Output DataLocalisation * * @output_name X * @output_type float * @output_description output X * * @output_name Y * @output_type float * @output_description output Y * * @output_name Z * @output_type float * @output_description output Z * * @output_name STRENGTH * @output_type float * @output_description output strength * * @output_name ID * @output_type string * @output_description output ID * END*/ using namespace std; DECLARE_TYPE2(DataLocalisation::ID,MarieDataLocalisation) MarieDataLocalisation::MarieDataLocalisation() : MarieObject("MarieDataLocalisation",ParameterSet()), m_isNode(false) { } MarieDataLocalisation::MarieDataLocalisation (const DataLocalisation &command) : MarieObject("MarieDataLocalisation",ParameterSet()), DataLocalisation(command), m_isNode(false) { } MarieDataLocalisation::MarieDataLocalisation(string nodeName, ParameterSet params) : MarieObject(nodeName,params), m_isNode(true) { //used as a BufferedNode, create inputs & outputs //inputs m_dataInID = addInput("DATA_LOCALISATION"); m_xInID = addInput("X"); m_yInID = addInput("Y"); m_zInID = addInput("Z"); m_strengthInID = addInput("STRENGTH"); m_idInID = addInput("ID"); //outputs m_dataOutID = addOutput("DATA_LOCALISATION"); m_xOutID = addOutput("X"); m_yOutID = addOutput("Y"); m_zOutID = addOutput("Z"); m_strengthOutID = addOutput("STRENGTH"); m_idOutID = addOutput("ID"); } void MarieDataLocalisation::calculate(int output_id, int count, Buffer &out) { if (m_isNode) { MarieDataLocalisation *data = NULL; float x,y,z,strength = 0; string id = ""; //get all inputs ObjectRef dataInValue = getInput(m_dataInID,count); ObjectRef xInValue = getInput(m_xInID,count); ObjectRef yInValue = getInput(m_yInID,count); ObjectRef zInValue = getInput(m_zInID,count); ObjectRef strengthInValue = getInput(m_strengthInID,count); ObjectRef idInValue = getInput(m_idInID,count); //create command object if (!dataInValue->isNil()) { RCPtr<MarieDataLocalisation> inputData = dataInValue; //copy input command data = new MarieDataLocalisation(*inputData); data->getPosition(x,y,z); strength = data->getStrength(); id = data->getID(); } else { if (!xInValue->isNil() || !yInValue->isNil() || !zInValue->isNil() || !strengthInValue->isNil() || !idInValue->isNil()) { data = new MarieDataLocalisation(); //get x if (!xInValue->isNil() || !yInValue->isNil() || !zInValue->isNil()) { RCPtr<Float> xPtr = xInValue; x = *xPtr; RCPtr<Float> yPtr = yInValue; y = *yPtr; RCPtr<Float> zPtr = zInValue; z = *zPtr; data->setPosition(x,y,z); } //get strength if (!strengthInValue->isNil()) { RCPtr<Float> strengthPtr = strengthInValue; strength = *strengthPtr; data->setStrength(strength); } //get id if (!idInValue->isNil()) { RCPtr<String> idPtr = idInValue; id = *idPtr; data->setID(id); } } } if (data) { //output values (*outputs[m_dataOutID].buffer)[count] = ObjectRef(data); (*outputs[m_xOutID].buffer)[count] = ObjectRef(Float::alloc(x)); (*outputs[m_yOutID].buffer)[count] = ObjectRef(Float::alloc(y)); (*outputs[m_zOutID].buffer)[count] = ObjectRef(Float::alloc(z)); (*outputs[m_strengthOutID].buffer)[count] = ObjectRef(Float::alloc(strength)); (*outputs[m_idOutID].buffer)[count] = ObjectRef(new String(id)); } else { //output values (*outputs[m_xOutID].buffer)[count] = nilObject; (*outputs[m_dataOutID].buffer)[count] = nilObject; (*outputs[m_yOutID].buffer)[count] = nilObject; (*outputs[m_zOutID].buffer)[count] = nilObject; (*outputs[m_strengthOutID].buffer)[count] = nilObject; (*outputs[m_idOutID].buffer)[count] = nilObject; } } else { out[count] = nilObject; } } void MarieDataLocalisation::printOn(ostream &out) const { MarieXMLDataFactory factory; //writing XML data string value = factory.toString((DataLocalisation&) (*this)); out.write(value.c_str(), value.size()); } void MarieDataLocalisation::readFrom(istream &in) { throw new GeneralException("readFrom not supported. Use the MarieLoad Node to read data from the stream.",__FILE__,__LINE__); } void MarieDataLocalisation::copyDataAbstract(DataAbstract *data) { if (data) { DataLocalisation *dataL = dynamic_cast<DataLocalisation*>(data); if (dataL) { //((DataLocalisation*)this)->operator=(*command); this->DataLocalisation::operator=(*dataL); } else { throw new GeneralException(string("Unable to cast into DataLocalisation Abstract : ") + data->getID(),__FILE__,__LINE__); } } } } |