首页 > 其他分享 >摩擦锥约束_FrictionConeConstraint

摩擦锥约束_FrictionConeConstraint

时间:2024-12-10 15:10:44浏览次数:8  
标签:square const d2Cone coneDerivatives FrictionConeConstraint localForces 约束 tangen

公式:

\(h(F) = u(F_z + F_{gripper}) - \sqrt{F^2_x + F^2_y + \epsilon} >= 0\)

  • \(F_{gripper}\):抓力(如果有)
  • \(\epsilon\):正则化参数,用于避免梯度计算时分母为0
vector_t FrictionConeConstraint::getValue(scalar_t time, const vector_t& state, const vector_t& input,
                                          const PreComputation& preComp) const 
{
  //从input中找出力
  const auto forcesInWorldFrame = centroidal_model::getContactForces(input, contactPointIndex_, info_);
  //转换坐标
  const vector3_t localForce = t_R_w * forcesInWorldFrame;
  //返回h(F)的值
  return coneConstraint(localForce);
}
VectorFunctionLinearApproximation FrictionConeConstraint::getLinearApproximation(scalar_t time, const vector_t& state,
                                                                                 const vector_t& input,
                                                                                 const PreComputation& preComp) const {
  const vector3_t forcesInWorldFrame = centroidal_model::getContactForces(input, contactPointIndex_, info_);
  const vector3_t localForce = t_R_w * forcesInWorldFrame;

  //F_local对u求导,F_local = T * u,求导后是T
  const auto localForceDerivatives = computeLocalForceDerivatives(forcesInWorldFrame);
  //h(F)对F_local求导
  const auto coneLocalDerivatives = computeConeLocalDerivatives(localForce);
  //h(F)对u求导
  const auto coneDerivatives = computeConeConstraintDerivatives(coneLocalDerivatives, localForceDerivatives);
  
  VectorFunctionLinearApproximation linearApproximation;
  //h(F)的值和导数
  linearApproximation.f = coneConstraint(localForce);
  linearApproximation.dfdx = matrix_t::Zero(1, state.size());
  linearApproximation.dfdu = frictionConeInputDerivative(input.size(), coneDerivatives);
  return linearApproximation;
}

df/du

FrictionConeConstraint::LocalForceDerivatives FrictionConeConstraint::computeLocalForceDerivatives(
    const vector3_t& forcesInWorldFrame) const {
  LocalForceDerivatives localForceDerivatives{};
  localForceDerivatives.dF_du = t_R_w;
  return localForceDerivatives;
}

dh/df, dh/dff


FrictionConeConstraint::ConeLocalDerivatives FrictionConeConstraint::computeConeLocalDerivatives(const vector3_t& localForces) const {
  const auto F_x_square = localForces.x() * localForces.x();
  const auto F_y_square = localForces.y() * localForces.y();
  const auto F_tangent_square = F_x_square + F_y_square + config_.regularization;
  const auto F_tangent_norm = sqrt(F_tangent_square);
  const auto F_tangent_square_pow32 = F_tangent_norm * F_tangent_square;  // = F_tangent_square ^ (3/2)

  ConeLocalDerivatives coneDerivatives{};
  //对h(F) = u * (Fz + gripperForce) - sqrt(Fx * Fx + Fy * Fy + regularization)求一阶偏导
  coneDerivatives.dCone_dF(0) = -localForces.x() / F_tangent_norm;// dh/dx
  coneDerivatives.dCone_dF(1) = -localForces.y() / F_tangent_norm;// dh/dy
  coneDerivatives.dCone_dF(2) = config_.frictionCoefficient;// dh/du

  //二阶偏导
  coneDerivatives.d2Cone_dF2(0, 0) = -(F_y_square + config_.regularization) / F_tangent_square_pow32;
  coneDerivatives.d2Cone_dF2(0, 1) = localForces.x() * localForces.y() / F_tangent_square_pow32;
  coneDerivatives.d2Cone_dF2(0, 2) = 0.0;
  coneDerivatives.d2Cone_dF2(1, 0) = coneDerivatives.d2Cone_dF2(0, 1);
  coneDerivatives.d2Cone_dF2(1, 1) = -(F_x_square + config_.regularization) / F_tangent_square_pow32;
  coneDerivatives.d2Cone_dF2(1, 2) = 0.0;
  coneDerivatives.d2Cone_dF2(2, 0) = 0.0;
  coneDerivatives.d2Cone_dF2(2, 1) = 0.0;
  coneDerivatives.d2Cone_dF2(2, 2) = 0.0;

  return coneDerivatives;
}

H(F)计算

\(h(F) = u(F_z + F_{gripper}) - \sqrt{F^2_x + F^2_y + \epsilon} >= 0\)

vector_t FrictionConeConstraint::coneConstraint(const vector3_t& localForces) const {
  const auto F_tangent_square = localForces.x() * localForces.x() + localForces.y() * localForces.y() + config_.regularization;
  const auto F_tangent_norm = sqrt(F_tangent_square);
  const scalar_t coneConstraint = config_.frictionCoefficient * (localForces.z() + config_.gripperForce) - F_tangent_norm;
  return (vector_t(1) << coneConstraint).finished();
}

dh/du, dh/duu


FrictionConeConstraint::ConeDerivatives FrictionConeConstraint::computeConeConstraintDerivatives(
    const ConeLocalDerivatives& coneLocalDerivatives, const LocalForceDerivatives& localForceDerivatives) const {
  ConeDerivatives coneDerivatives;
  // First order derivatives
  coneDerivatives.dCone_du.noalias() = coneLocalDerivatives.dCone_dF.transpose() * localForceDerivatives.dF_du;

  // Second order derivatives
  coneDerivatives.d2Cone_du2.noalias() =
      localForceDerivatives.dF_du.transpose() * coneLocalDerivatives.d2Cone_dF2 * localForceDerivatives.dF_du;

  return coneDerivatives;
}

标签:square,const,d2Cone,coneDerivatives,FrictionConeConstraint,localForces,约束,tangen
From: https://www.cnblogs.com/penuel/p/18597399

相关文章

  • 表的完整性约束
    为防止不符合规范的数据存入数据库,在用户对数据进行插入、修改、删除等操作时,MySQL提供了一种机制来检查数据库中的数据是否满足规定的条件,以保证数据库中数据的准确性和一致性,这种机制就是完整性约束。MySQL中主要支持以下几种种完整性约束,如表所示。其中Check约束是MySQL8中......
  • Jetpack Compose学习(14)——ConstraintLayout约束布局使用
    原文地址:JetpackCompose学习(14)——ConstraintLayout约束布局使用-Stars-One的杂货小窝本文阅读之前,需要了解ConstraintLayout的使用!各位可查阅我的ConstraintLayout使用一文本系列以往文章请查看此分类链接Jetpackcompose学习引入依赖implementation("androidx.c......
  • 如何约束布局大小
    文章目录1概念介绍2使用方法3示例代码我们在上一章回中介绍了CardWidget相关的内容,,本章回中将介绍AspectRatioWidget.闲话休提,让我们一起TalkFlutter吧。1概念介绍我们将要介绍的AspectRatioWidget是一个布局约束类组件,在二十一章回中介绍过这方面......
  • 差分约束 + 01BFS
    属于简单知识点的补档。差分约束差分约束系统是一种特殊的\(n\)元一次不等式组,包含\(n\)个变量\(x_1,\dots,x_n\)和\(m\)个约束条件,每个约束条件形如\(x_i-x_j\lec_k\),其中\(c_k\)是常数。我们要解决的问题是求出\(x_1,\dots,x_n\)的一组解。差分约束问题是最短......
  • mysql约束
    #创建一个表#需求:id为主键,并自增;name不能为空,且不可重复;age年龄在0-120之间;status状态默认为1,gender性别要求无createtableperson(idintprimarykeyauto_incrementcomment'主键',namevarchar(10)notnulluniquecomment'名字',ageintche......
  • 多智能体系统的约束驱动最优控制:高速公路车队案例研究(Matlab代码实现)
      ......
  • 差分约束系统
    差分约束给出\(n\)个活动,设\(t_i\)表示第\(i\)个活动开始的时间。这些活动满足以下\(m\)个类似关系:\[\begin{cases}t_{i1}-t_{j1}<=B_1\\t_{i2}-t_{j2}<=B_2\\\dots\\t_{im}-t_{jm}<=B_m\end{cases}\]其中\(1<=i_1,i_2,\dots,i_m,j_1,j_2,\dots,j_m<=n\)求满......
  • C++20中的Concepts 与 Java/C#中的范型约束
    C++20中的Concepts与Java/C#中的范型约束大家好!最近对C++20中的Concepts非常上头,上一篇聊了C++20中的Concepts与TypeScript,那么今天,就索性连Java和C#中的相似特性一起聊了算了。C++20引入了概念(Concepts),它是一种用来对模板参数进行约束的机制,能够提升模板编程的类型安......
  • [MySQL]第六章:MySQL表的约束
    本专栏内容为:MySQL学习专栏......
  • FPGA时序约束基础
    一、时序约束的目的由于实际信号在FPGA内部期间传输时,由于触发器等逻辑期间并非理想期间,因此不可避免地存在传输延时,这种延迟在高速工作频率、高逻辑级数时会造成后级触发器地建立时间和保持时间不满足,造成时序违例。(这也是为什么需要把FPGA设计不能以高级编程语言思想看的原因,设......