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

Port pinhole camera from ROS1 #4

Merged
merged 60 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
073feb6
change to get building with latest rclcpp
henrygerardmoore Sep 4, 2024
94d2f15
uncrustify fixes
henrygerardmoore Sep 7, 2024
0ad7731
try disabling -Wstringop-overread
henrygerardmoore Sep 12, 2024
def055c
Merge branch 'models_3d' into merge_3d_models
henrygerardmoore Sep 13, 2024
2a2c2aa
Merge branch 'rolling' into merge_3d_models
henrygerardmoore Sep 17, 2024
ed150d9
merge main
henrygerardmoore Sep 24, 2024
0773207
apply pre-commit
henrygerardmoore Sep 24, 2024
2b01c90
do vcs in dockerfile instead
henrygerardmoore Sep 24, 2024
098cb7e
let industrial ci find our repos
henrygerardmoore Sep 24, 2024
d62f650
remove industrial CI
henrygerardmoore Sep 24, 2024
a558ab1
remove deprecated .h headers
henrygerardmoore Sep 24, 2024
d91474e
fix test tolerance and only test fuse packages, not vcs deps
henrygerardmoore Sep 24, 2024
edd25a1
bump to correct link
henrygerardmoore Sep 24, 2024
d70df28
initial pass at 3D tutorial
henrygerardmoore Sep 24, 2024
6570a94
wip 3d tutorial
henrygerardmoore Sep 25, 2024
bcc20ad
fix typos
henrygerardmoore Sep 25, 2024
8df2fc8
fix 3d tutorial
henrygerardmoore Sep 26, 2024
2c5ee14
finish tutorial, add comments, fix visualization
henrygerardmoore Sep 26, 2024
1a7ef62
fix incomplete comment
henrygerardmoore Sep 27, 2024
85d4cfa
make launch file executable
henrygerardmoore Sep 27, 2024
1c63cd0
add upstream pinhole-camera-related files
henrygerardmoore Sep 27, 2024
7bd47e4
fix pinhole camera
henrygerardmoore Sep 27, 2024
65aee2d
comment out unused var
henrygerardmoore Sep 27, 2024
b4e76b6
change clang tidy conf and remove jenkinsfile
henrygerardmoore Sep 27, 2024
a98ef09
fix mistake in quat util
henrygerardmoore Oct 2, 2024
ea4e374
Update fuse_tutorials/src/three_dimensional_simulator.cpp
henrygerardmoore Oct 2, 2024
f0f0cc6
apply PR feedback
henrygerardmoore Oct 2, 2024
d2fa0e5
Merge branch 'merge_3d_models' into pinhole_camera
henrygerardmoore Oct 2, 2024
8c00d8d
add clang-tidy workflow
henrygerardmoore Oct 2, 2024
41e3692
add clang tidy pre-commit
henrygerardmoore Oct 3, 2024
c45e85c
add clang-tidy to pre-commit
henrygerardmoore Oct 3, 2024
a33b717
move pre-commit to after build in CI and make clang-tidy optional
henrygerardmoore Oct 3, 2024
81ef290
default to not running clang tidy, but let the user know
henrygerardmoore Oct 3, 2024
e31c89b
specify version
henrygerardmoore Oct 3, 2024
69af8ea
update first?
henrygerardmoore Oct 3, 2024
2d66302
cd into correct wd
henrygerardmoore Oct 3, 2024
04b5911
change pip cache owner
henrygerardmoore Oct 3, 2024
60c46d6
remove industrial CI
henrygerardmoore Oct 3, 2024
10abfa4
chown more stuff
henrygerardmoore Oct 3, 2024
9a6c4ce
try without container
henrygerardmoore Oct 3, 2024
66534b7
try without checkout
henrygerardmoore Oct 3, 2024
6b86114
add container back
henrygerardmoore Oct 3, 2024
8748a8f
try clang tidy outside pre-commit
henrygerardmoore Oct 4, 2024
e7ca98f
run only on changed cpp/hpp files
henrygerardmoore Oct 4, 2024
2ae9f73
point to config file
henrygerardmoore Oct 4, 2024
58d3ca6
change files to last
henrygerardmoore Oct 4, 2024
5c4a5fa
fix clang tidy path
henrygerardmoore Oct 4, 2024
6424c7a
try adding back some checks
henrygerardmoore Oct 4, 2024
445fb27
try removing cache
henrygerardmoore Oct 4, 2024
ad64883
clang tidy fix
henrygerardmoore Oct 4, 2024
65fc8bf
Merge branch 'add_clang_tidy' into merge_3d_models
henrygerardmoore Oct 4, 2024
9d22bde
remove most oft-violated checks
henrygerardmoore Oct 4, 2024
b874508
don't run clang tidy on main
henrygerardmoore Oct 4, 2024
a8f2389
Merge branch 'main' into merge_3d_models
henrygerardmoore Oct 4, 2024
6b7fd4b
Merge branch 'merge_3d_models' into pinhole_camera
henrygerardmoore Oct 4, 2024
f0962a1
clang-tidy fixes
henrygerardmoore Oct 4, 2024
2bb10ff
remove difficult checks
henrygerardmoore Oct 4, 2024
67e661b
clang tidy fixes
henrygerardmoore Oct 4, 2024
8b7fe6b
one more clang tidy fix
henrygerardmoore Oct 4, 2024
b89c506
Merge branch 'main' into pinhole_camera
henrygerardmoore Oct 7, 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
4 changes: 4 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ Checks: -*,
-bugprone-exception-escape,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
Comment on lines +16 to +17
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are annoying in test code and with Eigen in general.

-google-readability-casting,
-google-default-arguments,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a core class that uses a default argument that a ton of stuff inherits from (the print method in fuse models) so changing all these would be annoying.

-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely stylistic one that I don't care for. False positives on structs too, for which you obviously want public member variables

-modernize-use-trailing-return-type,
-modernize-avoid-bind,
-readability-identifier-length,
Expand Down
2 changes: 2 additions & 0 deletions fuse_variables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ add_library(
src/acceleration_linear_3d_stamped.cpp
src/orientation_2d_stamped.cpp
src/orientation_3d_stamped.cpp
src/pinhole_camera.cpp
src/pinhole_camera_fixed.cpp
src/point_2d_fixed_landmark.cpp
src/point_2d_landmark.cpp
src/point_3d_fixed_landmark.cpp
Expand Down
224 changes: 224 additions & 0 deletions fuse_variables/include/fuse_variables/pinhole_camera.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
/*
* Software License Agreement (BSD License)
*
* Author: Oscar Mendez
* Created: 11.13.2023
*
* Copyright (c) 2023, Locus Robotics
* 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_VARIABLES_PINHOLE_CAMERA_H
#define FUSE_VARIABLES_PINHOLE_CAMERA_H

#include <fuse_core/ceres_macros.hpp>
#include <fuse_core/fuse_macros.hpp>
#include <fuse_core/manifold.hpp>
#include <fuse_core/serialization.hpp>
#include <fuse_core/uuid.hpp>
#include <fuse_variables/fixed_size_variable.hpp>

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

#include <ostream>

namespace fuse_variables
{
/**
* @brief Variable representing intrinsic parameters of a camera.
*
* The UUID of this class is constant after
* construction and dependent on a user input database id. As such, the database id cannot be altered after
* construction.
*/
class PinholeCamera : public FixedSizeVariable<4>
{
public:
FUSE_VARIABLE_DEFINITIONS(PinholeCamera);

/**
* @brief Can be used to directly index variables in the data array
*/
enum : size_t
{
FX = 0,
FY = 1,
CX = 2,
CY = 3
};

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

/**
* @brief Construct a pinhole camera variable given a camera id
*
* @param[in] camera_id The id associated to a camera
*/
explicit PinholeCamera(const uint64_t& camera_id);

/**
* @brief Construct a pinhole camera variable given a camera id and intrinsic parameters
*
* @param[in] camera_id The id associated to a camera
*/
explicit PinholeCamera(const fuse_core::UUID& uuid, const uint64_t& camera_id, const double& fx, const double& fy,
const double& cx, const double& cy);

/**
* @brief Read-write access to the cx parameter.
*/
double& cx()
{
return data_[CX];
}

/**
* @brief Read-only access to the cx parameter.
*/
const double& cx() const
{
return data_[CX];
}

/**
* @brief Read-write access to the cy parameter.
*/
double& cy()
{
return data_[CY];
}

/**
* @brief Read-only access to the cy parameter.
*/
const double& cy() const
{
return data_[CY];
}

/**
* @brief Read-write access to the fx parameter.
*/
double& fx()
{
return data_[FX];
}

/**
* @brief Read-only access to the fx parameter.
*/
const double& fx() const
{
return data_[FX];
}

/**
* @brief Read-write access to the fy parameter.
*/
double& fy()
{
return data_[FY];
}

/**
* @brief Read-only access to the fy parameter.
*/
const double& fy() const
{
return data_[FY];
}

/**
* @brief Read-only access to the id
*/
const uint64_t& id() const
{
return id_;
}

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

#if CERES_SUPPORTS_MANIFOLDS
/**
* @brief Create a null Ceres manifold
*
* Overriding the manifold() method prevents additional processing with the ManifoldAdapter
*/
fuse_core::Manifold* manifold() const override
{
return nullptr;
}
#endif

protected:
/**
* @brief Construct a point 3D variable given a camera id
*
* @param[in] camera_id The id associated to a camera
*/
PinholeCamera(const fuse_core::UUID& uuid, const uint64_t& camera_id);

private:
// Allow Boost Serialization access to private methods
friend class boost::serialization::access;
uint64_t id_{ 0 };

/**
* @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<FixedSizeVariable<SIZE>>(*this);
archive& id_;
}
};

} // namespace fuse_variables

BOOST_CLASS_EXPORT_KEY(fuse_variables::PinholeCamera);

#endif // FUSE_VARIABLES_PINHOLE_CAMERA_H
124 changes: 124 additions & 0 deletions fuse_variables/include/fuse_variables/pinhole_camera_fixed.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Software License Agreement (BSD License)
*
* Author: Oscar Mendez
* Created: 11.13.2023
*
* Copyright (c) 2023, Locus Robotics
* 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_VARIABLES_PINHOLE_CAMERA_FIXED_H
#define FUSE_VARIABLES_PINHOLE_CAMERA_FIXED_H

#include <fuse_core/ceres_macros.hpp>
#include <fuse_core/fuse_macros.hpp>
#include <fuse_core/manifold.hpp>
#include <fuse_core/serialization.hpp>
#include <fuse_variables/pinhole_camera.hpp>

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

namespace fuse_variables
{
/**
* @brief Variable representing a pinhole camera that exists across time.
*
*/
class PinholeCameraFixed : public PinholeCamera
{
public:
FUSE_VARIABLE_DEFINITIONS(PinholeCameraFixed);

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

/**
* @brief Construct a point 2D variable given a landmarks id
*
* @param[in] camera_id The id associated to a camera
*/
explicit PinholeCameraFixed(const uint64_t& camera_id);

/**
* @brief Construct a pinhole camera variable given a camera id and intrinsic parameters
*
* @param[in] camera_id The id associated to a camera
*/
explicit PinholeCameraFixed(const uint64_t& camera_id, const double& fx, const double& fy, const double& cx,
const double& cy);
/**
* @brief Specifies if the value of the variable should not be changed during optimization
*/
bool holdConstant() const override
{
return true;
}

#if CERES_SUPPORTS_MANIFOLDS
/**
* @brief Create a null Ceres manifold
*
* Overriding the manifold() method prevents additional processing with the ManifoldAdapter
*/
fuse_core::Manifold* manifold() const override
{
return nullptr;
}
#endif

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<PinholeCamera>(*this);
}
};

} // namespace fuse_variables

BOOST_CLASS_EXPORT_KEY(fuse_variables::PinholeCameraFixed);

#endif // FUSE_VARIABLES_PINHOLE_CAMERA_FIXED_H
Loading
Loading