Skip to content

Commit

Permalink
Update clang-format style; add reformat bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Aug 14, 2024
1 parent 732854d commit 08dffc3
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AllowShortBlocksOnASingleLine: true
BreakBeforeBraces: Allman
#BreakBeforeTernaryOperators: true
#BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
ColumnLimit: 100
#CommentPragmas: ''
#ConstructorInitializerAllOnOneLineOrOnePerLine: true
#ConstructorInitializerIndentWidth: 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static void test_rotation_integration()
// gtPose).norm(),1e-6);

// Initial state:
auto lambdaAssertInitialState = [&ri]() {
auto lambdaAssertInitialState = [&ri]()
{
const auto& s = ri.current_integration_state();
ASSERT_LT_(
(s.deltaRij_ - mrpt::math::CMatrixDouble33::Identity()).norm(),
Expand Down
16 changes: 8 additions & 8 deletions mola_input_euroc_dataset/src/EurocDataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,17 @@ void EurocDataset::spinOnce()

std::visit(
overloaded{
[&](std::monostate&) {
THROW_EXCEPTION("Un-initialized entry!");
},
[&](SensorCamera& cam) {
[&](std::monostate&)
{ THROW_EXCEPTION("Un-initialized entry!"); },
[&](SensorCamera& cam)
{
build_dataset_entry_obs(cam);
cam.obs->timestamp = obs_tim;
this->sendObservationsToFrontEnds(cam.obs);
cam.obs.reset(); // free mem
},
[&](SensorIMU& imu) {
[&](SensorIMU& imu)
{
build_dataset_entry_obs(imu);
imu.obs->timestamp = obs_tim;
this->sendObservationsToFrontEnds(imu.obs);
Expand Down Expand Up @@ -330,9 +331,8 @@ void EurocDataset::spinOnce()
//
std::visit(
overloaded{
[&](std::monostate&) {
THROW_EXCEPTION("Un-initialized entry!");
},
[&](std::monostate&)
{ THROW_EXCEPTION("Un-initialized entry!"); },
[&](SensorCamera& cam) { build_dataset_entry_obs(cam); },
[&](SensorIMU& imu) { build_dataset_entry_obs(imu); }},
peeker->second);
Expand Down
2 changes: 1 addition & 1 deletion mola_input_mulran_dataset/src/MulranDataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void MulranDataset::load_lidar(timestep_t step) const
// Pose:
obs->sensorPose = ousterPoseOnVehicle_;
obs->timestamp = mrpt::Clock::fromDouble(
LidarFileNameToTimestamp(lstPointCloudFiles_[step]));
LidarFileNameToTimestamp(lstPointCloudFiles_[step]));

#if 0 // Export clouds to txt for debugging externally (e.g. python, matlab)
pts->saveXYZIRT_to_text_file(
Expand Down
6 changes: 3 additions & 3 deletions mola_input_paris_luco_dataset/src/ParisLucoDataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ void ParisLucoDataset::load_lidar(timestep_t step) const
const float earliestTime = *std::min_element(Ts->cbegin(), Ts->cend());
const float shiftTime = -earliestTime - 0.5 * lidarPeriod_;

std::transform(Ts->cbegin(), Ts->cend(), Ts->begin(), [=](double t) {
return t + shiftTime;
});
std::transform(
Ts->cbegin(), Ts->cend(), Ts->begin(),
[=](double t) { return t + shiftTime; });

// Fix missing RING_ID: ParisLuco does not have a RING_ID field,
// but we can generate it from the timestamps + pitch angle:
Expand Down
86 changes: 44 additions & 42 deletions mola_input_rawlog/src/RawlogDataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,23 @@ void RawlogDataset::doReadAheadFromFile()
std::dynamic_pointer_cast<mrpt::obs::CSensoryFrame>(
obj);
sf)
{
for (const auto& o : *sf)
read_ahead_.emplace(o->getTimeStamp(), o);
}
else if (auto acts = std::dynamic_pointer_cast<
mrpt::obs::CActionCollection>(obj);
acts)
{
// odometry actions: ignore
}
else
THROW_EXCEPTION_FMT(
"Rawlog file can contain classes: "
"CObservation|CSensoryFrame|CActionCollection, but class "
"'%s' found.",
obj->GetRuntimeClass()->className);
{
for (const auto& o : *sf)
read_ahead_.emplace(o->getTimeStamp(), o);
}
else if (auto acts = std::dynamic_pointer_cast<
mrpt::obs::CActionCollection>(obj);
acts)
{
// odometry actions: ignore
}
else
THROW_EXCEPTION_FMT(
"Rawlog file can contain classes: "
"CObservation|CSensoryFrame|CActionCollection, but "
"class "
"'%s' found.",
obj->GetRuntimeClass()->className);
}
catch (const mrpt::serialization::CExceptionEOF&)
{
Expand Down Expand Up @@ -247,22 +248,22 @@ void RawlogDataset::doReadAheadFromEntireRawlog()
if (auto sf =
std::dynamic_pointer_cast<mrpt::obs::CSensoryFrame>(obj);
sf)
{
for (const auto& o : *sf) read_ahead_.emplace(o->getTimeStamp(), o);
}
else if (auto acts =
std::dynamic_pointer_cast<mrpt::obs::CActionCollection>(
obj);
acts)
{
// odometry actions: ignore
}
else
THROW_EXCEPTION_FMT(
"Rawlog file can contain classes: "
"CObservation|CSensoryFrame|CActionCollection, but class "
"'%s' found.",
obj->GetRuntimeClass()->className);
{
for (const auto& o : *sf)
read_ahead_.emplace(o->getTimeStamp(), o);
}
else if (auto acts = std::dynamic_pointer_cast<
mrpt::obs::CActionCollection>(obj);
acts)
{
// odometry actions: ignore
}
else
THROW_EXCEPTION_FMT(
"Rawlog file can contain classes: "
"CObservation|CSensoryFrame|CActionCollection, but class "
"'%s' found.",
obj->GetRuntimeClass()->className);
}
}

Expand Down Expand Up @@ -331,17 +332,18 @@ mrpt::obs::CSensoryFrame::Ptr RawlogDataset::datasetGetObservations(
else //
if (auto sf = std::dynamic_pointer_cast<mrpt::obs::CSensoryFrame>(obj);
sf)
{
sfRet = sf;
{
sfRet = sf;

for (auto& o : *sf) unload_queue_.emplace(o->getTimeStamp(), o);
}
else if (auto acts =
std::dynamic_pointer_cast<mrpt::obs::CActionCollection>(obj);
acts)
{
// odometry actions: ignore
}
for (auto& o : *sf) unload_queue_.emplace(o->getTimeStamp(), o);
}
else if (auto acts =
std::dynamic_pointer_cast<mrpt::obs::CActionCollection>(
obj);
acts)
{
// odometry actions: ignore
}

return sfRet;
}
27 changes: 18 additions & 9 deletions mola_kernel/src/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ EntityBase& mola::entity_get_base(Entity& e)
std::visit(
overloaded{
[&ret](EntityBase& b) { ret = &b; },
[&ret](EntityOther& o) {
[&ret](EntityOther& o)
{
ASSERT_(o);
ret = o.get();
},
Expand All @@ -39,7 +40,8 @@ const EntityBase& mola::entity_get_base(const Entity& e)
std::visit(
overloaded{
[&ret](const EntityBase& b) { ret = &b; },
[&ret](const EntityOther& o) {
[&ret](const EntityOther& o)
{
ASSERT_(o);
ret = o.get();
},
Expand All @@ -56,15 +58,17 @@ void mola::entity_update_pose(mola::Entity& e, const mrpt::math::TPose3D& p)

std::visit(
overloaded{
[&](RefPose3&) {
[&](RefPose3&)
{
ASSERTMSG_(
p == mrpt::math::TPose3D::Identity(),
"RefPose3 cannot be assigned a pose != Identity()");
},
[&](RelDynPose3KF& ee) { ee.relpose_value = p; },
[&](RelPose3& ee) { ee.relpose_value = p; },
[&](RelPose3KF& ee) { ee.relpose_value = p; },
[]([[maybe_unused]] auto ee) {
[]([[maybe_unused]] auto ee)
{
throw std::runtime_error(
mrpt::format("[updateEntityPose] Unknown Entity type!"));
},
Expand All @@ -86,14 +90,16 @@ void mola::entity_update_vel(mola::Entity& e, const std::array<double, 3>& v)
"RefPose3 cannot be assigned a velocity!=0");
#endif
},
[&](RelDynPose3KF& ee) {
[&](RelDynPose3KF& ee)
{
ee.twist_value.vx = v[0];
ee.twist_value.vy = v[1];
ee.twist_value.vz = v[2];
},
[&](RelPose3&) {},
[&](RelPose3KF&) {},
[]([[maybe_unused]] auto ee) {
[]([[maybe_unused]] auto ee)
{
throw std::runtime_error(
mrpt::format("[updateEntityPose] Unknown Entity type!"));
},
Expand All @@ -113,7 +119,8 @@ mrpt::math::TTwist3D mola::entity_get_twist(const mola::Entity& e)
[&](const RelDynPose3KF& ee) { ret = ee.twist_value; },
[&](const RelPose3&) {},
[&](const RelPose3KF&) {},
[]([[maybe_unused]] auto ee) {
[]([[maybe_unused]] auto ee)
{
throw std::runtime_error(
mrpt::format("[updateEntityPose] Unknown Entity type!"));
},
Expand All @@ -134,7 +141,8 @@ mrpt::math::TPose3D mola::entity_get_pose(const mola::Entity& e)
[&](const RelDynPose3KF& ee) { ret = ee.relpose_value; },
[&](const RelPose3& ee) { ret = ee.relpose_value; },
[&](const RelPose3KF& ee) { ret = ee.relpose_value; },
[]([[maybe_unused]] auto ee) {
[]([[maybe_unused]] auto ee)
{
throw std::runtime_error(
mrpt::format("[getEntityPose] Unknown Entity type!"));
},
Expand All @@ -154,7 +162,8 @@ mrpt::Clock::time_point mola::entity_get_timestamp(const mola::Entity& e)
overloaded{
[&](const EntityBase& ee) { ret = ee.timestamp_; },
[&](const EntityOther& ee) { ret = ee->timestamp_; },
[](std::monostate) {
[](std::monostate)
{
throw std::runtime_error(
mrpt::format("[getEntityTimeStamp] Unknown Entity type!"));
},
Expand Down
6 changes: 4 additions & 2 deletions mola_kernel/src/Factor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ FactorBase& mola::factor_get_base(Factor& f)
std::visit(
overloaded{
[&ret](FactorBase& b) { ret = &b; },
[&ret](FactorOther& o) {
[&ret](FactorOther& o)
{
ASSERT_(o);
ret = o.get();
},
Expand All @@ -39,7 +40,8 @@ const FactorBase& mola::factor_get_base(const Factor& f)
std::visit(
overloaded{
[&ret](const FactorBase& b) { ret = &b; },
[&ret](const FactorOther& o) {
[&ret](const FactorOther& o)
{
ASSERT_(o);
ret = o.get();
},
Expand Down
2 changes: 1 addition & 1 deletion mola_kernel/src/factors/FactorConstVelKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mola::id_t FactorConstVelKinematics::edge_indices(const std::size_t i) const
// Implementation of the CSerializable virtual interface:
uint8_t FactorConstVelKinematics::serializeGetVersion() const { return 0; }
void FactorConstVelKinematics::serializeTo(
mrpt::serialization::CArchive& out) const
mrpt::serialization::CArchive& out) const
{
baseSerializeTo(out);
out << from_kf_ << to_kf_ << deltaTime_;
Expand Down
2 changes: 1 addition & 1 deletion mola_kernel/src/factors/FactorStereoProjectionPose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mola::id_t FactorStereoProjectionPose::edge_indices(const std::size_t i) const
// Implementation of the CSerializable virtual interface:
uint8_t FactorStereoProjectionPose::serializeGetVersion() const { return 0; }
void FactorStereoProjectionPose::serializeTo(
mrpt::serialization::CArchive& out) const
mrpt::serialization::CArchive& out) const
{
baseSerializeTo(out);
out << sigma_xleft_ << sigma_xright_ << sigma_y_ << observation_.x_left
Expand Down
3 changes: 2 additions & 1 deletion mola_kernel/src/interfaces/FilterBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void FilterBase::spinOnce()
void FilterBase::onNewObservation(const CObservation::Ptr& o)
{
const auto obsFut = thread_pool_.enqueue(
[this](const CObservation::Ptr& in) {
[this](const CObservation::Ptr& in)
{
try
{
// Process the observation:
Expand Down
6 changes: 4 additions & 2 deletions mola_kernel/src/interfaces/RawDataSourceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ void RawDataSourceBase::sendObservationsToFrontEnds(
if (export_to_rawlog_out_.is_open())
{
auto fut = worker_pool_export_rawlog_.enqueue(
[this](mrpt::obs::CObservation::Ptr o) {
[this](mrpt::obs::CObservation::Ptr o)
{
if (!o) return;
auto a = mrpt::serialization::archiveFrom(
this->export_to_rawlog_out_);
Expand All @@ -159,7 +160,8 @@ void RawDataSourceBase::sendObservationsToFrontEnds(
// Create and enque the GUI update function, as a lambda:
RawDataSourceBase::SensorViewerImpl* sv = &(*it_sen_gui->second);

auto func = [this, sv, obs]() {
auto func = [this, sv, obs]()
{
try
{
ProfilerEntry pe(profiler_, "send to viz lambda");
Expand Down
6 changes: 4 additions & 2 deletions mola_kernel/src/pretty_print_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void mola::pretty_print_exception(

auto& o = use_std_cerr ? std::cerr : std::cout;

const auto setFormatRed = [=](const ConsoleTextStyle style) {
const auto setFormatRed = [=](const ConsoleTextStyle style)
{
#if MRPT_VERSION >= 0x233
consoleColorAndStyle(
ConsoleForegroundColor::RED, ConsoleBackgroundColor::DEFAULT, style,
Expand All @@ -36,7 +37,8 @@ void mola::pretty_print_exception(
#endif
};

const auto resetFormat = [=]() {
const auto resetFormat = [=]()
{
#if MRPT_VERSION >= 0x233
consoleColorAndStyle(
ConsoleForegroundColor::DEFAULT, ConsoleBackgroundColor::DEFAULT,
Expand Down
2 changes: 2 additions & 0 deletions mola_launcher/src/MolaDLL_Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
*/

#include "MolaDLL_Loader.h"

#include <mrpt/core/exceptions.h>
#include <mrpt/system/CDirectoryExplorer.h>

#include <map>

#if defined(__unix__)
Expand Down
1 change: 1 addition & 0 deletions mola_launcher/src/MolaDLL_Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#pragma once

#include <mrpt/system/COutputLogger.h>

#include <string>
#include <vector>

Expand Down
Loading

0 comments on commit 08dffc3

Please sign in to comment.