libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Kinematic::StartPoint< Scalar > Class Template Reference

机器人起始点(StartPoint)类,继承自 Object。 StartPoint class representing the base or root of a robotic kinematic chain, inheriting from Object. More...

#include <kinematic.hpp>

Inheritance diagram for LibXR::Kinematic::StartPoint< Scalar >:
[legend]
Collaboration diagram for LibXR::Kinematic::StartPoint< Scalar >:
[legend]

Public Member Functions

 StartPoint (Inertia< Scalar > &inertia)
 构造 StartPoint 物体对象。 Constructs a StartPoint object.
 
void CalcForward ()
 计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.
 
void CalcTargetForward ()
 计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.
 
void CalcInertia ()
 计算机器人系统的惯性分布。 Computes the inertia distribution of the robotic system.
 
void CalcCenterOfMass ()
 计算机器人系统的质心。 Computes the center of mass (CoM) of the robotic system.
 
- Public Member Functions inherited from LibXR::Kinematic::Object< Scalar >
 Object (Inertia< Scalar > &inertia)
 使用惯性参数构造 Object 对象。 Constructs an Object using inertia parameters.
 
void SetPosition (const Position< Scalar > &pos)
 设置物体的位置信息。 Sets the position of the object.
 
void SetQuaternion (const Quaternion< Scalar > &quat)
 设置物体的旋转信息(四元数表示)。 Sets the rotation of the object using a quaternion.
 
virtual void CalcBackward ()
 

Static Public Member Functions

static ErrorCode InertiaForeachFunLoopStart (Joint< Scalar > *joint, Joint< Scalar > *parent)
 计算起始点惯性(首次遍历)。 Computes the inertia of the start point (first traversal).
 
static ErrorCode InertiaForeachFunLoop (Joint< Scalar > *joint, Joint< Scalar > *parent)
 计算机器人系统的惯性(后续遍历)。 Computes the inertia of the robotic system (subsequent traversal).
 
static ErrorCode ForwardForeachFunLoop (Joint< Scalar > *joint, StartPoint< Scalar > &start)
 计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.
 
static ErrorCode TargetForwardForeachFunLoop (Joint< Scalar > *joint, StartPoint< Scalar > &start)
 计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.
 
static ErrorCode CenterOfMassForeachFunLoop (Joint< Scalar > *joint, StartPoint< Scalar > &start)
 计算系统的质心。 Computes the center of mass of the system.
 

Data Fields

CenterOfMass< Scalar > cog
 机器人质心。 The center of mass of the robot.
 
- Data Fields inherited from LibXR::Kinematic::Object< Scalar >
List joints
 物体的关节列表。 List of joints associated with the object.
 
Joint< Scalar > * parent = nullptr
 指向父关节的指针。 Pointer to the parent joint.
 
Param param_
 物体参数。 Object parameters.
 
Runtime runtime_
 物体运行时状态。 Object runtime data.
 

Additional Inherited Members

- Public Types inherited from LibXR::Kinematic::Object< Scalar >
typedef List::Node< Joint< Scalar > * > Link
 关节链接类型。 Type for linking joints.
 

Detailed Description

template<typename Scalar>
class LibXR::Kinematic::StartPoint< Scalar >

机器人起始点(StartPoint)类,继承自 Object。 StartPoint class representing the base or root of a robotic kinematic chain, inheriting from Object.

该类作为运动学链的起始点,负责计算前向运动学、逆向运动学、 质心计算以及惯性计算等关键功能。 This class serves as the starting point of a kinematic chain and is responsible for computing forward kinematics, inverse kinematics, center of mass calculation, and inertia computation.

Template Parameters
Scalar角度和位置的存储类型。 The storage type for angles and positions.

Definition at line 554 of file kinematic.hpp.

Constructor & Destructor Documentation

◆ StartPoint()

template<typename Scalar >
LibXR::Kinematic::StartPoint< Scalar >::StartPoint ( Inertia< Scalar > & inertia)
inline

构造 StartPoint 物体对象。 Constructs a StartPoint object.

Parameters
inertia物体的惯性参数。 The inertia parameters of the object.

Definition at line 565 of file kinematic.hpp.

565: Object<Scalar>(inertia) {}
Object(Inertia< Scalar > &inertia)
使用惯性参数构造 Object 对象。 Constructs an Object using inertia parameters.

Member Function Documentation

◆ CalcCenterOfMass()

template<typename Scalar >
void LibXR::Kinematic::StartPoint< Scalar >::CalcCenterOfMass ( )
inline

计算机器人系统的质心。 Computes the center of mass (CoM) of the robotic system.

该函数遍历所有关节,并利用惯性计算系统整体质心位置。 This function traverses all joints and uses inertia calculations to determine the overall center of mass.

Definition at line 622 of file kinematic.hpp.

623 {
624 this->cog = CenterOfMass<Scalar>(this->param_.inertia, this->runtime_.state);
626 }
Param param_
物体参数。 Object parameters.
List joints
物体的关节列表。 List of joints associated with the object.
static ErrorCode CenterOfMassForeachFunLoop(Joint< Scalar > *joint, StartPoint< Scalar > &start)
计算系统的质心。 Computes the center of mass of the system.
CenterOfMass< Scalar > cog
机器人质心。 The center of mass of the robot.
ErrorCode Foreach(Func func)
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function.
Definition list.hpp:172

◆ CalcForward()

template<typename Scalar >
void LibXR::Kinematic::StartPoint< Scalar >::CalcForward ( )
inline

计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.

该函数遍历所有关节,根据当前状态计算其空间变换矩阵。 This function traverses all joints and calculates their spatial transformations based on the current state.

Definition at line 575 of file kinematic.hpp.

576 {
577 this->runtime_.target = this->runtime_.state;
578 auto fun = [&](Joint<Scalar> *joint) { return ForwardForeachFunLoop(joint, *this); };
579 this->joints.template Foreach<Joint<Scalar> *>(fun);
580 }
Runtime runtime_
物体运行时状态。 Object runtime data.
static ErrorCode ForwardForeachFunLoop(Joint< Scalar > *joint, StartPoint< Scalar > &start)
计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.
Transform< Scalar > target
物体的目标状态变换矩阵。 Transformation matrix of the target state.
Transform< Scalar > state
物体的当前状态变换矩阵。 Transformation matrix of the current state.

◆ CalcInertia()

template<typename Scalar >
void LibXR::Kinematic::StartPoint< Scalar >::CalcInertia ( )
inline

计算机器人系统的惯性分布。 Computes the inertia distribution of the robotic system.

该函数遍历所有关节,并根据质心和旋转惯性矩计算整体惯性分布。 This function traverses all joints and calculates the overall inertia distribution based on the center of mass and rotational inertia matrix.

Definition at line 606 of file kinematic.hpp.

607 {
608 Joint<Scalar> *res = nullptr;
609 auto fun = [&](Joint<Scalar> *joint)
610 { return InertiaForeachFunLoopStart(joint, res); };
611 this->joints.template Foreach<Joint<Scalar> *>(fun);
612 }
static ErrorCode InertiaForeachFunLoopStart(Joint< Scalar > *joint, Joint< Scalar > *parent)
计算起始点惯性(首次遍历)。 Computes the inertia of the start point (first traversal).

◆ CalcTargetForward()

template<typename Scalar >
void LibXR::Kinematic::StartPoint< Scalar >::CalcTargetForward ( )
inline

计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.

该函数用于目标位置调整,确保所有关节正确响应目标状态的变化。 This function is used for target position adjustments, ensuring all joints correctly respond to changes in the target state.

Definition at line 590 of file kinematic.hpp.

591 {
592 this->runtime_.target = this->runtime_.state;
593 auto fun = [&](Joint<Scalar> *joint)
594 { return TargetForwardForeachFunLoop(joint, *this); };
595 this->joints.template Foreach<Joint<Scalar> *>(fun);
596 }
static ErrorCode TargetForwardForeachFunLoop(Joint< Scalar > *joint, StartPoint< Scalar > &start)
计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.

◆ CenterOfMassForeachFunLoop()

template<typename Scalar >
static ErrorCode LibXR::Kinematic::StartPoint< Scalar >::CenterOfMassForeachFunLoop ( Joint< Scalar > * joint,
StartPoint< Scalar > & start )
inlinestatic

计算系统的质心。 Computes the center of mass of the system.

Definition at line 742 of file kinematic.hpp.

744 {
745 CenterOfMass<Scalar> child_cog(joint->child->param_.inertia,
746 joint->child->runtime_.state);
747
748 start.cog += child_cog;
749
750 joint->child->joints.Foreach(TargetForwardForeachFunLoop, start);
751
752 return ErrorCode::OK;
753 }

◆ ForwardForeachFunLoop()

template<typename Scalar >
static ErrorCode LibXR::Kinematic::StartPoint< Scalar >::ForwardForeachFunLoop ( Joint< Scalar > * joint,
StartPoint< Scalar > & start )
inlinestatic

计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.

Definition at line 682 of file kinematic.hpp.

683 {
684 Transform<Scalar> t_joint(joint->parent->runtime_.state + joint->param_.parent2this);
685
686 joint->runtime_.state = t_joint;
687
688 Transform<Scalar> t_child(
689 joint->runtime_.state.rotation * joint->runtime_.state_angle,
690 joint->runtime_.state.translation);
691
692 t_child = t_child + joint->param_.this2child;
693
694 joint->child->runtime_.state = t_child;
695 joint->runtime_.state_axis = joint->runtime_.state.rotation * joint->param_.axis;
696 joint->runtime_.target_axis = joint->runtime_.state_axis;
697
698 joint->runtime_.target = joint->runtime_.state;
699 joint->runtime_.target_angle = joint->runtime_.state_angle;
700 joint->child->runtime_.target = joint->child->runtime_.state;
701
702 auto fun = [&](Joint<Scalar> *child_joint)
703 { return ForwardForeachFunLoop(child_joint, start); };
704
705 joint->child->joints.template Foreach<Joint<Scalar> *>(fun);
706
707 return ErrorCode::OK;
708 }

◆ InertiaForeachFunLoop()

template<typename Scalar >
static ErrorCode LibXR::Kinematic::StartPoint< Scalar >::InertiaForeachFunLoop ( Joint< Scalar > * joint,
Joint< Scalar > * parent )
inlinestatic

计算机器人系统的惯性(后续遍历)。 Computes the inertia of the robotic system (subsequent traversal).

Definition at line 660 of file kinematic.hpp.

661 {
662 auto new_inertia =
663 joint->child->param_.inertia
664 .Translate(parent->runtime_.state.translation -
665 joint->child->runtime_.state.translation)
666 .Rotate(parent->runtime_.state.rotation / joint->runtime_.state.rotation);
667
668 parent->runtime_.inertia = new_inertia + parent->runtime_.inertia;
669
670 auto fun_loop = [&](Joint<Scalar> *child_joint)
671 { return InertiaForeachFunLoop(child_joint, joint); };
672
673 joint->child->joints.template Foreach<Joint<Scalar> *>(fun_loop);
674
675 return ErrorCode::OK;
676 }
Joint< Scalar > * parent
指向父关节的指针。 Pointer to the parent joint.
static ErrorCode InertiaForeachFunLoop(Joint< Scalar > *joint, Joint< Scalar > *parent)
计算机器人系统的惯性(后续遍历)。 Computes the inertia of the robotic system (subsequent traversal).

◆ InertiaForeachFunLoopStart()

template<typename Scalar >
static ErrorCode LibXR::Kinematic::StartPoint< Scalar >::InertiaForeachFunLoopStart ( Joint< Scalar > * joint,
Joint< Scalar > * parent )
inlinestatic

计算起始点惯性(首次遍历)。 Computes the inertia of the start point (first traversal).

Definition at line 632 of file kinematic.hpp.

633 {
634 UNUSED(parent);
635 joint->runtime_.inertia = joint->child->param_.inertia
636 .Translate(joint->runtime_.state.translation -
637 joint->child->runtime_.state.translation)
638 .Rotate(joint->child->runtime_.state.rotation /
639 joint->runtime_.state.rotation);
640
641 joint->runtime_.inertia = Inertia<Scalar>::Rotate(
642 joint->runtime_.inertia, Eigen::Quaternion<Scalar>(joint->runtime_.state_angle));
643
644 auto fun_loop = [&](Joint<Scalar> *child_joint)
645 { return InertiaForeachFunLoop(child_joint, joint); };
646
647 auto fun_start = [&](Joint<Scalar> *child_joint)
648 { return InertiaForeachFunLoopStart(child_joint, joint); };
649
650 joint->child->joints.template Foreach<Joint<Scalar> *>(fun_loop);
651 joint->child->joints.template Foreach<Joint<Scalar> *>(fun_start);
652
653 return ErrorCode::OK;
654 }
Inertia Rotate(const Eigen::Matrix< Scalar, 3, 3 > &R) const
旋转惯性张量。Rotates the inertia tensor.
Definition inertia.hpp:162

◆ TargetForwardForeachFunLoop()

template<typename Scalar >
static ErrorCode LibXR::Kinematic::StartPoint< Scalar >::TargetForwardForeachFunLoop ( Joint< Scalar > * joint,
StartPoint< Scalar > & start )
inlinestatic

计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.

Definition at line 714 of file kinematic.hpp.

716 {
717 Transform<Scalar> t_joint(joint->parent->runtime_.target + joint->param_.parent2this);
718
719 joint->runtime_.target = t_joint;
720
721 Transform<Scalar> t_child(
722 joint->runtime_.target.rotation * joint->runtime_.target_angle,
723 joint->runtime_.target.translation);
724
725 t_child = t_child + joint->param_.this2child;
726 joint->child->runtime_.target = t_child;
727
728 joint->runtime_.target_axis = joint->runtime_.target.rotation * joint->param_.axis;
729
730 auto fun = [&](Joint<Scalar> *child_joint)
731 { return TargetForwardForeachFunLoop(child_joint, start); };
732
733 joint->child->joints.template Foreach<Joint<Scalar> *>(fun);
734
735 return ErrorCode::OK;
736 }

Field Documentation

◆ cog

template<typename Scalar >
CenterOfMass<Scalar> LibXR::Kinematic::StartPoint< Scalar >::cog

机器人质心。 The center of mass of the robot.

Definition at line 557 of file kinematic.hpp.


The documentation for this class was generated from the following file: