Skip to content
Snippets Groups Projects
Commit 1dbc8494 authored by Tobias Gröger's avatar Tobias Gröger
Browse files

Add aron conversion

parent 65284dbe
No related branches found
No related tags found
2 merge requests!38human tracker skeleton,!28Draft: Dev -> Main
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
)
<?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>
#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
/**
* 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
/**
* 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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment