@@ -18,9 +18,11 @@ InnerEigenAPI::InnerEigenAPI(DSR::DSRGraph *G_)
1818// //// TRANSFORMATION MATRIX
1919// //////////////////////////////////////////////////////////////////////////////////////
2020
21- std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix (const std::string &dest, const std::string &orig, std::uint64_t timestamp)
21+ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix (const std::string &dest, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
2222{
23- KeyTransform key = std::make_tuple (dest, orig);
23+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
24+ return {};
25+ KeyTransform key = std::make_tuple (dest, orig, edge_type);
2426 if ( auto it = cache.find (key) ; it != cache.end ())
2527 return it->second ;
2628 else
@@ -48,10 +50,10 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
4850 auto p_node = G->get_parent_node (a);
4951 if ( not p_node.has_value ())
5052 break ;
51- auto edge_rt = rt->get_edge_RT (p_node.value (), a.id ());
53+ auto edge_rt = rt->get_edge_RT (p_node.value (), a.id (), edge_type );
5254 if (not edge_rt.has_value ())
5355 {
54- qWarning () << __FUNCTION__ << " :" <<__LINE__<< " Cannot find RT edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
56+ qWarning () << __FUNCTION__ << " :" <<__LINE__<< " Cannot find " << QString::fromStdString (edge_type) << " edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
5557 return {};
5658 }
5759 if ( auto rtmat = rt->get_edge_RT_as_rtmat (edge_rt.value (), timestamp); rtmat.has_value ())
@@ -68,10 +70,10 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
6870 auto p_node = G->get_parent_node (b);
6971 if (not p_node.has_value ())
7072 break ;
71- auto edge_rt = rt->get_edge_RT (p_node.value (), b.id ());
73+ auto edge_rt = rt->get_edge_RT (p_node.value (), b.id (), edge_type );
7274 if (not edge_rt.has_value ())
7375 {
74- qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find RT edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
76+ qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find " << QString::fromStdString (edge_type) << " edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
7577 return {};
7678 }
7779 if ( auto rtmat = rt->get_edge_RT_as_rtmat (edge_rt.value (), timestamp); rtmat.has_value ())
@@ -91,16 +93,16 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
9193 if (p_node.has_value () and q_node.has_value ())
9294 {
9395 // qDebug() << "listas A&B" << p_node.value().id() << q_node.value().id();
94- auto a_edge_rt = rt->get_edge_RT (p_node.value (), a.id ());
96+ auto a_edge_rt = rt->get_edge_RT (p_node.value (), a.id (), edge_type );
9597 if (not a_edge_rt.has_value ())
9698 {
97- qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find RT edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
99+ qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find " << QString::fromStdString (edge_type) << " edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
98100 return {};
99101 }
100- auto b_edge_rt = rt->get_edge_RT (q_node.value (), b.id ());
102+ auto b_edge_rt = rt->get_edge_RT (q_node.value (), b.id (), edge_type );
101103 if (not b_edge_rt.has_value ())
102104 {
103- qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find RT edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
105+ qWarning () << __FUNCTION__ << " :" <<__LINE__ << " Cannot find " << QString::fromStdString (edge_type) << " edge between Parent (" << QString::fromStdString (p_node->name ()) << " , " << p_node->id () <<" ) and son (" << QString::fromStdString (a.name ()) << " , " << a.id () <<" ) nodes going from: " << QString::fromStdString (orig) << " to: " << QString::fromStdString (dest);
104106 return {};
105107 }
106108 auto a_rtmat = rt->get_edge_RT_as_rtmat (a_edge_rt.value (), timestamp);
@@ -133,9 +135,11 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
133135 }
134136}
135137
136- std::optional<Mat::Rot3D> InnerEigenAPI::get_rotation_matrix (const std::string &dest, const std::string &orig, std::uint64_t timestamp)
138+ std::optional<Mat::Rot3D> InnerEigenAPI::get_rotation_matrix (const std::string &dest, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
137139{
138- if ( auto r = get_transformation_matrix (dest, orig, timestamp); r.has_value ())
140+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
141+ return {};
142+ if ( auto r = get_transformation_matrix (dest, orig, timestamp, edge_type); r.has_value ())
139143 return r.value ().rotation ();
140144 else
141145 {
@@ -144,9 +148,11 @@ std::optional<Mat::Rot3D> InnerEigenAPI::get_rotation_matrix(const std::string &
144148 }
145149}
146150
147- std::optional<Mat::Vector3d> InnerEigenAPI::get_translation_vector (const std::string &dest, const std::string &orig, std::uint64_t timestamp)
151+ std::optional<Mat::Vector3d> InnerEigenAPI::get_translation_vector (const std::string &dest, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
148152{
149- if (auto r = get_transformation_matrix (dest, orig, timestamp); r.has_value ())
153+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
154+ return {};
155+ if (auto r = get_transformation_matrix (dest, orig, timestamp, edge_type); r.has_value ())
150156 return r.value ().translation ();
151157 else
152158 {
@@ -155,9 +161,11 @@ std::optional<Mat::Vector3d> InnerEigenAPI::get_translation_vector(const std::st
155161 return {};
156162 }
157163}
158- std::optional<Mat::Vector3d> InnerEigenAPI::get_euler_xyz_angles (const std::string &dest, const std::string &orig, std::uint64_t timestamp)
164+ std::optional<Mat::Vector3d> InnerEigenAPI::get_euler_xyz_angles (const std::string &dest, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
159165{
160- if ( auto r = get_transformation_matrix (dest, orig, timestamp); r.has_value ())
166+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
167+ return {};
168+ if ( auto r = get_transformation_matrix (dest, orig, timestamp, edge_type); r.has_value ())
161169 return r.value ().rotation ().eulerAngles (0 ,1 ,2 ); // X Y Z order
162170 else
163171 {
@@ -169,10 +177,12 @@ std::optional<Mat::Vector3d> InnerEigenAPI::get_euler_xyz_angles(const std::stri
169177// //////////////////////////////////////////////////////////////////////////////////////
170178// //// TRANSFORM
171179// //////////////////////////////////////////////////////////////////////////////////////
172- std::optional<Mat::Vector3d> InnerEigenAPI::transform (const std::string &dest, const Mat::Vector3d &vector, const std::string &orig, std::uint64_t timestamp)
180+ std::optional<Mat::Vector3d> InnerEigenAPI::transform (const std::string &dest, const Mat::Vector3d &vector, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
173181{
182+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
183+ return {};
174184 // std::cout <<__FUNCTION__ << " " << initVec << std::endl;
175- auto tm = get_transformation_matrix (dest, orig, timestamp);
185+ auto tm = get_transformation_matrix (dest, orig, timestamp, edge_type );
176186 // std::cout << __FUNCTION__ << " " << tm.value().matrix().format(CleanFmt) << std::endl;
177187 if (tm.has_value ())
178188 {
@@ -183,14 +193,18 @@ std::optional<Mat::Vector3d> InnerEigenAPI::transform(const std::string &dest, c
183193 return {};
184194}
185195
186- std::optional<Mat::Vector3d> InnerEigenAPI::transform ( const std::string &dest, const std::string & orig, std::uint64_t timestamp)
196+ std::optional<Mat::Vector3d> InnerEigenAPI::transform ( const std::string &dest, const std::string & orig, std::uint64_t timestamp, const std::string &edge_type )
187197 {
188- return transform (dest, Mat::Vector3d (0 .,0 .,0 .), orig, timestamp);
198+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
199+ return {};
200+ return transform (dest, Mat::Vector3d (0 .,0 .,0 .), orig, timestamp, edge_type);
189201 }
190202
191- std::optional<Mat::Vector6d> InnerEigenAPI::transform_axis (const std::string &dest, const Mat::Vector6d &vector, const std::string &orig, std::uint64_t timestamp)
203+ std::optional<Mat::Vector6d> InnerEigenAPI::transform_axis (const std::string &dest, const Mat::Vector6d &vector, const std::string &orig, std::uint64_t timestamp, const std::string &edge_type )
192204{
193- auto tm = get_transformation_matrix (dest, orig, timestamp);
205+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
206+ return {};
207+ auto tm = get_transformation_matrix (dest, orig, timestamp, edge_type);
194208 if (tm.has_value ())
195209 {
196210 const Mat::RTMat rtmat = tm.value ();
@@ -208,9 +222,12 @@ std::optional<Mat::Vector6d> InnerEigenAPI::transform_axis(const std::string &de
208222 return {};
209223 }
210224
211- std::optional<Mat::Vector6d> InnerEigenAPI::transform_axis ( const std::string &dest, const std::string & orig, std::uint64_t timestamp)
225+ std::optional<Mat::Vector6d> InnerEigenAPI::transform_axis ( const std::string &dest, const std::string & orig, std::uint64_t timestamp, const std::string &edge_type )
212226{
213- return transform_axis (dest, Mat::Vector6d::Zero (), orig, timestamp);
227+ if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
228+ return {};
229+ Mat::Vector6d v;
230+ return transform_axis (dest, Mat::Vector6d::Zero (), orig, timestamp, edge_type);
214231}
215232
216233// //////////////////////////////////////////////////////////////////////
@@ -356,4 +373,4 @@ void InnerEigenAPI::remove_cache_entry(uint64_t id)
356373// cache[key] = ret;
357374// }
358375// return ret;
359- // }
376+ // }
0 commit comments