diff --git a/source/armarx/navigation/human/CMakeLists.txt b/source/armarx/navigation/human/CMakeLists.txt index c173b5914f61fec0d9510b0d69df06afb78868a9..670c1869ff8ed165640cba1d5d49cbc57faf14ea 100644 --- a/source/armarx/navigation/human/CMakeLists.txt +++ b/source/armarx/navigation/human/CMakeLists.txt @@ -1,14 +1,20 @@ armarx_add_aron_library(human_aron ARON_FILES + aron/Human.xml ) armarx_add_library(human DEPENDENCIES_PUBLIC ArmarXCore armarx_navigation::core + armarx_navigation::conversions DEPENDENCIES_PRIVATE + range-v3::range-v3 SOURCES - #types.cpp + types.cpp + aron_conversions.cpp HEADERS types.h + aron_conversions.h + shapes.h ) diff --git a/source/armarx/navigation/human/aron/Human.xml b/source/armarx/navigation/human/aron/Human.xml new file mode 100644 index 0000000000000000000000000000000000000000..57d104d858b8b346531c61b73069aba168ce374d --- /dev/null +++ b/source/armarx/navigation/human/aron/Human.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <GenerateTypes> + + <Object name='armarx::navigation::human::arondto::Human'> + <ObjectChild key='pose'> + <Pose /> + </ObjectChild> + <ObjectChild key='linearVelocity'> + <Position /> + </ObjectChild> + <ObjectChild key='detectionTime'> + <Time /> + </ObjectChild> + </Object> + + <Object name='armarx::navigation::human::arondto::HumanGroup'> + <ObjectChild key='shape'> + <List> + <Position /> + </List> + </ObjectChild> + <ObjectChild key='humans'> + <List> + <armarx::navigation::human::arondto::Human /> + </List> + </ObjectChild> + <ObjectChild key='detectionTime'> + <Time /> + </ObjectChild> + </Object> + + </GenerateTypes> +</AronTypeDefinition> diff --git a/source/armarx/navigation/human/aron_conversions.cpp b/source/armarx/navigation/human/aron_conversions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e09a3ca376d5f75790c8adada1038e627c968161 --- /dev/null +++ b/source/armarx/navigation/human/aron_conversions.cpp @@ -0,0 +1,69 @@ +#include "aron_conversions.h" + +#include <armarx/navigation/conversions/eigen.h> +#include <armarx/navigation/human/aron/Human.aron.generated.h> +#include <armarx/navigation/human/types.h> +#include <range/v3/range/conversion.hpp> +#include <range/v3/view/transform.hpp> + +namespace armarx::navigation::human +{ + void + toAron(arondto::Human& dto, const Human& bo) + { + dto.pose = conv::to3D(bo.pose).matrix(); + dto.linearVelocity = conv::to3D(bo.linearVelocity); + dto.detectionTime = bo.detectionTime; + } + + void + fromAron(const arondto::Human& dto, Human& bo) + { + bo.pose = conv::to2D(core::Pose(dto.pose)); + bo.linearVelocity = conv::to2D(dto.linearVelocity); + bo.detectionTime = dto.detectionTime; + } + + + void + toAron(arondto::HumanGroup& dto, const HumanGroup& bo) + { + dto.shape = bo.shape.vertices | + ranges::views::transform([](const Eigen::Vector2f& boVer) -> Eigen::Vector3f + { return conv::to3D(boVer); }) | + ranges::to_vector; + + dto.humans = bo.humans | + ranges::views::transform( + [](const Human& boHuman) -> arondto::Human + { + arondto::Human dtoHuman; + toAron(dtoHuman, boHuman); + return dtoHuman; + }) | + ranges::to_vector; + dto.detectionTime = bo.detectionTime; + } + + void + fromAron(const arondto::HumanGroup& dto, HumanGroup& bo) + { + bo.shape.vertices = + dto.shape | + ranges::views::transform([](const Eigen::Vector3f& dtoVer) -> Eigen::Vector2f + { return conv::to2D(dtoVer); }) | + ranges::to_vector; + + bo.humans = dto.humans | + ranges::views::transform( + [](const arondto::Human& dtoHuman) -> Human + { + Human boHuman; + fromAron(dtoHuman, boHuman); + return boHuman; + }) | + ranges::to_vector; + bo.detectionTime = dto.detectionTime; + } + +} // namespace armarx::navigation::human diff --git a/source/armarx/navigation/human/aron_conversions.h b/source/armarx/navigation/human/aron_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..71159748a75ed5d44312650a530c80cc2e25e1ab --- /dev/null +++ b/source/armarx/navigation/human/aron_conversions.h @@ -0,0 +1,46 @@ +/** + * 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 Tobias Gröger ( tobias dot groeger at student dot kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +namespace armarx::navigation::human +{ + struct Human; + struct HumanGroup; + + namespace arondto + { + struct Human; + struct HumanGroup; + + } // namespace arondto + +} // namespace armarx::navigation::human + +namespace armarx::navigation::human +{ + void toAron(arondto::Human& dto, const Human& bo); + void fromAron(const arondto::Human& dto, Human& bo); + + void toAron(arondto::HumanGroup& dto, const HumanGroup& bo); + void fromAron(const arondto::HumanGroup& dto, HumanGroup& bo); + +} // namespace armarx::navigation::human diff --git a/source/armarx/navigation/human/shapes.h b/source/armarx/navigation/human/shapes.h new file mode 100644 index 0000000000000000000000000000000000000000..f6fd25a5156684648c7abf4139ebe04f27188a32 --- /dev/null +++ b/source/armarx/navigation/human/shapes.h @@ -0,0 +1,48 @@ +/** + * 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 Tobias Gröger ( tobias dot groeger at student dot kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <SimoxUtility/shapes.h> + +#include <armarx/navigation/core/basic_types.h> + +namespace armarx::navigation::human::shapes +{ + + /** + * @brief An axis oriented ellipse with half-axes a and b along the x- and y-axis respectively. + */ + struct Ellipse + { + float a; + float b; + }; + + /** + * @brief A polygon with arbitrarily many vertices. The polygon will always be closed automatically. + */ + struct Polygon + { + std::vector<Eigen::Vector2f> vertices; + }; + +} // namespace armarx::navigation::human::shapes diff --git a/source/armarx/navigation/human/types.h b/source/armarx/navigation/human/types.h index 867849a18f9a1c542f9cbd9f6caa9b5f6b9e56ae..6b66e7c6eda19641d632a278ae886458fee24e15 100644 --- a/source/armarx/navigation/human/types.h +++ b/source/armarx/navigation/human/types.h @@ -24,6 +24,7 @@ #include <ArmarXCore/core/time.h> #include <armarx/navigation/core/basic_types.h> +#include <armarx/navigation/human/shapes.h> namespace armarx::navigation::human { @@ -38,7 +39,7 @@ namespace armarx::navigation::human struct HumanGroup { - std::vector<Eigen::Vector2f> vertices; + shapes::Polygon shape; std::vector<Human> humans; DateTime detectionTime; }; @@ -46,6 +47,7 @@ namespace armarx::navigation::human struct ProxemicZone { core::Pose2D pose; + shapes::Ellipse shape; }; } // namespace armarx::navigation::human