Skip to content

Commit

Permalink
Renamed InterfaceMOICalculator class to CustomInertiaCalcProperties
Browse files Browse the repository at this point in the history
Signed-off-by: Jasmeet Singh <[email protected]>
  • Loading branch information
jasmeet0915 committed Aug 16, 2023
1 parent b9a6698 commit 00c1496
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Open Source Robotics Foundation
* Copyright 2023 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,8 @@
*
*/

#ifndef SDF_INTERFACE_MOI_CALCULATOR_HH_
#define SDF_INTERFACE_MOI_CALCULATOR_HH_
#ifndef SDF_CUSTOM_INERTIA_CALC_PROPERTIES_HH_
#define SDF_CUSTOM_INERTIA_CALC_PROPERTIES_HH_

#include <gz/utils/ImplPtr.hh>
#include <gz/math/Inertial.hh>
Expand All @@ -33,13 +33,13 @@ inline namespace SDF_VERSION_NAMESPACE
// Forward Declarations
class Mesh;

class SDFORMAT_VISIBLE InterfaceMoiCalculator
class SDFORMAT_VISIBLE CustomInertiaCalcProperties
{
/// \brief Constructor
/// \param[in] _density Double density value
/// \param[in] _mesh sdf::Mesh object
/// \param[in] _calculatorParamElem sdf::ElementPtr for calculator params element
public: InterfaceMoiCalculator(const double _density,
public: CustomInertiaCalcProperties(const double _density,
const sdf::Mesh _mesh,
const sdf::ElementPtr _calculatorParams);

Expand All @@ -62,19 +62,19 @@ class SDFORMAT_VISIBLE InterfaceMoiCalculator
/// \brief Get the reference to the <moi_calculator_params> sdf element.
/// User defined custom calculator params can be accessed through this element
/// \return sdf::ElementPtr for the tag
public: const sdf::ElementPtr MoiCalculatorParams() const;
public: const sdf::ElementPtr AutoInertiaParams() const;

/// \brief Function to set the calculator params sdf element object
/// \param[in] _calculatorParamElem sdf::ElementPtr for calculator params element
public: void SetMoiCalculatorParams(sdf::ElementPtr _calculatorParamElem);
public: void SetAutoInertiaParams(sdf::ElementPtr _calculatorParamElem);

/// \brief Private data pointer.
GZ_UTILS_IMPL_PTR(dataPtr)
};

using CustomInertiaCalculator =
std::function<std::optional<gz::math::Inertiald>(sdf::Errors &,
const sdf::InterfaceMoiCalculator &)>;
const sdf::CustomInertiaCalcProperties &)>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/sdf/Mesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <gz/math/Vector3.hh>
#include <gz/math/Inertial.hh>
#include <gz/utils/ImplPtr.hh>
#include "sdf/InterafaceMoiCalculator.hh"
#include <sdf/CustomInertiaCalcProperties.hh>
#include <sdf/Element.hh>
#include <sdf/Error.hh>
#include <sdf/sdf_config.h>
Expand Down
2 changes: 1 addition & 1 deletion include/sdf/ParserConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "sdf/Error.hh"
#include "sdf/InterfaceElements.hh"
#include "sdf/InterafaceMoiCalculator.hh"
#include "sdf/CustomInertiaCalcProperties.hh"
#include "sdf/sdf_config.h"
#include "sdf/system_util.hh"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Open Source Robotics Foundation
* Copyright 2023 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,13 +15,13 @@
*
*/

#include "sdf/InterafaceMoiCalculator.hh"
#include "sdf/CustomInertiaCalcProperties.hh"
#include "sdf/Mesh.hh"
#include "sdf/Element.hh"

using namespace sdf;

class InterfaceMoiCalculator::Implementation
class CustomInertiaCalcProperties::Implementation
{
/// \brief Density of the mesh
public: double density;
Expand All @@ -31,45 +31,52 @@ class InterfaceMoiCalculator::Implementation

/// \brief SDF element pointer to <moi_calculator_params> tag. This can be used
/// to access custom params for the Mesh Intertia Caluclator
public: sdf::ElementPtr calculatorParams;
public: sdf::ElementPtr inertiaCalculatorParams;
};

InterfaceMoiCalculator::InterfaceMoiCalculator(const double _density,
/////////////////////////////////////////////////
CustomInertiaCalcProperties::CustomInertiaCalcProperties(const double _density,
const sdf::Mesh _mesh,
const sdf::ElementPtr _calculatorParams)
: dataPtr(gz::utils::MakeImpl<Implementation>())
{
this->dataPtr->density = _density;
this->dataPtr->mesh = _mesh;
this->dataPtr->calculatorParams = _calculatorParams;
this->dataPtr->inertiaCalculatorParams = _calculatorParams;
}

const double InterfaceMoiCalculator::Density() const
/////////////////////////////////////////////////
const double CustomInertiaCalcProperties::Density() const
{
return this->dataPtr->density;
}

void InterfaceMoiCalculator::SetDensity(const double _density)
/////////////////////////////////////////////////
void CustomInertiaCalcProperties::SetDensity(const double _density)
{
this->dataPtr->density = _density;
}

const sdf::Mesh &InterfaceMoiCalculator::Mesh() const
/////////////////////////////////////////////////
const sdf::Mesh &CustomInertiaCalcProperties::Mesh() const
{
return this->dataPtr->mesh;
}

void InterfaceMoiCalculator::SetMesh(sdf::Mesh &_mesh)
/////////////////////////////////////////////////
void CustomInertiaCalcProperties::SetMesh(sdf::Mesh &_mesh)
{
this->dataPtr->mesh = _mesh;
}

const sdf::ElementPtr InterfaceMoiCalculator::MoiCalculatorParams() const
/////////////////////////////////////////////////
const sdf::ElementPtr CustomInertiaCalcProperties::AutoInertiaParams() const
{
return this->dataPtr->calculatorParams;
return this->dataPtr->inertiaCalculatorParams;
}

void InterfaceMoiCalculator::SetMoiCalculatorParams(sdf::ElementPtr _calculatorParams)
/////////////////////////////////////////////////
void CustomInertiaCalcProperties::SetAutoInertiaParams(sdf::ElementPtr _autoInertiaParams)
{
this->dataPtr->calculatorParams = _calculatorParams;
this->dataPtr->inertiaCalculatorParams = _autoInertiaParams;
}
4 changes: 2 additions & 2 deletions src/Mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <optional>

#include <gz/math/Inertial.hh>
#include "sdf/InterafaceMoiCalculator.hh"
#include "sdf/CustomInertiaCalcProperties.hh"
#include "sdf/parser.hh"
#include "sdf/Mesh.hh"
#include "Utils.hh"
Expand Down Expand Up @@ -206,7 +206,7 @@ std::optional<gz::math::Inertiald> Mesh::CalculateInertial(const double _density
std::cout << "In Mesh:CalculateInertial function: " << std::endl;
const auto &customCalculator = _config.CustomInertiaCalc();

sdf::InterfaceMoiCalculator calcInterface = InterfaceMoiCalculator(
sdf::CustomInertiaCalcProperties calcInterface = CustomInertiaCalcProperties(
_density, *this, _autoInertiaParams);

return customCalculator(errors, calcInterface);
Expand Down
2 changes: 1 addition & 1 deletion src/ParserConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "sdf/ParserConfig.hh"
#include "sdf/Filesystem.hh"
#include "sdf/Types.hh"
#include "sdf/InterafaceMoiCalculator.hh"
#include "sdf/CustomInertiaCalcProperties.hh"

using namespace sdf;

Expand Down

0 comments on commit 00c1496

Please sign in to comment.