conversions.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <memory>
4
#include <optional>
5
#include <ostream>
6
7
#include <Eigen/Core>
8
9
#include <
ArmarXCore/util/CPPUtility/trace.h
>
10
11
namespace
armarx::core::eigen
12
{
13
// optional
14
template
<
class
EigenT,
int
rows,
int
cols>
15
std::optional<Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>>&
16
assign
(std::optional<
Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>
>& lh,
17
const
std::optional<
Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>
>& rh)
18
{
19
ARMARX_TRACE
;
20
if
(rh.has_value())
21
{
22
lh.emplace(rh.value());
23
}
24
else
25
{
26
lh = std::nullopt;
27
}
28
return
lh;
29
}
30
31
template
<
class
EigenT,
int
rows,
int
cols>
32
std::optional<Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>>&
33
assign
(std::optional<
Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>
>& lh,
34
const
std::optional<
Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>
>& rh)
35
{
36
ARMARX_TRACE
;
37
if
(rh.has_value())
38
{
39
lh.emplace(rh.value());
40
}
41
else
42
{
43
lh = std::nullopt;
44
}
45
return
lh;
46
}
47
48
// shared_ptr
49
template
<
class
EigenT,
int
rows,
int
cols>
50
std::shared_ptr<Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>>&
51
assign
(std::shared_ptr<
Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>
>& lh,
52
const
std::shared_ptr<
Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>
>& rh)
53
{
54
ARMARX_TRACE
;
55
if
(rh)
56
{
57
lh = std::make_shared<Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>>(*rh);
58
}
59
else
60
{
61
lh =
nullptr
;
62
}
63
return
lh;
64
}
65
66
template
<
class
EigenT,
int
rows,
int
cols>
67
std::shared_ptr<Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>>&
68
assign
(std::shared_ptr<
Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>
>& lh,
69
const
std::shared_ptr<
Eigen::Matrix<EigenT, rows, cols, Eigen::ColMajor>
>& rh)
70
{
71
ARMARX_TRACE
;
72
if
(rh)
73
{
74
lh = std::make_shared<Eigen::Matrix<EigenT, rows, cols, Eigen::RowMajor>>(*rh);
75
}
76
else
77
{
78
lh =
nullptr
;
79
}
80
return
lh;
81
}
82
}
// namespace armarx::core::eigen
83
84
namespace
armarx
85
{
86
using
armarx::core::eigen::assign
;
87
}
armarx::core::eigen
Definition:
conversions.cpp:3
trace.h
ARMARX_TRACE
#define ARMARX_TRACE
Definition:
trace.h:77
Eigen::Matrix
Definition:
EigenForwardDeclarations.h:27
armarx::core::eigen::assign
std::optional< Eigen::Matrix< EigenT, rows, cols, Eigen::ColMajor > > & assign(std::optional< Eigen::Matrix< EigenT, rows, cols, Eigen::ColMajor >> &lh, const std::optional< Eigen::Matrix< EigenT, rows, cols, Eigen::RowMajor >> &rh)
Definition:
conversions.h:16
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:27
ArmarXCore
core
eigen
conversions.h
Generated on Sat Mar 29 2025 09:17:21 for armarx_documentation by
1.8.17