Program Listing for File PhysicalHinge.h#
↰ Return to documentation for file (include/Karana/SOADyn/PhysicalHinge.h)
/*
* Copyright (c) 2024-2026 Karana Dynamics Pty Ltd. All rights reserved.
*
* NOTICE TO USER:
*
* This source code and/or documentation (the "Licensed Materials") is
* the confidential and proprietary information of Karana Dynamics Inc.
* Use of these Licensed Materials is governed by the terms and conditions
* of a separate software license agreement between Karana Dynamics and the
* Licensee ("License Agreement"). Unless expressly permitted under that
* agreement, any reproduction, modification, distribution, or disclosure
* of the Licensed Materials, in whole or in part, to any third party
* without the prior written consent of Karana Dynamics is strictly prohibited.
*
* THE LICENSED MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
* KARANA DYNAMICS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, AND
* FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL KARANA DYNAMICS BE LIABLE FOR ANY DAMAGES WHATSOEVER,
* INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS, DATA, OR USE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, WHETHER IN CONTRACT, TORT,
* OR OTHERWISE ARISING OUT OF OR IN CONNECTION WITH THE LICENSED MATERIALS.
*
* U.S. Government End Users: The Licensed Materials are a "commercial item"
* as defined at 48 C.F.R. 2.101, and are provided to the U.S. Government
* only as a commercial end item under the terms of this license.
*
* Any use of the Licensed Materials in individual or commercial software must
* include, in the user documentation and internal source code comments,
* this Notice, Disclaimer, and U.S. Government Use Provision.
*/
/**
* @file
* @brief Contains the declarations for the PhysicalHinge class.
*/
#pragma once
#include "Karana/SOADyn/FramePairHinge.h"
#include <vector>
namespace Karana::Dynamics {
namespace kc = Karana::Core;
class HingeOnode;
class HingePnode;
class PinSubhinge;
class PhysicalBody;
/**
* @class PhysicalHinge
* @brief Represents the class for physical articulation hinges
*
* This class is the container for physical subhinges that define
* articulation for physical bodies. See \sref{body_hinge_sec} section
* for more information on physical hinges.
*/
class PhysicalHinge : public FramePairHinge {
/* for access to _oneTimeTeardown and _oneTimeSetup methods */
friend class PhysicalBody;
/* for access to _setupATBIDataCaches */
friend class Multibody;
/* for access to _invdyn_cache */
friend class HingePnode;
/* for access to acorPrime */
friend class CompoundSubhinge;
public:
/**
* @brief Factory method to create a PhysicalHinge instance.
*
* @param parent The parent body
* @param child The child body
* @param htype The hinge type
* @param subhinge_types The list of subhinge types for a custom hinge type
* @return A new PhysicalHinge instance
*/
static const kc::ks_ptr<PhysicalHinge>
create(PhysicalBody &parent,
PhysicalBody &child,
HingeType htype,
const std::vector<SubhingeType> &subhinge_types = std::vector<SubhingeType>());
/**
* @brief Hinge destructor.
*/
virtual ~PhysicalHinge();
/**
* @brief Hinge Constructor.
* @param parent The parent body
* @param child The child body
* @param name The string name for the hinge
* @param htype The hinge type
* @param subhinge_types The list of subhinge types for a custom hinge type
*/
PhysicalHinge(
PhysicalBody &parent,
PhysicalBody &child,
std::string_view name,
HingeType htype,
const std::vector<SubhingeType> &subhinge_types = std::vector<SubhingeType>());
std::string_view typeString(bool brief = true) const noexcept override {
return kc::Base::typeString(brief);
}
public:
/**
* @brief Return the pnode for the hinge
* See \sref{body_hinge_sec} section for more information on onodes and pnodes.
* @return the HingePnode instance
*/
const kc::ks_ptr<HingePnode> &pnode() const;
/**
* @brief Return the onode for the hinge
* See \sref{body_hinge_sec} section for more information on onodes and pnodes.
* @return the HingeOnode instance
*/
const kc::ks_ptr<HingeOnode> &onode() const;
std::string dumpString(std::string_view prefix,
const Karana::Core::Base::DumpOptions *options) const override;
protected:
/**
* @brief - Discard the PhysicalHinge.
* @param base - Pointer to the PhysicalHinge.
*/
void _discard(kc::ks_ptr<Base> &base) override;
/**
* @brief Helper method to set up the ATBI data caches.
*/
void _setupATBIDataCaches();
/**
* @brief Helper method to tear down the ATBI data caches.
*/
void _teardownATBIDataCaches();
/**
* @brief Helper method to set up the inverse dynamics data cache.
*/
void _setupInvDynDataCaches();
/**
* @brief Helper method to tear down the inverse dynamics data cache.
*/
void _teardownInvDynDataCaches();
/**
* @brief Helper method to tear down the hinge
*/
// Adding suppression, as CodeChecker complains this method has
// the same name as a method in the base version. This is just a
// CodeChecker false positive.
// codechecker_suppress [cppcheck-duplInheritedMember]
void _oneTimeTeardown();
/** @brief Carry out side effect of the the generalized force changing for
the subhinge.
An example side effect is to mark the ATBI filter
data cache for the hinge onode as not healthy for a physical hinge.
*/
void _changeActionT() override;
/** @brief Compute the overall Coriolis accel term for all of the
subhinges about and in the pnode frame.
This is needed for
compound bodies ATBI filter step. The XdotU vector is
non-null (i.e. non-zero size) only for constraint-embedding
compound bodies - where the XdotU term is a contribution
from the configuration dependency of the independent to
dependent coordinates
@param x_dot_u the Xdot*U input values for the subhinges
@return the a' Coriolis acceleration vector
*/
km::SpatialVector _acorPrime(const km::Vec &x_dot_u) const;
private:
kc::ks_ptr<HingeOnode> _onode;
kc::ks_ptr<HingePnode> _pnode;
};
} // namespace Karana::Dynamics