diff --git a/source/RobotAPI/components/ArViz/CMakeLists.txt b/source/RobotAPI/components/ArViz/CMakeLists.txt index d79d9a4ba4e3ee75d0860328997112e864c008d3..23bc568751839f9758cd09597b2b4f58b8b5e419 100644 --- a/source/RobotAPI/components/ArViz/CMakeLists.txt +++ b/source/RobotAPI/components/ArViz/CMakeLists.txt @@ -16,6 +16,7 @@ set(SOURCES Client/elements/Robot.cpp Client/elements/RobotHand.cpp Client/drawer/ArVizDrawerBase.cpp + Client/ScopedClient.cpp Coin/ElementVisualizer.cpp @@ -65,6 +66,7 @@ set(HEADERS Client/Layer.h Client/Elements.h Client/Client.h + Client/ScopedClient.h Client/ClientCGALExtensions.h Client/Color.h diff --git a/source/RobotAPI/components/ArViz/Client/Client.h b/source/RobotAPI/components/ArViz/Client/Client.h index cc8e7289a57f4302b65fae48574d04f8931d4bc5..71e4197cc71b0ec094ecec84b47a4e35f0a3854a 100644 --- a/source/RobotAPI/components/ArViz/Client/Client.h +++ b/source/RobotAPI/components/ArViz/Client/Client.h @@ -51,7 +51,7 @@ namespace armarx::viz // ////////////////////////////////////////////////////////////////// // //layer - Layer layer(std::string const& name) const + virtual Layer layer(std::string const& name) const { return Layer(componentName, name); } diff --git a/source/RobotAPI/components/ArViz/Client/Elements.h b/source/RobotAPI/components/ArViz/Client/Elements.h index 297a22469d52be8b7cda3c71438f6ee0617c0091..66f07992e0ba2dc0c382b3a9742a5413c9f192b6 100644 --- a/source/RobotAPI/components/ArViz/Client/Elements.h +++ b/source/RobotAPI/components/ArViz/Client/Elements.h @@ -122,6 +122,13 @@ namespace armarx::viz ) : Box(name, b) {} + + Box(std::string const& id) + : ElementOps(id) + { + pose(Eigen::Matrix4f::Identity()); + } + }; diff --git a/source/RobotAPI/components/ArViz/Client/ScopedClient.cpp b/source/RobotAPI/components/ArViz/Client/ScopedClient.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e968ca7dd19298ac9eff6080370edb73a5138ca --- /dev/null +++ b/source/RobotAPI/components/ArViz/Client/ScopedClient.cpp @@ -0,0 +1,43 @@ +/* + * 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 + */ + + +#include "ScopedClient.h" + +namespace armarx::viz +{ + + Layer ScopedClient::layer(std::string const& name) const + { + layers.insert(name); + + return Client::layer(name); + } + + ScopedClient::~ScopedClient() + { + for (const auto& layer : layers) + { + Client::commitDeleteLayer(layer); + } + } + +} // namespace armarx::viz diff --git a/source/RobotAPI/components/ArViz/Client/ScopedClient.h b/source/RobotAPI/components/ArViz/Client/ScopedClient.h new file mode 100644 index 0000000000000000000000000000000000000000..23271b5ba6de545b183728ba04fdaa86f7938e0a --- /dev/null +++ b/source/RobotAPI/components/ArViz/Client/ScopedClient.h @@ -0,0 +1,52 @@ +/* + * 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 + */ + +#include <set> + +#include "Client.h" + +namespace armarx::viz +{ + /** + * @brief `viz::Client` that will delete (clear) committed layers when destroyed. + * + * Note that, as a consequence, a network call be performed in the destructor. + * + * This might be useful if you have a class `MyTask` perform visualizing while performing some task, + * but whose visualization should be removed when the task finished. + * In this case, `MyTask` can have a `viz::ScopedClient` (which can be created from a regular `viz::Client`). + * When destructing the instance of `MyTask`, all visualization done by `MyTask` will be cleared + * (as `viz::ScopedClient` will go out of scope as well). + * + */ + class ScopedClient: virtual public Client + { + public: + using Client::Client; + + Layer layer(std::string const& name) const override; + + virtual ~ScopedClient(); + + private: + mutable std::set<std::string> layers; + }; +} // namespace armarx::viz \ No newline at end of file diff --git a/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.cpp b/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.cpp index 456671e79cc764fc577121082967fcc52e341361..4fcd3e452040b179aa92e8a3928d32d05abaaf60 100644 --- a/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.cpp +++ b/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.cpp @@ -57,7 +57,7 @@ namespace armarx controller->activateController(); } - void VelocityControllerHelper::setTargetVelocity(const Eigen::VectorXf& cv) + void VelocityControllerHelper::setTargetVelocity(const Eigen::Vector6f& cv) { controller->setTargetVelocity(cv(0), cv(1), cv(2), cv(3), cv(4), cv(5)); } diff --git a/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.h b/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.h index c93de51afea1f663deda3e5f458cfe9f65acf8d7..ab47ffaccc480f999f214df3f5dbb908549f1ad7 100644 --- a/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.h +++ b/source/RobotAPI/libraries/RobotStatechartHelpers/VelocityControllerHelper.h @@ -43,7 +43,7 @@ namespace armarx void init(); - void setTargetVelocity(const Eigen::VectorXf& cv); + void setTargetVelocity(const Eigen::Vector6f& cv); void setNullSpaceControl(bool enabled); diff --git a/source/RobotAPI/libraries/armem/util/util.h b/source/RobotAPI/libraries/armem/util/util.h index 44a32b8317022bbcee867413de19b6f6688a853b..16da9f1709528dc7b9c7d484be494a2f1e6da851 100644 --- a/source/RobotAPI/libraries/armem/util/util.h +++ b/source/RobotAPI/libraries/armem/util/util.h @@ -21,10 +21,11 @@ #pragma once -#include "ArmarXCore/core/logging/Logging.h" #include <vector> #include <optional> +#include "ArmarXCore/core/logging/Logging.h" + #include <RobotAPI/libraries/armem/core/workingmemory/Entity.h> #include <RobotAPI/libraries/armem/core/workingmemory/EntityInstance.h> #include <RobotAPI/libraries/aron/core/codegenerator/codeWriter/cpp/AronCppClass.h> diff --git a/source/RobotAPI/libraries/core/CartesianVelocityControllerWithRamp.h b/source/RobotAPI/libraries/core/CartesianVelocityControllerWithRamp.h index ff1ff84535fad72d2fd3ef06e3adda8b7c9d08ba..1a73b84900971b6cafe810bedd219998362a29a4 100644 --- a/source/RobotAPI/libraries/core/CartesianVelocityControllerWithRamp.h +++ b/source/RobotAPI/libraries/core/CartesianVelocityControllerWithRamp.h @@ -49,7 +49,7 @@ namespace armarx CartesianVelocityControllerWithRamp(CartesianVelocityControllerWithRamp&&) = default; CartesianVelocityControllerWithRamp& operator=(CartesianVelocityControllerWithRamp&&) = default; - [[deprecated("compued null space velocity does not match pseudo inverse svd method in simox. never use this function.")]] + [[deprecated("computed null space velocity does not match pseudo inverse svd method in simox. never use this function.")]] void setCurrentJointVelocity(const Eigen::Ref<const Eigen::VectorXf>& currentJointVelocity); void switchMode(const Eigen::VectorXf& currentJointVelocity, VirtualRobot::IKSolver::CartesianSelection mode);