From 9ce639b0aacda92f6e3832b54853ccee72fd76fb Mon Sep 17 00:00:00 2001 From: Manfred Kroehnert <Manfred.Kroehnert@kit.edu> Date: Tue, 9 Sep 2014 15:34:16 +0200 Subject: [PATCH] add empty StopRobot state --- .../MotionControlGroup/CMakeLists.txt | 2 + .../MotionControlGroup.scgxml | 1 + .../MotionControlGroup/StopRobot.cpp | 83 +++++++++++++++++++ .../MotionControlGroup/StopRobot.h | 58 +++++++++++++ .../MotionControlGroup/StopRobot.xml | 10 +++ 5 files changed, 154 insertions(+) create mode 100644 source/RobotAPI/statecharts/MotionControlGroup/StopRobot.cpp create mode 100644 source/RobotAPI/statecharts/MotionControlGroup/StopRobot.h create mode 100644 source/RobotAPI/statecharts/MotionControlGroup/StopRobot.xml diff --git a/source/RobotAPI/statecharts/MotionControlGroup/CMakeLists.txt b/source/RobotAPI/statecharts/MotionControlGroup/CMakeLists.txt index e4ba4cbeb..63722b666 100644 --- a/source/RobotAPI/statecharts/MotionControlGroup/CMakeLists.txt +++ b/source/RobotAPI/statecharts/MotionControlGroup/CMakeLists.txt @@ -20,6 +20,7 @@ set(SOURCES MotionControlGroupRemoteStateOfferer.cpp ./MoveJoints.cpp testing/testMoveJoints.cpp +./StopRobot.cpp #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.cpp ) @@ -27,6 +28,7 @@ set(HEADERS MotionControlGroupRemoteStateOfferer.h ./MoveJoints.h testing/testMoveJoints.h +./StopRobot.h #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.h ) diff --git a/source/RobotAPI/statecharts/MotionControlGroup/MotionControlGroup.scgxml b/source/RobotAPI/statecharts/MotionControlGroup/MotionControlGroup.scgxml index a7c11afef..5bb6eae95 100644 --- a/source/RobotAPI/statecharts/MotionControlGroup/MotionControlGroup.scgxml +++ b/source/RobotAPI/statecharts/MotionControlGroup/MotionControlGroup.scgxml @@ -4,5 +4,6 @@ <State filename="testMoveJoints.xml"/> </Folder> <State filename="MoveJoints.xml" visibility="public"/> + <State filename="StopRobot.xml"/> </StatechartGroup> diff --git a/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.cpp b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.cpp new file mode 100644 index 000000000..d199bfbca --- /dev/null +++ b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.cpp @@ -0,0 +1,83 @@ +/* + * This file is part of ArmarX. + * + * ArmarX 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 of + * the License, or (at your option) any later version. + * + * ArmarX 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 General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::MotionControlGroup + * @author Manfred Kroehnert ( Manfred dot Kroehnert at kit dot edu ) + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#include "StopRobot.h" + +using namespace armarx; +using namespace MotionControlGroup; + +// DO NOT EDIT NEXT LINE +StopRobot::SubClassRegistry StopRobot::Registry(StopRobot::GetName(), &StopRobot::CreateInstance); + + + +StopRobot::StopRobot(XMLStateConstructorParams stateData) : + XMLStateTemplate < StopRobot > (stateData) +{ +} + +void StopRobot::onEnter() +{ + // put your user code for the enter-point here + // execution time should be short (<100ms) +} + +void StopRobot::run() +{ + // put your user code for the execution-phase here + // runs in seperate thread, thus can do complex operations + // should check constantly whether isRunningTaskStopped() returns true + + + while (!isRunningTaskStopped()) // stop run function if returning true + { + // do your calculations + } + +} + +void StopRobot::onBreak() +{ + // put your user code for the breaking point here + // execution time should be short (<100ms) +} + +void StopRobot::onExit() +{ + // put your user code for the exit point here + // execution time should be short (<100ms) + +} + +// DO NOT EDIT NEXT FUNCTION +std::string StopRobot::GetName() +{ + return "StopRobot"; +} + +// DO NOT EDIT NEXT FUNCTION +XMLStateFactoryBasePtr StopRobot::CreateInstance(XMLStateConstructorParams stateData) +{ + return XMLStateFactoryBasePtr(new StopRobot(stateData)); +} + diff --git a/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.h b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.h new file mode 100644 index 000000000..78bad7020 --- /dev/null +++ b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.h @@ -0,0 +1,58 @@ +/* + * This file is part of ArmarX. + * + * ArmarX 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 of + * the License, or (at your option) any later version. + * + * ArmarX 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 General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::MotionControlGroup + * @author Manfred Kroehnert ( Manfred dot Kroehnert at kit dot edu ) + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#ifndef _ARMARX_XMLUSERCODE_RobotAPI_MotionControlGroup_StopRobot_H +#define _ARMARX_XMLUSERCODE_RobotAPI_MotionControlGroup_StopRobot_H + +#include <Core/statechart/xmlstates/XMLState.h> + +namespace armarx +{ + namespace MotionControlGroup + { + class StopRobot : + virtual public XMLStateTemplate < StopRobot > , + public XMLStateFactoryBase + { + public: + StopRobot(XMLStateConstructorParams stateData); + + // inherited from StateBase + void onEnter(); + void run(); + void onBreak(); + void onExit(); + + // static functions for AbstractFactory Method + static std::string GetName(); + static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData); + static SubClassRegistry Registry; + + // DO NOT INSERT ANY CLASS MEMBERS, + // use stateparameters instead, + // if classmember are neccessary nonetheless, reset them in onEnter + }; + } +} + +#endif diff --git a/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.xml b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.xml new file mode 100644 index 000000000..4d6edb683 --- /dev/null +++ b/source/RobotAPI/statecharts/MotionControlGroup/StopRobot.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<State version="1.0" name="StopRobot" uuid="A88DB279-17A6-4776-A3C0-114B775609C9" width="800" height="600"> + <InputParameters/> + <OutputParameters/> + <LocalParameters/> + <Substates/> + <Events/> + <Transitions/> +</State> + -- GitLab