6#include "Eigen/src/Core/Matrix.h"
7#include "Eigen/src/Geometry/Quaternion.h"
10#include "transform.hpp"
30template <
typename Scalar = DefaultScalar>
32template <
typename Scalar = DefaultScalar>
34template <
typename Scalar = DefaultScalar>
36template <
typename Scalar = DefaultScalar>
39template <
typename Scalar>
64 Eigen::AngleAxis<Scalar>
66 Eigen::AngleAxis<Scalar>
69 Eigen::Matrix<Scalar, 3, 3>
106 child->parent =
this;
179template <
typename Scalar>
247 virtual void CalcBackward() {}
264template <
typename Scalar>
274 Eigen::Matrix<Scalar, 6, 1>::Constant(1);
394 Eigen::Matrix<Scalar, 6, 1>
error;
400 for (
int i = 0;; i++)
402 if (
tmp->parent ==
nullptr)
456 (Eigen::Quaternion<Scalar>(this->runtime_.
target.
rotation).conjugate() *
501 joint->runtime_.target_axis);
505 joint->runtime_.target.rotation;
507 joint->SetTarget(
joint->runtime_.target_angle.angle() +
551template <
typename Scalar>
633 joint->runtime_.inertia =
joint->child->param_.inertia
634 .Translate(
joint->runtime_.state.translation -
635 joint->child->runtime_.state.translation)
636 .Rotate(
joint->child->runtime_.state.rotation /
637 joint->runtime_.state.rotation);
640 joint->runtime_.inertia, Eigen::Quaternion<Scalar>(
joint->runtime_.state_angle));
651 return ErrorCode::OK;
661 joint->child->param_.inertia
662 .Translate(
parent->runtime_.state.translation -
663 joint->child->runtime_.state.translation)
664 .Rotate(
parent->runtime_.state.rotation /
joint->runtime_.state.rotation);
673 return ErrorCode::OK;
687 joint->runtime_.state.rotation *
joint->runtime_.state_angle,
688 joint->runtime_.state.translation);
693 joint->runtime_.state_axis =
joint->runtime_.state.rotation *
joint->param_.axis;
694 joint->runtime_.target_axis =
joint->runtime_.state_axis;
696 joint->runtime_.target =
joint->runtime_.state;
697 joint->runtime_.target_angle =
joint->runtime_.state_angle;
698 joint->child->runtime_.target =
joint->child->runtime_.state;
705 return ErrorCode::OK;
720 joint->runtime_.target.rotation *
joint->runtime_.target_angle,
721 joint->runtime_.target.translation);
726 joint->runtime_.target_axis =
joint->runtime_.target.rotation *
joint->param_.axis;
733 return ErrorCode::OK;
744 joint->child->runtime_.state);
750 return ErrorCode::OK;
三维坐标轴类,继承自 Eigen::Matrix<Scalar, 3, 1>。 A 3D axis class, inheriting from Eigen::Matrix<Scalar,...
质心信息表示类。Represents the center of mass information.
表示刚体的惯性张量和质量信息的类。Provides a class to represent the inertia tensor and mass of a rigid body.
Inertia Rotate(const Eigen::Matrix< Scalar, 3, 3 > &R) const
旋转惯性张量。Rotates the inertia tensor.
机器人末端点(EndPoint)类,继承自 Object。 EndPoint class representing the end effector of a robotic system,...
Eigen::Matrix< Scalar, 3, 1 > GetPositionError()
获取末端点位置误差。 Gets the position error of the end effector.
Scalar max_line_velocity_
Scalar max_angular_velocity_
void SetMaxAngularVelocity(Scalar velocity)
设置最大角速度。 Sets the maximum angular velocity.
Eigen::Matrix< Scalar, 6, 1 > err_weight_
误差权重矩阵。 Error weight matrix.
Quaternion< Scalar > target_quat_
目标四元数方向。 Target quaternion orientation.
void SetTargetQuaternion(const Quaternion< Scalar > &quat)
设置目标四元数方向。 Sets the target quaternion orientation.
Eigen::Matrix< Scalar, 6, Eigen::Dynamic > * jacobian_matrix_
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > * delta_theta_
关节角度调整量。 Joint angle adjustments.
void SetTargetPosition(const Position< Scalar > &pos)
设置目标位置。 Sets the target position.
Eigen::Matrix< Scalar, 6, 1 > CalcBackward(Scalar dt, int max_step=10, Scalar max_err=1e-3, Scalar step_size=1.0)
计算逆运动学(IK),调整关节角度以达到目标位置和方向。 Computes inverse kinematics (IK) to adjust joint angles for reaching the...
Eigen::Quaternion< Scalar > GetQuaternionError()
获取末端点方向误差。 Gets the orientation error of the end effector.
void SetErrorWeight(const Eigen::Matrix< Scalar, 6, 1 > &weight)
设置误差权重矩阵。 Sets the error weight matrix.
Position< Scalar > target_pos_
目标位置。 Target position.
void SetMaxLineVelocity(Scalar velocity)
设置最大线速度。 Sets the maximum linear velocity.
EndPoint(Inertia< Scalar > &inertia)
构造 EndPoint 末端点对象。 Constructs an EndPoint object.
关节(Joint)类,表示机器人连杆间的旋转关节。 Joint class representing a rotational joint between robot links.
Object< Scalar > * parent
指向父物体的指针。 Pointer to the parent object.
Object< Scalar > * child
指向子物体的指针。 Pointer to the child object.
Joint(Axis< Scalar > axis, Object< Scalar > *parent, Transform< Scalar > &parent2this, Object< Scalar > *child, Transform< Scalar > &this2child)
构造 Joint 关节对象。 Constructs a Joint object.
void SetBackwardMult(Scalar mult)
设置逆向运动学计算的步长系数。 Sets the step size coefficient for inverse kinematics calculations.
Param param_
关节的参数配置。 Parameters of the joint.
Runtime runtime_
关节的运行时数据。 Runtime data of the joint.
void SetState(Scalar state)
设置关节当前状态角度。 Sets the current state angle of the joint.
void SetTarget(Scalar target)
设置关节的目标角度。 Sets the target angle of the joint.
机器人中的物体(Object)类。 Object class representing an entity in the robot.
void SetPosition(const Position< Scalar > &pos)
设置物体的位置信息。 Sets the position of the object.
Object(Inertia< Scalar > &inertia)
使用惯性参数构造 Object 对象。 Constructs an Object using inertia parameters.
Runtime runtime_
物体运行时状态。 Object runtime data.
Joint< Scalar > * parent
指向父关节的指针。 Pointer to the parent joint.
List::Node< Joint< Scalar > * > Link
关节链接类型。 Type for linking joints.
Param param_
物体参数。 Object parameters.
List joints
物体的关节列表。 List of joints associated with the object.
void SetQuaternion(const Quaternion< Scalar > &quat)
设置物体的旋转信息(四元数表示)。 Sets the rotation of the object using a quaternion.
机器人起始点(StartPoint)类,继承自 Object。 StartPoint class representing the base or root of a robotic kinematic...
void CalcInertia()
计算机器人系统的惯性分布。 Computes the inertia distribution of the robotic system.
StartPoint(Inertia< Scalar > &inertia)
构造 StartPoint 物体对象。 Constructs a StartPoint object.
static ErrorCode ForwardForeachFunLoop(Joint< Scalar > *joint, StartPoint< Scalar > &start)
计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.
void CalcForward()
计算当前状态的前向运动学(FK)。 Computes forward kinematics (FK) for the current state.
static ErrorCode InertiaForeachFunLoopStart(Joint< Scalar > *joint, Joint< Scalar > *parent)
计算起始点惯性(首次遍历)。 Computes the inertia of the start point (first traversal).
void CalcCenterOfMass()
计算机器人系统的质心。 Computes the center of mass (CoM) of the robotic system.
void CalcTargetForward()
计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.
static ErrorCode InertiaForeachFunLoop(Joint< Scalar > *joint, Joint< Scalar > *parent)
计算机器人系统的惯性(后续遍历)。 Computes the inertia of the robotic system (subsequent traversal).
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.
static ErrorCode TargetForwardForeachFunLoop(Joint< Scalar > *joint, StartPoint< Scalar > &start)
计算目标状态的前向运动学(FK)。 Computes forward kinematics (FK) for the target state.
数据节点模板,继承自 BaseNode,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data...
链表实现,用于存储和管理数据节点。 A linked list implementation for storing and managing data nodes.
ErrorCode Foreach(Func func)
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function.
三维空间中的位置向量 / 3D position vector
四元数表示与运算,继承自 Eigen::Quaternion / Quaternion representation and operations, inheriting from Eigen::Qua...
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
关节参数结构体。 Structure containing joint parameters.
Axis< Scalar > axis
关节旋转轴。 Rotation axis of the joint.
Transform< Scalar > this2child
Scalar ik_mult
逆向运动学步长系数。 Step size coefficient for inverse kinematics.
Transform< Scalar > parent2this
关节运行时状态结构体。 Structure containing runtime state of the joint.
Eigen::Matrix< Scalar, 3, 3 > inertia
关节的惯性矩阵。 Inertia matrix of the joint.
Transform< Scalar > target
目标状态的变换矩阵。 Transformation matrix of the target state.
Axis< Scalar > target_axis
目标关节轴向。 Target axis orientation.
Eigen::AngleAxis< Scalar > state_angle
当前关节角度状态。 Current joint angle state.
Axis< Scalar > state_axis
当前关节轴向。 Current axis orientation.
Eigen::AngleAxis< Scalar > target_angle
目标关节角度状态。 Target joint angle state.
Transform< Scalar > state
当前状态的变换矩阵。 Transformation matrix of the current state.
物体参数结构体,存储物体的惯性参数。 Structure storing inertia parameters of the object.
物体运行时状态结构体,存储物体的变换信息。 Structure storing runtime transformation data of the object.
Transform< Scalar > target
物体的目标状态变换矩阵。 Transformation matrix of the target state.
Transform< Scalar > state
物体的当前状态变换矩阵。 Transformation matrix of the current state.