Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D fuse models #354

Open
wants to merge 123 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
6878097
humble branch
andreaostuni Jul 21, 2023
edb7d60
make composable optimizer nodes (dev)
giafranchini Aug 4, 2023
504a1c6
batch and fixed lag optimizer as components
giafranchini Aug 7, 2023
699b9d1
optimizer components refactor
giafranchini Aug 23, 2023
ce960ad
undo optimizer.cpp changes
giafranchini Aug 23, 2023
dce95d2
set precision 1e-4 to validatePartialMeasurement
giafranchini Sep 25, 2023
f33bc5d
new branch iron_unicycle3d
giafranchini Oct 5, 2023
ddd06c2
odometry 3d development
giafranchini Nov 3, 2023
9927ad0
add normal_prior_pose_3d
giafranchini Nov 3, 2023
5a3df7b
odometry 3d with partial measurements development
giafranchini Nov 6, 2023
c065595
clean up: removed euler constraints
giafranchini Nov 8, 2023
38cae76
3D pose absolute and relative constraints with partial measure support
giafranchini Nov 8, 2023
5f037ce
clean up: removed euler constraints plugin from cmake
giafranchini Nov 8, 2023
d846fff
Add support partial measurements for odometry 3D
giafranchini Nov 8, 2023
052be96
imu 3D plugin dev
giafranchini Nov 8, 2023
ac1a0f8
fix missing type() template specialization for vel 3d
giafranchini Nov 14, 2023
c516176
add support for partial measurements in absolute_orientation_3d_stamp…
giafranchini Nov 15, 2023
16f4c53
fix: missing tf_timeout param
giafranchini Nov 15, 2023
5d4dd92
removed euler constraint headers
giafranchini Nov 15, 2023
0c63c45
fix: wrong array mapping in unicycle 3d motion model + tests
giafranchini Nov 15, 2023
3fb62bd
Update README.md
giafranchini Nov 20, 2023
10c0065
Update typo in fuse_constraints/fuse_plugins.xml
giafranchini Nov 20, 2023
df856ca
Update typo in fuse_constraints/fuse_plugins.xml
giafranchini Nov 20, 2023
92a3a69
Update typo in fuse_constraints/fuse_plugins.xml
giafranchini Nov 20, 2023
3fac148
Update typo in fuse_constraints/fuse_plugins.xml
giafranchini Nov 20, 2023
211e0eb
Update fuse_constraints/fuse_plugins.xml
giafranchini Nov 20, 2023
89656fb
Update copyright fuse_constraints/include/fuse_constraints/normal_pri…
giafranchini Nov 20, 2023
486336b
Fix: removed double new line
giafranchini Nov 20, 2023
a09db78
Update copyright in fuse_constraints/src/normal_prior_pose_3d.cpp
giafranchini Nov 20, 2023
f6e78fb
Cleaning is_angular_3d method in sensor config
giafranchini Nov 20, 2023
c6a0daf
Revert "Cleaning is_angular_3d method in sensor config"
giafranchini Nov 21, 2023
c1b1ede
Fix: delta orientation cost function residuals static map
giafranchini Nov 28, 2023
ae84092
Add independent param for pose delta
giafranchini Nov 28, 2023
1072fe4
Add test absolute pose 3d stamped constraint
giafranchini Nov 28, 2023
55280dc
unicycle 3d predict refactor + test
giafranchini Nov 28, 2023
d3e3c36
unicycle 3d cost functor refactor + test
giafranchini Nov 28, 2023
c44aa4e
different handling for orient/vel variables in sensor config
giafranchini Nov 28, 2023
569d8ff
remove TODOs
giafranchini Nov 28, 2023
bd30458
abs and diff pose handling
giafranchini Nov 28, 2023
04a984d
unicycle 3d tests + minor fixes
giafranchini Dec 5, 2023
e85eaa2
feature: quat2eul + jacobian
giafranchini Dec 14, 2023
ba5217d
feature: unicycle 3d analytical derivatives
giafranchini Dec 14, 2023
4f7dff8
refactor: jacobian computation in predict function with eigen
giafranchini Dec 14, 2023
3959d76
feature: odometry_3d_publisher predict to current time
giafranchini Dec 14, 2023
49d12a9
feature: quat2rpy and quat product jacobian
giafranchini Dec 20, 2023
5aa23b0
feature: add normal_prior_pose_3d
giafranchini Dec 20, 2023
0ae0f4c
process only orientation for imu3d
giafranchini Dec 20, 2023
7a8cde8
feature: add normal_prior_orientation_3d
giafranchini Dec 20, 2023
00ecb7e
fix: normal prior pose jacobian maps
giafranchini Dec 20, 2023
e9f1aa4
dev: sensor_proc refactor
giafranchini Dec 28, 2023
017242a
fix: typo in quat2rpy + tests
giafranchini Jan 2, 2024
436652d
chore: cost_function_gtest support for quaternions
giafranchini Jan 2, 2024
336b974
Merge branch 'iron_unicycle3d' into refactor/sensor_proc
giafranchini Jan 3, 2024
186a6e1
Merge pull request #13 from giafranchini/refactor/sensor_proc
giafranchini Jan 3, 2024
7f9bb01
refactor: relative_pose_3d fixed size
giafranchini Jan 4, 2024
60a8363
feature: relative_pose_3d_euler constraint
giafranchini Jan 4, 2024
b2058a8
refactor: sensor_proc + models relative pose update
giafranchini Jan 4, 2024
7191974
Fix: wrong fixed size sqrt_info in relatie euler cost functor + test
giafranchini Jan 5, 2024
3d78b1a
sensor_proc_3d tests
giafranchini Jan 8, 2024
d710b35
fix: wrong expected value in test absolutePose3DStampedEulerConstraint
giafranchini Jan 10, 2024
22190e8
Fix: imu3D getPositiveParam account for params namespace
giafranchini Jan 10, 2024
ff3ecff
fix tf2 conversion
giafranchini Jan 10, 2024
5a33b9f
Removed completed TODOs
giafranchini Jan 10, 2024
e7c74ce
Merge pull request #15 from giafranchini/refactor/relative_pose_proce…
giafranchini Jan 10, 2024
a7abf32
removed covariance_geometry dep from fuse_constraints
giafranchini Jan 11, 2024
3a8a14c
add missing absolute constraints and cleanup
giafranchini Jan 11, 2024
9014320
absolute orientation 3d cleanup
giafranchini Jan 11, 2024
c50296a
absolute pose 3d & 3d euler cleanup
giafranchini Jan 11, 2024
727afd1
delta pose/orientation cost functor cleanup
giafranchini Jan 11, 2024
656d306
Update normal_delta_pose_3d_cost_functor.hpp
giafranchini Jan 11, 2024
339952f
normal prior orientation 3d cleanup
giafranchini Jan 11, 2024
34ecebb
normal prior orientation 3d cost functor cleanup
giafranchini Jan 11, 2024
99c1055
normal prior pose 3d cost functor cleanup
giafranchini Jan 11, 2024
ac54c93
normal prior pose 3d euler cost functor/function cleanup
giafranchini Jan 11, 2024
0e930cd
relative pose 3d constraint cleanup
giafranchini Jan 11, 2024
7073ae7
normal prior pose 3d cost function cleanup
giafranchini Jan 11, 2024
4b554da
fuse_constraints tests cleanup
giafranchini Jan 11, 2024
666d6bc
removed fuse_core::Quaternion alias
giafranchini Jan 11, 2024
73d9178
sensor_proc cleanup
giafranchini Jan 11, 2024
23d5773
unicycle2D cleanup
giafranchini Jan 11, 2024
1353917
unicycle2d state kinematic constraint cleanup
giafranchini Jan 11, 2024
e66dadb
3d models cleanup
giafranchini Jan 11, 2024
b104d77
Update optimizer.hpp
giafranchini Jan 11, 2024
7a2a338
Update test_sensor_proc.cpp
giafranchini Jan 11, 2024
4366749
removed utils.py
giafranchini Jan 11, 2024
34a3ab3
fuse optimizers cleanup
giafranchini Jan 11, 2024
235bd94
range_sensor_tutorial launch file cleanup
giafranchini Jan 11, 2024
238b7d4
Update range_sensor_tutorial.launch.py
giafranchini Jan 11, 2024
0515c90
orientation_3d variable cleanup
giafranchini Jan 11, 2024
72ff6a9
rename unicycle3d to omnidirectional3d
giafranchini Jan 11, 2024
40f7645
Merge pull request #16 from giafranchini/iron-omni3d
giafranchini Jan 11, 2024
ae23ab8
Merge pull request #17 from giafranchini/iron_models3d
giafranchini Jan 16, 2024
4ee3981
update fuse.repos
giafranchini Jan 16, 2024
ca7e435
feature: covariance variation check in processDifferentialPose3DWithC…
giafranchini Jan 29, 2024
3b36fe4
add some comments in sensor_proc
giafranchini Feb 1, 2024
228dbd6
Merge pull request #19 from giafranchini/feature-covariance-check
giafranchini Feb 1, 2024
0b44b7a
revert composable optimizer
giafranchini Mar 11, 2024
88204cd
Update fuse_core/include/fuse_core/util.hpp
giafranchini Mar 11, 2024
0878114
Update fuse_core/include/fuse_core/util.hpp
giafranchini Mar 11, 2024
ee059b6
Tests for quat2rpy - quat product - quat2angleaxis jacobians
giafranchini Mar 11, 2024
69344a1
Remove comments in absolute_pose_3d_stamped_constraint.cpp
giafranchini Mar 11, 2024
8a5b97c
Add TODOs normal_prior_pose_3d.cpp
giafranchini Mar 11, 2024
a8c4d7b
Add TODO to normal_prior_orientation_3d.cpp
giafranchini Mar 11, 2024
cba0a03
Add single jacobian check in normal_prior_orientation_3d
giafranchini Mar 11, 2024
90ded4b
Formalize comparisons in quaternion2rpy
giafranchini Mar 11, 2024
0376050
Update fuse_models/include/fuse_models/omnidirectional_3d.hpp
giafranchini Sep 25, 2024
05bc6a3
Update fuse_models/include/fuse_models/omnidirectional_3d.hpp
giafranchini Sep 25, 2024
e729204
Update fuse_models/include/fuse_models/omnidirectional_3d.hpp
giafranchini Sep 25, 2024
80aec70
Update fuse_models/include/fuse_models/omnidirectional_3d.hpp
giafranchini Sep 25, 2024
d26d91f
fix typos
giafranchini Sep 25, 2024
4689930
fix typo: quat instead of rpy
giafranchini Sep 25, 2024
05a35c2
Fix wrong stride in linear acceleration covariance eigen map
giafranchini Sep 26, 2024
0e64676
fix omnidirectional_3d_ignition orientation init + tests
giafranchini Oct 3, 2024
7475196
add 3D tutorial (#27)
henrygerardmoore Oct 3, 2024
ec62d42
Fix wrong quaternion2angleaxis jacobian + test
giafranchini Oct 3, 2024
491fda4
remove summary print
giafranchini Oct 17, 2024
e27f6f8
Port support for Ceres 2.1.0 Manifold class into ROS 2 Rolling (#366)
svwilliams Apr 20, 2024
b21c169
uncrustify
giafranchini Oct 22, 2024
43c5833
test quaternionToAngleAxis for very small rotations
giafranchini Oct 22, 2024
1dbd922
Merge branch 'rolling' into models_3d
giafranchini Oct 22, 2024
1383744
fix typo omnidirectional_3d
giafranchini Oct 29, 2024
568decf
Missing support for Ceres 2.1.0 Manifold in pose_3d constraint tests
giafranchini Nov 2, 2024
720eaf0
add optional tolerance in ExpectCostFunctionsAreEqual
giafranchini Nov 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fuse.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repositories:
locusrobotics/tf2_2d:
type: git
url: https://github.com/locusrobotics/tf2_2d.git
version: rolling
covariance_geometry_ros:
type: git
url: https://github.com/giafranchini/covariance_geometry_ros.git
version: iron
5 changes: 5 additions & 0 deletions fuse_constraints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ add_library(${PROJECT_NAME}
src/absolute_orientation_3d_stamped_euler_constraint.cpp
src/absolute_pose_2d_stamped_constraint.cpp
src/absolute_pose_3d_stamped_constraint.cpp
src/absolute_pose_3d_stamped_euler_constraint.cpp
src/marginal_constraint.cpp
src/marginal_cost_function.cpp
src/marginalize_variables.cpp
src/normal_delta.cpp
src/normal_delta_orientation_2d.cpp
src/normal_delta_pose_2d.cpp
src/normal_prior_orientation_2d.cpp
src/normal_prior_orientation_3d.cpp
src/normal_prior_pose_2d.cpp
src/normal_prior_pose_3d.cpp
src/normal_prior_pose_3d_euler.cpp
src/relative_constraint.cpp
src/relative_orientation_3d_stamped_constraint.cpp
src/relative_pose_2d_stamped_constraint.cpp
src/relative_pose_3d_stamped_constraint.cpp
src/relative_pose_3d_stamped_euler_constraint.cpp
src/uuid_ordering.cpp
src/variable_constraints.cpp
)
Expand Down
35 changes: 35 additions & 0 deletions fuse_constraints/fuse_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
the 2D angular acceleration.
</description>
</class>
<class type="fuse_constraints::AbsoluteAccelerationAngular3DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D angular acceleration, or a direct measurement of
the 3D angular acceleration.
</description>
</class>
<class type="fuse_constraints::AbsoluteAccelerationLinear2DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 2D linear acceleration, or a direct measurement of
the 2D linear acceleration.
</description>
</class>
<class type="fuse_constraints::AbsoluteAccelerationLinear3DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D linear acceleration, or a direct measurement of
the 3D linear acceleration.
</description>
</class>
<class type="fuse_constraints::AbsoluteOrientation2DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 2D orientation, or a direct measurement of the
Expand All @@ -35,12 +47,24 @@
the 2D angular velocity.
</description>
</class>
<class type="fuse_constraints::AbsoluteVelocityAngular3DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D angular velocity, or a direct measurement of
the 3D angular velocity.
</description>
</class>
<class type="fuse_constraints::AbsoluteVelocityLinear2DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 2D linear velocity, or a direct measurement of
the 2D linear velocity.
</description>
</class>
<class type="fuse_constraints::AbsoluteVelocityLinear3DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D linear velocity, or a direct measurement of
the 3D linear velocity.
</description>
</class>
<class type="fuse_constraints::AbsoluteOrientation3DStampedConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D orientation, or a direct measurement of the
Expand All @@ -63,6 +87,12 @@
A constraint that represents either prior information about a 3D pose, or a direct measurement of the 3D pose.
</description>
</class>
<class type="fuse_constraints::AbsolutePose3DStampedEulerConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents either prior information about a 3D pose, or a direct measurement of the 3D pose,
orientation parametrized in RPY.
</description>
</class>
<class type="fuse_constraints::MarginalConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents remaining marginal information on a set of variables.
Expand Down Expand Up @@ -118,4 +148,9 @@
A constraint that represents a measurement on the difference between two 3D poses.
</description>
</class>
<class type="fuse_constraints::RelativePose3DStampedEulerConstraint" base_class_type="fuse_core::Constraint">
<description>
A constraint that represents a measurement on the difference between two 3D poses, orientation parametrized in RPY.
</description>
</class>
</library>
16 changes: 16 additions & 0 deletions fuse_constraints/include/fuse_constraints/absolute_constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@
#include <fuse_core/serialization.hpp>
#include <fuse_core/uuid.hpp>
#include <fuse_variables/acceleration_angular_2d_stamped.hpp>
#include <fuse_variables/acceleration_angular_3d_stamped.hpp>
#include <fuse_variables/acceleration_linear_2d_stamped.hpp>
#include <fuse_variables/acceleration_linear_3d_stamped.hpp>
#include <fuse_variables/orientation_2d_stamped.hpp>
#include <fuse_variables/position_2d_stamped.hpp>
#include <fuse_variables/position_3d_stamped.hpp>
#include <fuse_variables/velocity_angular_2d_stamped.hpp>
#include <fuse_variables/velocity_angular_3d_stamped.hpp>
#include <fuse_variables/velocity_linear_3d_stamped.hpp>
#include <fuse_variables/velocity_linear_2d_stamped.hpp>

#include <boost/serialization/access.hpp>
Expand Down Expand Up @@ -196,27 +200,39 @@ class AbsoluteConstraint : public fuse_core::Constraint
// Define unique names for the different variations of the absolute constraint
using AbsoluteAccelerationAngular2DStampedConstraint =
AbsoluteConstraint<fuse_variables::AccelerationAngular2DStamped>;
using AbsoluteAccelerationAngular3DStampedConstraint =
AbsoluteConstraint<fuse_variables::AccelerationAngular3DStamped>;
using AbsoluteAccelerationLinear2DStampedConstraint =
AbsoluteConstraint<fuse_variables::AccelerationLinear2DStamped>;
using AbsoluteAccelerationLinear3DStampedConstraint =
AbsoluteConstraint<fuse_variables::AccelerationLinear3DStamped>;
using AbsoluteOrientation2DStampedConstraint =
AbsoluteConstraint<fuse_variables::Orientation2DStamped>;
using AbsolutePosition2DStampedConstraint = AbsoluteConstraint<fuse_variables::Position2DStamped>;
using AbsolutePosition3DStampedConstraint = AbsoluteConstraint<fuse_variables::Position3DStamped>;
using AbsoluteVelocityAngular2DStampedConstraint =
AbsoluteConstraint<fuse_variables::VelocityAngular2DStamped>;
using AbsoluteVelocityAngular3DStampedConstraint =
AbsoluteConstraint<fuse_variables::VelocityAngular3DStamped>;
using AbsoluteVelocityLinear2DStampedConstraint =
AbsoluteConstraint<fuse_variables::VelocityLinear2DStamped>;
using AbsoluteVelocityLinear3DStampedConstraint =
AbsoluteConstraint<fuse_variables::VelocityLinear3DStamped>;
} // namespace fuse_constraints

// Include the template implementation
#include <fuse_constraints/absolute_constraint_impl.hpp>

BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteAccelerationAngular2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteAccelerationAngular3DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteAccelerationLinear2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteAccelerationLinear3DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteOrientation2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsolutePosition2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsolutePosition3DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteVelocityAngular2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteVelocityAngular3DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteVelocityLinear2DStampedConstraint);
BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsoluteVelocityLinear3DStampedConstraint);

#endif // FUSE_CONSTRAINTS__ABSOLUTE_CONSTRAINT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ inline std::string AbsoluteConstraint<fuse_variables::AccelerationLinear2DStampe
return "fuse_constraints::AbsoluteAccelerationLinear2DStampedConstraint";
}

template<>
inline std::string AbsoluteConstraint<fuse_variables::AccelerationAngular3DStamped>::type() const
{
return "fuse_constraints::AbsoluteAccelerationAngular3DStampedConstraint";
}

template<>
inline std::string AbsoluteConstraint<fuse_variables::AccelerationLinear3DStamped>::type() const
{
return "fuse_constraints::AbsoluteAccelerationLinear3DStampedConstraint";
}

template<>
inline std::string AbsoluteConstraint<fuse_variables::Orientation2DStamped>::type() const
{
Expand Down Expand Up @@ -185,6 +197,18 @@ inline std::string AbsoluteConstraint<fuse_variables::VelocityLinear2DStamped>::
return "fuse_constraints::AbsoluteVelocityLinear2DStampedConstraint";
}

template<>
inline std::string AbsoluteConstraint<fuse_variables::VelocityAngular3DStamped>::type() const
{
return "fuse_constraints::AbsoluteVelocityAngular3DStampedConstraint";
}

template<>
inline std::string AbsoluteConstraint<fuse_variables::VelocityLinear3DStamped>::type() const
{
return "fuse_constraints::AbsoluteVelocityLinear3DStampedConstraint";
}

} // namespace fuse_constraints

#endif // FUSE_CONSTRAINTS__ABSOLUTE_CONSTRAINT_IMPL_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2023, Giacomo Franchini
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/


#ifndef FUSE_CONSTRAINTS__ABSOLUTE_POSE_3D_STAMPED_EULER_CONSTRAINT_HPP_
#define FUSE_CONSTRAINTS__ABSOLUTE_POSE_3D_STAMPED_EULER_CONSTRAINT_HPP_

#include <Eigen/Dense>

#include <ostream>
#include <string>
#include <vector>

#include <fuse_core/constraint.hpp>
#include <fuse_core/eigen.hpp>
#include <fuse_core/fuse_macros.hpp>
#include <fuse_core/serialization.hpp>
#include <fuse_core/uuid.hpp>
#include <fuse_variables/orientation_3d_stamped.hpp>
#include <fuse_variables/position_3d_stamped.hpp>

#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp>


namespace fuse_constraints
{

/**
* @brief A constraint that represents either prior information about a 3D pose, or a direct
* measurement of the 3D pose.
*
* A 3D pose is the combination of a 3D position and a 3D orientation variable. As a convenience,
* this class applies an absolute constraint on both variables at once. This type of constraint
* arises in many situations. In mapping it is common to define the very first pose as the origin.
* Some sensors, such as GPS, provide direct measurements of the robot's pose in the global frame.
* And localization systems often match laserscans or pointclouds to a prior map (scan-to-map
* measurements). This constraint holds the measured 3D pose: orientation is parametrized as roll-pitch-yaw
* Euler angles and the covariance represents the error around each translational and rotational axis.
* This constraint allows measurement of a subset of the pose components given in the variable.
*/

class AbsolutePose3DStampedEulerConstraint : public fuse_core::Constraint
{
public:
FUSE_CONSTRAINT_DEFINITIONS_WITH_EIGEN(AbsolutePose3DStampedEulerConstraint)

/**
* @brief Default constructor
*/
AbsolutePose3DStampedEulerConstraint() = default;

/**
* @brief Create a constraint using a measurement/prior of the 3D pose
*
* @param[in] source The name of the sensor or motion model that generated this constraint
* @param[in] position The variable representing the position components of the pose
* @param[in] orientation The variable representing the orientation components of the pose
* @param[in] mean The measured/prior pose as a vector
* (6x1 vector: x, y, z, roll, pitch, yaw)
* @param[in] covariance The measurement/prior covariance (6x6 matrix: x, y, z, roll, pitch, yaw)
*/
AbsolutePose3DStampedEulerConstraint(
const std::string & source,
const fuse_variables::Position3DStamped & position,
const fuse_variables::Orientation3DStamped & orientation,
const fuse_core::Vector6d & mean,
const fuse_core::Matrix6d & covariance);

/**
* @brief Create a constraint using a partial measurement/prior of the 3D pose
*
* @param[in] source The name of the sensor or motion model that generated this constraint
* @param[in] position The variable representing the position components of the pose
* @param[in] orientation The variable representing the orientation components of the pose
* @param[in] partial_mean The measured/prior pose as a vector
* (6x1 vector: x, y, z, roll, pitch, yaw)
* @param[in] partial_covariance The measurement/prior covariance (6x6 matrix: x, y, z, roll, pitch, yaw)
* @param[in] variable_indices The indices of the measured variables
*/
AbsolutePose3DStampedEulerConstraint(
const std::string & source,
const fuse_variables::Position3DStamped & position,
const fuse_variables::Orientation3DStamped & orientation,
const fuse_core::Vector6d & partial_mean,
const fuse_core::MatrixXd & partial_covariance,
const std::vector<size_t> & variable_indices);

/**
* @brief Destructor
*/
virtual ~AbsolutePose3DStampedEulerConstraint() = default;

/**
* @brief Read-only access to the measured/prior vector of mean values.
*
* Order is (x, y, z, roll, pitch, yaw)
*/
const fuse_core::Vector6d & mean() const {return mean_;}

/**
* @brief Read-only access to the square root information matrix.
*
* Order is (x, y, z, roll, pitch, yaw)
*/
const fuse_core::MatrixXd & sqrtInformation() const {return sqrt_information_;}

/**
* @brief Compute the measurement covariance matrix.
*
* Order is (x, y, z, roll, pitch, yaw)
*/
fuse_core::Matrix6d covariance() const;

/**
* @brief Print a human-readable description of the constraint to the provided stream.
*
* @param[out] stream The stream to write to. Defaults to stdout.
*/
void print(std::ostream & stream = std::cout) const override;

/**
* @brief Construct an instance of this constraint's cost function
*
* The function caller will own the new cost function instance. It is the responsibility of the
* caller to delete the cost function object when it is no longer needed. If the pointer is
* provided to a Ceres::Problem object, the Ceres::Problem object will takes ownership of the
* pointer and delete it during destruction.
*
* @return A base pointer to an instance of a derived CostFunction.
*/
ceres::CostFunction * costFunction() const override;

protected:
fuse_core::Vector6d mean_; //!< The measured/prior mean vector for this variable
fuse_core::MatrixXd sqrt_information_; //!< The square root information matrix

private:
// Allow Boost Serialization access to private methods
friend class boost::serialization::access;

/**
* @brief The Boost Serialize method that serializes all of the data members in to/out of the
* archive
*
* @param[in/out] archive - The archive object that holds the serialized class members
* @param[in] version - The version of the archive being read/written. Generally unused.
*/
template<class Archive>
void serialize(Archive & archive, const unsigned int /* version */)
{
archive & boost::serialization::base_object<fuse_core::Constraint>(*this);
archive & mean_;
archive & sqrt_information_;
}
};

} // namespace fuse_constraints

BOOST_CLASS_EXPORT_KEY(fuse_constraints::AbsolutePose3DStampedEulerConstraint);

#endif // FUSE_CONSTRAINTS__ABSOLUTE_POSE_3D_STAMPED_EULER_CONSTRAINT_HPP_
Loading