force_success_node.h
Go to the documentation of this file.
00001 /*  Copyright (C) 2018 Davide Faconti -  All Rights Reserved
00002 *
00003 *   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
00004 *   to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
00005 *   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
00006 *   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00007 *
00008 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00009 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00010 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00011 */
00012 
00013 #ifndef DECORATOR_ALWAYS_SUCCESS_NODE_H
00014 #define DECORATOR_ALWAYS_SUCCESS_NODE_H
00015 
00016 #include "behaviortree_cpp/decorator_node.h"
00017 
00018 namespace BT
00019 {
00020 class ForceSuccessDecorator : public DecoratorNode
00021 {
00022   public:
00023     ForceSuccessDecorator(const std::string& name) : DecoratorNode(name, NodeParameters())
00024     {
00025         setRegistrationName("ForceSuccess");
00026     }
00027 
00028   private:
00029     virtual BT::NodeStatus tick() override;
00030 };
00031 
00032 //------------ implementation ----------------------------
00033 
00034 inline NodeStatus ForceSuccessDecorator::tick()
00035 {
00036     setStatus(NodeStatus::RUNNING);
00037 
00038     const NodeStatus child_state = child_node_->executeTick();
00039 
00040     switch (child_state)
00041     {
00042         case NodeStatus::FAILURE:
00043         case NodeStatus::SUCCESS:
00044         {
00045             return NodeStatus::SUCCESS;
00046         }
00047 
00048         case NodeStatus::RUNNING:
00049         {
00050             return NodeStatus::RUNNING;
00051         }
00052 
00053         default:
00054         {
00055             // TODO throw?
00056         }
00057     }
00058     return status();
00059 }
00060 }
00061 
00062 #endif


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 03:50:10