diff --git a/source/RobotAPI/components/skills/SkillProviderExample/CMakeLists.txt b/source/RobotAPI/components/skills/SkillProviderExample/CMakeLists.txt index b13f663e25b6c31fbb4ab3b919ce81431d617b70..56bfd4d8af2866f732345b2e65f8ab6ce6463fff 100644 --- a/source/RobotAPI/components/skills/SkillProviderExample/CMakeLists.txt +++ b/source/RobotAPI/components/skills/SkillProviderExample/CMakeLists.txt @@ -18,6 +18,7 @@ set(SOURCES Chaining.cpp Callback.cpp Timeout.cpp + Segfault.cpp ) set(HEADERS @@ -27,6 +28,7 @@ set(HEADERS Chaining.h Callback.h Timeout.h + Segfault.h ) armarx_add_component("${SOURCES}" "${HEADERS}") diff --git a/source/RobotAPI/components/skills/SkillProviderExample/Segfault.cpp b/source/RobotAPI/components/skills/SkillProviderExample/Segfault.cpp new file mode 100644 index 0000000000000000000000000000000000000000..324a6704843a93756fb748570cd806b4466af912 --- /dev/null +++ b/source/RobotAPI/components/skills/SkillProviderExample/Segfault.cpp @@ -0,0 +1,29 @@ + +#include "Segfault.h" + +namespace armarx::skills::provider +{ + SegfaultSkill::SegfaultSkill() : SimpleSkill(GetSkillDescription()) + { + } + + SkillDescription + SegfaultSkill::GetSkillDescription() + { + return SkillDescription{ + .skillId = skills::SkillID{.skillName = "Segfault"}, + .description = "This skill segfaults while executing. This will kill the Provider!", + .timeout = armarx::core::time::Duration::MilliSeconds(100)}; + } + + Skill::MainResult + SegfaultSkill::main(const MainInput& in) + { + int* number = nullptr; + (*number)++; + + ARMARX_IMPORTANT << "If you can read this in the log, something is really wrong with the " + "SegfaultSkill. It should have segfaulted by now..."; + return {TerminatedSkillStatus::Succeeded, nullptr}; + } +} // namespace armarx::skills::provider diff --git a/source/RobotAPI/components/skills/SkillProviderExample/Segfault.h b/source/RobotAPI/components/skills/SkillProviderExample/Segfault.h new file mode 100644 index 0000000000000000000000000000000000000000..75c5a81fe1ab744a9adf650a415a3c7f75f65f2b --- /dev/null +++ b/source/RobotAPI/components/skills/SkillProviderExample/Segfault.h @@ -0,0 +1,41 @@ + +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 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/>. + * + * @author Fabian Reister ( fabian dot reister at kit dot edu ) + * @date 2021 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + + +// RobotAPI +#include <RobotAPI/libraries/skills/provider/SimpleSkill.h> + +namespace armarx::skills::provider +{ + class SegfaultSkill : public SimpleSkill + { + public: + SegfaultSkill(); + + static SkillDescription GetSkillDescription(); + + private: + Skill::MainResult main(const MainInput&) final; + }; +} // namespace armarx::skills::provider diff --git a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp index 5ab480cd5c05556e2c7ea486ac0ec3976b1eb6df..7a5be5053e7b25b46629d5c5825abd28528b5652 100644 --- a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp +++ b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp @@ -57,6 +57,10 @@ namespace armarx::skills::provider // incomplete and prepare ARMARX_INFO << "Adding skill IncompleteSkill"; addSkillFactory<IncompleteSkill>(); + + // incomplete and prepare + ARMARX_INFO << "Adding skill SegfaultSkill"; + addSkillFactory<SegfaultSkill>(); } void diff --git a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.h b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.h index b8391b0881f625af03b00b601983251c4d90558b..be0c6b3704daafcbec412fd0b9dfd9690485e8f1 100644 --- a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.h +++ b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.h @@ -33,6 +33,7 @@ #include "Chaining.h" #include "HelloWorld.h" #include "Incomplete.h" +#include "Segfault.h" #include "Timeout.h" namespace armarx::skills::provider