From: Dominic L. <ma...@us...> - 2004-10-28 18:12:01
|
Update of /cvsroot/robotflow/RobotFlow/MARIE/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14514 Modified Files: Makefile.am Added Files: extractMarieCommandJoystick.cpp extractMarieCommandMotor.cpp newMarieCommandJoystick.cpp newMarieCommandMotor.cpp Log Message: commands now have all new / extract nodes --- NEW FILE: extractMarieCommandMotor.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Dominic Letourneau / 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 <sstream> #include <string> #include "MarieCommandMotor.h" #include "MarieXMLDataFactory.h" #include "Behavior.h" #include "Vector.h" #include "MarieDataNull.h" namespace marie { //forward declaration class extractMarieCommandMotor; DECLARE_NODE(extractMarieCommandMotor) /*Node * * @name extractMarieCommandMotor * @category RobotFlow:MARIE:COMMAND * @description Extract data in the FlowDesigner format from MarieCommandMotor * * @input_name COMMAND_MOTOR * @input_type MarieCommandMotor * @input_description The MarieCommandMotor object * * @output_name VELOCITY * @output_type int * @output_description output velocity * * @output_name ROTATION * @output_type int * @output_description output rotation * * END*/ using namespace std; class extractMarieCommandMotor : public BufferedNode { private: //intputs int m_commandMotorID; //outputs int m_velocityOutID; int m_rotationOutID; public: extractMarieCommandMotor(string nodeName, ParameterSet params) : BufferedNode(nodeName,params) { //inputs m_commandMotorID = addInput("COMMAND_MOTOR"); //outputs m_velocityOutID = addOutput("VELOCITY"); m_rotationOutID = addOutput("ROTATION"); } void calculate(int output_id, int count, Buffer &out) { try { //get input RCPtr<MarieCommandMotor> command = getInput(m_commandMotorID,count); //output data (*outputs[m_velocityOutID].buffer)[count] = ObjectRef(Int::alloc(command->getVelocity())); (*outputs[m_rotationOutID].buffer)[count] = ObjectRef(Int::alloc(command->getRotation())); } catch (BaseException *e) { e->print(cerr); e->add(new GeneralException("Unable to process",__FILE__,__LINE__)); throw e; } } };//class extractMarieCommandMotor }//namespace marie --- NEW FILE: extractMarieCommandJoystick.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Dominic Letourneau / 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 <sstream> #include <string> #include "MarieCommandJoystick.h" #include "MarieXMLDataFactory.h" #include "Behavior.h" #include "Vector.h" #include "MarieDataNull.h" namespace marie { //forward declaration class extractMarieCommandJoystick; DECLARE_NODE(extractMarieCommandJoystick) /*Node * * @name extractMarieCommandJoystick * @category RobotFlow:MARIE:COMMAND * @description Extract data in the FlowDesigner format from MarieCommandJoystick * * @input_name COMMAND_JOYSTICK * @input_type MarieCommandJoystick * @input_description The MarieCommandJoystick object * * @output_name X * @output_type int * @output_description input x, nilObject if not used * * @output_name Y * @output_type int * @output_description input y, nilObject if not used * * @output_name XMIN * @output_type int * @output_description input xmin, nilObject if not used * * @output_name YMIN * @output_type int * @output_description input ymin, nilObject if not used * * @output_name XMAX * @output_type int * @output_description input xmax, nilObject if not used * * @output_name YMAX * @output_type int * @output_description input ymax, nilObject if not used * * @output_name NBBUTTONS * @output_type int * @output_description output nb buttons, nilObject if not used * * @output_name BUTTONSTATE * @output_type int * @output_description output button state, nilObject if not used * END*/ using namespace std; class extractMarieCommandJoystick : public BufferedNode { private: //intputs int m_commandInID; //outputs int m_xOutID; int m_yOutID; int m_xminOutID; int m_yminOutID; int m_xmaxOutID; int m_ymaxOutID; int m_nbButtonsOutID; int m_buttonStateOutID; public: extractMarieCommandJoystick(string nodeName, ParameterSet params) : BufferedNode(nodeName,params) { //inputs m_commandInID = addInput("COMMAND_JOYSTICK"); //outputs m_xOutID = addOutput("X"); m_yOutID = addOutput("Y"); m_xminOutID = addOutput("XMIN"); m_yminOutID = addOutput("YMIN"); m_xmaxOutID = addOutput("XMAX"); m_ymaxOutID = addOutput("YMAX"); m_nbButtonsOutID = addOutput("NBBUTTONS"); m_buttonStateOutID = addOutput("BUTTONSTATE"); } void calculate(int output_id, int count, Buffer &out) { try { RCPtr<MarieCommandJoystick> command = getInput(m_commandInID,count); int x, y, xmin, ymin, xmax, ymax, nbButtons, buttonState = 0; command->getXY(x, y); command->getMinXY(xmin, ymin); command->getMaxXY(xmax, ymax); nbButtons = command->getNbButtons(); buttonState = command->getButtonState(); //output data (*outputs[m_xOutID].buffer)[count] = ObjectRef(Int::alloc(x)); (*outputs[m_yOutID].buffer)[count] = ObjectRef(Int::alloc(y)); (*outputs[m_xminOutID].buffer)[count] = ObjectRef(Int::alloc(xmin)); (*outputs[m_yminOutID].buffer)[count] = ObjectRef(Int::alloc(ymin)); (*outputs[m_xmaxOutID].buffer)[count] = ObjectRef(Int::alloc(xmax)); (*outputs[m_ymaxOutID].buffer)[count] = ObjectRef(Int::alloc(ymax)); (*outputs[m_nbButtonsOutID].buffer)[count] = ObjectRef(Int::alloc(nbButtons)); (*outputs[m_buttonStateOutID].buffer)[count] = ObjectRef(Int::alloc(buttonState)); } catch (BaseException *e) { e->print(cerr); e->add(new GeneralException("Unable to process",__FILE__,__LINE__)); throw e; } } };//class extractMarieCommandJoystick }//namespace marie --- NEW FILE: newMarieCommandMotor.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Dominic Letourneau / 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 <sstream> #include <string> #include "MarieCommandMotor.h" #include "MarieXMLDataFactory.h" #include "Behavior.h" #include "Vector.h" #include "MarieDataNull.h" namespace marie { //forward declaration class newMarieCommandMotor; DECLARE_NODE(newMarieCommandMotor) /*Node * * @name newMarieCommandMotor * @category RobotFlow:MARIE:COMMAND * @description Create an object of type MarieCommandMotor * * @input_name VELOCITY * @input_type int * @input_description input velocity * * @input_name ROTATION * @input_type int * @input_description input rotation * * @output_name COMMAND_MOTOR * @output_description Output MARIE BehaviorCommand data object * @output_type MarieCommandBahavior * END*/ using namespace std; class newMarieCommandMotor : public BufferedNode { private: //intputs int m_velocityInID; int m_rotationInID; //outputs int m_commandOutID; public: newMarieCommandMotor(string nodeName, ParameterSet params) : BufferedNode(nodeName,params) { //intputs m_velocityInID = addInput("VELOCITY"); m_rotationInID = addInput("ROTATION"); //outputs m_commandOutID = addOutput("COMMAND_MOTOR"); } void calculate(int output_id, int count, Buffer &out) { try { RCPtr<Int> velocity = getInput(m_velocityInID,count); RCPtr<Int> rotation = getInput(m_rotationInID,count); MarieCommandMotor *command = new MarieCommandMotor(); command->setVelocity(*velocity); command->setRotation(*rotation); //output result out[count] = command; } catch (BaseException *e) { e->print(cerr); e->add(new GeneralException("Unable to process",__FILE__,__LINE__)); throw e; } } };//class newMarieCommandMotor }//namespace marie Index: Makefile.am =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/MARIE/src/Makefile.am,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Makefile.am 28 Oct 2004 15:03:29 -0000 1.19 --- Makefile.am 28 Oct 2004 18:11:48 -0000 1.20 *************** *** 18,36 **** MarieDataOdometry.cpp \ MarieDataNull.cpp \ MarieCommandBehavior.cpp \ MarieCommandCamera.cpp \ MarieCommandMotor.cpp \ ! MarieDataRaw.cpp \ ! MarieCommandJoystick.cpp \ ! MarieDataIR.cpp \ ! MarieDataBumper.cpp \ ! MarieDataMap.cpp \ ! newMarieDataMap.cpp \ MarieRequestSystem.cpp \ newMarieRequestSystem.cpp \ - extractMarieCommandBehavior.cpp \ newMarieCommandBehavior.cpp \ extractMarieCommandCamera.cpp \ ! newMarieCommandCamera.cpp install-data-local: --- 18,40 ---- MarieDataOdometry.cpp \ MarieDataNull.cpp \ + MarieDataRaw.cpp \ + MarieDataIR.cpp \ + MarieDataBumper.cpp \ + MarieDataMap.cpp \ MarieCommandBehavior.cpp \ MarieCommandCamera.cpp \ MarieCommandMotor.cpp \ ! MarieCommandJoystick.cpp \ MarieRequestSystem.cpp \ + newMarieDataMap.cpp \ newMarieRequestSystem.cpp \ newMarieCommandBehavior.cpp \ + newMarieCommandCamera.cpp \ + newMarieCommandMotor.cpp \ + newMarieCommandJoystick.cpp \ + extractMarieCommandBehavior.cpp \ extractMarieCommandCamera.cpp \ ! extractMarieCommandMotor.cpp \ ! extractMarieCommandJoystick.cpp install-data-local: --- NEW FILE: newMarieCommandJoystick.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Dominic Letourneau / 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 <sstream> #include <string> #include "MarieCommandJoystick.h" #include "MarieXMLDataFactory.h" #include "Behavior.h" #include "Vector.h" #include "MarieDataNull.h" namespace marie { //forward declaration class newMarieCommandJoystick; DECLARE_NODE(newMarieCommandJoystick) /*Node * * @name newMarieCommandJoystick * @category RobotFlow:MARIE:COMMAND * @description Create an object of type MarieCommandJoystick * * @input_name X * @input_type int * @input_description input x, nilObject if not used * * @input_name Y * @input_type int * @input_description input y, nilObject if not used * * @input_name XMIN * @input_type int * @input_description input xmin, nilObject if not used * * @input_name YMIN * @input_type int * @input_description input ymin, nilObject if not used * * @input_name XMAX * @input_type int * @input_description input xmax, nilObject if not used * * @input_name YMAX * @input_type int * @input_description input ymax, nilObject if not used * * @input_name NBBUTTONS * @input_type int * @input_description input nb buttons, nilObject if not used * * @input_name BUTTONSTATE * @input_type int * @input_description input button state, nilObject if not used * * @output_name COMMAND_JOYSTICK * @output_description Output MARIE CommandJoystick data object * @output_type MarieCommandJoystick * END*/ using namespace std; class newMarieCommandJoystick : public BufferedNode { private: //inputs int m_xInID; int m_yInID; int m_xminInID; int m_yminInID; int m_xmaxInID; int m_ymaxInID; int m_nbButtonsInID; int m_buttonStateInID; //outputs int m_commandOutID; public: newMarieCommandJoystick(string nodeName, ParameterSet params) : BufferedNode(nodeName,params) { //inputs m_xInID = addInput("X"); m_yInID = addInput("Y"); m_xminInID = addInput("XMIN"); m_yminInID = addInput("YMIN"); m_xmaxInID = addInput("XMAX"); m_ymaxInID = addInput("YMAX"); m_nbButtonsInID = addInput("NBBUTTONS"); m_buttonStateInID = addInput("BUTTONSTATE"); //outputs m_commandOutID = addOutput("COMMAND_JOYSTICK"); } void calculate(int output_id, int count, Buffer &out) { try { //get all inputs ObjectRef xInValue = getInput(m_xInID,count); ObjectRef yInValue = getInput(m_yInID,count); ObjectRef xminInValue = getInput(m_xminInID,count); ObjectRef yminInValue = getInput(m_yminInID,count); ObjectRef xmaxInValue = getInput(m_xmaxInID,count); ObjectRef ymaxInValue = getInput(m_ymaxInID,count); ObjectRef nbButtonsInValue = getInput(m_nbButtonsInID,count); ObjectRef buttonStateInValue = getInput(m_buttonStateInID,count); //create command object MarieCommandJoystick *command = new MarieCommandJoystick(); int x, y, xmin, ymin, xmax, ymax, nbButtons, buttonState = 0; //get x if (!xInValue->isNil()) { RCPtr<Int> xPtr = xInValue; x = *xPtr; } //get y if (!yInValue->isNil()) { RCPtr<Int> yPtr = yInValue; y = *yPtr; } //get xmin if (!xminInValue->isNil()) { RCPtr<Int> xminPtr = xminInValue; xmin = *xminPtr; } //get ymin if (!yminInValue->isNil()) { RCPtr<Int> yminPtr = yminInValue; ymin = *yminPtr; } //get xmax if (!xmaxInValue->isNil()) { RCPtr<Int> xmaxPtr = xmaxInValue; xmax = *xmaxPtr; } //get ymax if (!ymaxInValue->isNil()) { RCPtr<Int> ymaxPtr = ymaxInValue; ymax = *ymaxPtr; } //get nbButtons if (!nbButtonsInValue->isNil()) { RCPtr<Int> nbButtonsPtr = nbButtonsInValue; nbButtons = *nbButtonsPtr; } //get buttonState if (!buttonStateInValue->isNil()) { RCPtr<Int> buttonStatePtr = buttonStateInValue; buttonState = *buttonStatePtr; } //set PTZ command->setXY(x, y); command->setMinXY(xmin, ymin); command->setMaxXY(xmax, ymax); command->setNbButtons(nbButtons); command->setButtonState(buttonState); //output command object out[count] = ObjectRef(command); } catch(BaseException *e) { e->print(cerr); throw e->add(new GeneralException("",__FILE__,__LINE__)); } } };//class newMarieCommandJoystick }//namespace marie |