5 namespace robot_model {
10 : _weight(1.0
f), _x(obj[0]), _y(obj[1]), _z(obj[2])
24 matrix(0,0), matrix(0,1), matrix(0,2),
25 matrix(1,0), matrix(1,1), matrix(1,2),
26 matrix(2,0), matrix(2,1), matrix(2,2)}
31 matrix(0,0), matrix(0,1), matrix(0,2),
32 matrix(1,0), matrix(1,1), matrix(1,2),
33 matrix(2,0), matrix(2,1), matrix(2,2)}
42 :
_weight(1.0
f), _x(obj[0]), _y(obj[1]), _z(obj[2])
55 :
_weight(1.0
f), _min_positions(min_positions), _max_positions(max_positions)
69 auto min_positions_array =
new double[num_joints];
74 auto max_positions_array =
new double[num_joints];
82 delete[] min_positions_array;
83 delete[] max_positions_array;
102 matrix(1, 1) =
cos(radians);
103 matrix(1, 2) = -
sin(radians);
105 matrix(2, 1) =
sin(radians);
106 matrix(2, 2) =
cos(radians);
111 if (inertia.size() != 6)
116 inertia[0] = inertia[1] = inertia[2] = 0.4f * mass * radius * radius;
117 inertia[3] = inertia[4] = inertia[5] = 0;
122 if (inertia.size() != 6)
127 inertia[1] = inertia[2] = mass * length * length / 12.f;
128 inertia[0] = inertia[3] = inertia[4] = inertia[5] = 0;
134 internal_,
nullptr, 0, element, combine ? 1 : 0);
156 double transform[16];
165 double transform[16];
187 const Eigen::Matrix4d& com,
188 const Eigen::VectorXd& inertia,
190 const Eigen::Matrix4d& output,
193 if (inertia.size() != 6)
197 double com_array[16];
198 double inertia_array[6];
199 double output_array[16];
216 com_array, inertia_array, mass, 1, output_array);
218 return tryAdd(body, combine);
231 Matrix4d com = Matrix4d::Identity();
233 Matrix4d input_to_axis = Matrix4d::Identity();
275 if (!
addRigidBody(com, inertia, mass, input_to_axis,
false))
289 Matrix4d com = Matrix4d::Identity();
290 Matrix4d output = Matrix4d::Identity();
294 double mass = 0.4f * (extension - 0.03) + 0.26f;
297 double edge_to_center = .0175f;
304 -edge_to_center *
sin(twist),
305 edge_to_center * (1 +
cos(twist)));
317 Matrix4d com = Matrix4d::Identity();
318 Matrix4d output = Matrix4d::Identity();
348 double y_dist = -0.0225;
374 getFK(frame_type, positions, frames);
380 auto positions_array =
new double[positions.size()];
386 auto frame_array =
new double[16 * num_frames];
389 delete[] positions_array;
391 frames.resize(num_frames);
392 for (
size_t i = 0; i < num_frames; ++i)
397 delete[] frame_array;
403 auto positions_array =
new double[positions.size()];
409 double transform_array[16];
411 delete[] positions_array;
420 getJ(frame_type, positions, jacobians);
425 auto positions_array =
new double[positions.size()];
432 size_t num_dofs = positions.size();
433 size_t rows = 6 * num_frames;
434 size_t cols = num_dofs;
435 auto jacobians_array =
new double[rows * cols];
437 delete[] positions_array;
438 jacobians.resize(num_frames);
439 for (
size_t i = 0; i < num_frames; ++i)
444 delete[] jacobians_array;
458 size_t num_dofs = positions.size();
459 jacobian.resize(6, num_dofs);
460 jacobian = *tmp_jacobians.rbegin();
466 auto masses_array =
new double[num_masses];
472 delete[] masses_array;
HebiStatusCode hebiIKAddObjectiveEndEffectorSO3(HebiIKPtr ik, double weight, size_t end_effector_index, const double *matrix)
Add an objective that optimizes for the end effector output frame orientation to be given by the 3x3 ...
Eigen::VectorXd _max_positions
std::vector< Matrix4d, Eigen::aligned_allocator< Eigen::Matrix4d > > Matrix4dVector
static void setTranslate(Eigen::Matrix4d &matrix, double x, double y, double z)
Returned when an accessor function attempts to retrieve a field which is not set. ...
HebiStatusCode hebiIKAddObjectiveEndEffectorTipAxis(HebiIKPtr ik, double weight, size_t end_effector_index, double x, double y, double z)
Add an objective that points the end effector's z axis in a given direction. Note that this is incomp...
HebiStatusCode hebiRobotModelGetForwardKinematics(HebiRobotModelPtr robot_model, HebiFrameType frame_type, const double *positions, double *frames)
Generates the transforms for the forward kinematics of the given robot model.
void getMasses(Eigen::VectorXd &masses) const
Returns the mass of each rigid body (or combination of rigid bodies) in the robot model...
HebiStatusCode hebiRobotModelGetJacobians(HebiRobotModelPtr robot_model, HebiFrameType frame_type, const double *positions, double *jacobians)
Generates the jacobian for each frame in the given kinematic tree.
HebiStatusCode addObjective(HebiIKPtr ik) const override
static const std::map< ActuatorType, double > actuator_masses_
EndEffectorPositionObjective(const Eigen::Vector3d &)
A matrix or vector expression mapping an existing array of data.
bool addJoint(HebiJointType joint_type, bool combine)
Adds a degree of freedom about the specified axis.
HebiRobotModelElementPtr hebiRobotModelElementCreateJoint(HebiJointType joint_type)
Creates a one-dof joint about the specified axis.
HebiStatusCode hebiRobotModelGetMasses(HebiRobotModelPtr robot_model, double *masses)
Fill in the masses vector with the mass of each body with mass in the kinematic tree, reported in a depth-first ordering.
struct _HebiIK * HebiIKPtr
HebiRobotModelPtr hebiRobotModelCreate(void)
Creates an object to hold a robot model (tree topology). This structure has a single output available...
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
HebiStatusCode addObjective(HebiIKPtr ik) const override
bool addLink(LinkType link_type, double extension, double twist)
Add an element to the robot model with the kinematics/dynamics of a link between two actuators...
void getJ(HebiFrameType, const Eigen::VectorXd &positions, MatrixXdVector &jacobians) const
Generates the Jacobian for each frame in the given kinematic tree.
HebiRobotModelPtr const internal_
void setBaseFrame(const Eigen::Matrix4d &base_frame)
Set the transform from a world coordinate system to the input of the root element in this robot model...
JointLimitConstraint(const Eigen::VectorXd &min_positions, const Eigen::VectorXd &max_positions)
Eigen::VectorXd _min_positions
static void setRodXAxisInertia(Eigen::VectorXd &inertia, double mass, double length)
void getForwardKinematics(HebiFrameType, const Eigen::VectorXd &positions, Matrix4dVector &frames) const
Generates the forward kinematics for the given robot model.
bool tryAdd(HebiRobotModelElementPtr element, bool combine)
size_t hebiRobotModelGetNumberOfDoFs(HebiRobotModelPtr robot_model)
Returns the number of settable degrees of freedom in the kinematic tree. (This is equal to the number...
void hebiRobotModelElementRelease(HebiRobotModelElementPtr element)
Frees resources created by this element.
EIGEN_DEVICE_FUNC const CosReturnType cos() const
HebiStatusCode addObjective(HebiIKPtr ik) const override
void getFK(HebiFrameType, const Eigen::VectorXd &positions, Matrix4dVector &frames) const
Generates the forward kinematics for the given robot model.
HebiRobotModelElementPtr hebiRobotModelElementCreateRigidBody(const double *com, const double *inertia, double mass, size_t num_outputs, const double *outputs)
Creates a rigid body defining static transforms to the given outputs.
Eigen::Matrix4d getBaseFrame() const
Returns the transform from the world coordinate system to the root kinematic body, as set by the setBaseFrame function.
void getEndEffector(const Eigen::VectorXd &positions, Eigen::Matrix4d &transform) const
Generates the forward kinematics to the end effector (leaf node) frame(s).
RobotModel()
Creates a robot model object with no bodies and an identity base frame.
struct _HebiRobotModelElement * HebiRobotModelElementPtr
HebiStatusCode hebiIKAddObjectiveEndEffectorPosition(HebiIKPtr ik, float weight, size_t end_effector_index, double x, double y, double z)
Add an objective that optimizes for the end effector output frame origin to be at the given (x...
bool addRigidBody(const Eigen::Matrix4d &com, const Eigen::VectorXd &inertia, double mass, const Eigen::Matrix4d &output, bool combine)
Adds a rigid body with the specified properties to the robot model.
void getJEndEffector(const Eigen::VectorXd &positions, Eigen::MatrixXd &jacobian) const
Generates the Jacobian for the end effector (leaf node) frames(s).
HebiStatusCode hebiRobotModelAdd(HebiRobotModelPtr robot_model, HebiRobotModelElementPtr existing_element, size_t output_index, HebiRobotModelElementPtr new_element, int32_t combine)
Add an element to a parent element connected to a robot model object.
Success; no failures occurred.
HebiStatusCode hebiRobotModelSetBaseFrame(HebiRobotModelPtr robot_model, const double *transform)
Sets the fixed transform from the origin to the input of the first added model element.
HebiStatusCode addObjective(HebiIKPtr ik) const override
EndEffectorTipAxisObjective(const Eigen::Vector3d &)
bool addBracket(BracketType bracket_type)
Add an element to the robot model with the kinematics/dynamics of a bracket between two actuators...
size_t getFrameCount(HebiFrameType frame_type) const
Return the number of frames in the forward kinematics.
size_t getDoFCount() const
Returns the number of settable degrees of freedom in the kinematic tree. (This is equal to the number...
void hebiRobotModelRelease(HebiRobotModelPtr robot_model)
Frees resources created by this robot model object.
static void setRotX(Eigen::Matrix4d &matrix, double radians)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
HebiStatusCode hebiRobotModelGetBaseFrame(HebiRobotModelPtr robot_model, double *transform)
Retreives the fixed transform from the origin to the input of the first added model element...
HebiStatusCode hebiIKAddConstraintJointAngles(HebiIKPtr ik, double weight, size_t num_joints, const double *min_positions, const double *max_positions)
Define joint angle constraints.
void getJacobianEndEffector(const Eigen::VectorXd &positions, Eigen::MatrixXd &jacobian) const
Generates the Jacobian for the end effector (leaf node) frames(s).
size_t hebiRobotModelGetNumberOfFrames(HebiRobotModelPtr robot_model, HebiFrameType frame_type)
Return the number of frames in the forward kinematic tree of the robot model.
EndEffectorSO3Objective(const Eigen::Matrix3d &)
void getJacobians(HebiFrameType, const Eigen::VectorXd &positions, MatrixXdVector &jacobians) const
Generates the Jacobian for each frame in the given kinematic tree.
static void setSphereInertia(Eigen::VectorXd &inertia, double mass, double radius)
bool addActuator(ActuatorType actuator_type)
Add an element to the robot model with the kinematics/dynamics of an X5 actuator. ...
std::vector< MatrixXd, Eigen::aligned_allocator< Eigen::MatrixXd > > MatrixXdVector
~RobotModel() noexcept
Destructor cleans up robot model object, including all managed elements.