6 namespace robot_model {
11 : _weight(1.0f), _x(obj[0]), _y(obj[1]), _z(obj[2]) {}
23 matrix(0,0), matrix(1,0), matrix(2,0),
24 matrix(0,1), matrix(1,1), matrix(2,1),
25 matrix(0,2), matrix(1,2), matrix(2,2)}
30 matrix(0,0), matrix(1,0), matrix(2,0),
31 matrix(0,1), matrix(1,1), matrix(2,1),
32 matrix(0,2), matrix(1,2), matrix(2,2)}
41 :
_weight(1.0f), _x(obj[0]), _y(obj[1]), _z(obj[2]) {}
51 :
_weight(1.0f), _min_positions(min_positions), _max_positions(max_positions) {}
54 const Eigen::VectorXd& max_positions)
63 auto min_positions_array =
new double[num_joints];
65 Map<Eigen::VectorXd> tmp(min_positions_array, num_joints);
68 auto max_positions_array =
new double[num_joints];
70 Map<Eigen::VectorXd> tmp(max_positions_array, num_joints);
76 delete[] min_positions_array;
77 delete[] max_positions_array;
101 if (
internal ==
nullptr) {
108 for (
size_t i = 0; i < num_warnings; ++i)
112 return std::unique_ptr<RobotModel>(
new RobotModel(
internal));
119 double transform[16];
120 Map<Matrix<double, 4, 4>> tmp(transform);
127 double transform[16];
131 Map<const Matrix<double, 4, 4>> tmp(transform);
145 const Eigen::Matrix4d& output) {
146 if (inertia.size() != 6)
150 double com_array[16];
151 double inertia_array[6];
152 double output_array[16];
156 Map<Matrix<double, 4, 4>> tmp(com_array);
160 Map<Eigen::VectorXd> tmp(inertia_array, 6);
164 Map<Matrix<double, 4, 4>> tmp(output_array);
180 if (element ==
nullptr)
189 static_cast<HebiLinkInputType>(input_type),
190 static_cast<HebiLinkOutputType>(output_type),
192 if (element ==
nullptr)
199 if (element ==
nullptr)
207 if (element ==
nullptr)
214 getFK(frame_type, positions, frames);
219 auto positions_array =
new double[positions.size()];
221 Map<Eigen::VectorXd> tmp(positions_array, positions.size());
225 auto frame_array =
new double[16 * num_frames];
228 delete[] positions_array;
230 frames.resize(num_frames);
231 for (
size_t i = 0; i < num_frames; ++i) {
232 Map<Matrix<double, 4, 4>> tmp(frame_array + i * 16);
235 delete[] frame_array;
240 auto positions_array =
new double[positions.size()];
242 Map<Eigen::VectorXd> tmp(positions_array, positions.size());
246 double transform_array[16];
248 delete[] positions_array;
250 Map<Matrix<double, 4, 4>> tmp(transform_array);
257 getJ(frame_type, positions, jacobians);
261 auto positions_array =
new double[positions.size()];
263 Map<Eigen::VectorXd> tmp(positions_array, positions.size());
268 size_t num_dofs = positions.size();
269 size_t rows = 6 * num_frames;
270 size_t cols = num_dofs;
271 auto jacobians_array =
new double[rows * cols];
273 delete[] positions_array;
274 jacobians.resize(num_frames);
275 for (
size_t i = 0; i < num_frames; ++i) {
276 Map<Matrix<double, Dynamic, Dynamic>> tmp(jacobians_array + i * cols * 6, 6, cols);
279 delete[] jacobians_array;
291 size_t num_dofs = positions.size();
292 jacobian.resize(6, num_dofs);
293 jacobian = *tmp_jacobians.rbegin();
298 auto masses_array =
new double[num_masses];
301 Map<VectorXd> tmp(masses_array, num_masses);
304 delete[] masses_array;
309 metadata.resize(num_elems);
310 for (
auto i = 0; i < num_elems; i++) {
Eigen::VectorXd _max_positions
std::vector< Matrix4d, Eigen::aligned_allocator< Eigen::Matrix4d > > Matrix4dVector
HebiStatusCode hebiRobotModelGetForwardKinematics(HebiRobotModelPtr robot_model, HebiFrameType frame_type, const double *positions, double *frames, HebiMatrixOrdering ordering)
Generates the transforms for the forward kinematics of the given robot model.
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 hebiRobotModelGetJacobians(HebiRobotModelPtr robot_model, HebiFrameType frame_type, const double *positions, double *jacobians, HebiMatrixOrdering ordering)
Generates the jacobian for each frame in the given kinematic tree.
HebiStatusCode hebiIKAddObjectiveEndEffectorSO3(HebiIKPtr ik, double weight, size_t end_effector_index, const double *matrix, HebiMatrixOrdering ordering)
Add an objective that optimizes for the end effector output frame orientation to be given by the 3x3 ...
HebiStatusCode addObjective(HebiIKPtr ik) const override
void getMetadata(std::vector< MetadataBase > &metadata) const
Returns the metadata of each component of the robot model.
EndEffectorPositionObjective(const Eigen::Vector3d &)
HebiRobotModelElementPtr hebiRobotModelElementCreateJoint(HebiJointType joint_type)
RobotModel API.
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.
HebiRobotModelPtr hebiRobotModelCreate(void)
Creates an object to hold a robot model (tree topology). This structure has a single output available...
HebiStatusCode hebiRobotModelGetElementMetadata(HebiRobotModelPtr model, size_t index, HebiRobotModelElementMetadata *output)
Retrieves metadata about an element in the robot model. This metadata includes what type of element t...
HebiRobotModelElementPtr hebiRobotModelElementCreateActuator(HebiActuatorType actuator_type)
Creates a robot model element corresponding to a standard HEBI actuator.
bool addLink(robot_model::LinkType link_type, double extension, double twist, LinkInputType input_type=LinkInputType::RightAngle, LinkOutputType output_type=LinkOutputType::RightAngle)
Add an element to the robot model with the kinematics/dynamics of a link between two actuators...
HebiStatusCode addObjective(HebiIKPtr ik) const override
const char * hebiRobotModelGetImportError()
Retrieve any error string from the last call to hebiRobotModelImport. This must be called on the same...
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)
static std::unique_ptr< RobotModel > loadHRDF(const std::string &file)
Creates a robot model object with no bodies and an identity base frame.
Eigen::VectorXd _min_positions
size_t getDoFCount() const
Returns the number of settable degrees of freedom in the kinematic tree. (This is equal to the number...
size_t hebiRobotModelGetNumberOfDoFs(HebiRobotModelPtr robot_model)
Returns the number of settable degrees of freedom in the kinematic tree. (This is equal to the number...
struct HebiRobotModel_ * HebiRobotModelPtr
bool addBracket(robot_model::BracketType bracket_type)
Add an element to the robot model with the kinematics/dynamics of a bracket between two actuators...
void getEndEffector(const Eigen::VectorXd &positions, Eigen::Matrix4d &transform) const
Generates the forward kinematics to the end effector (leaf node) frame(s).
void hebiRobotModelElementRelease(HebiRobotModelElementPtr element)
Frees resources created by this element.
void getJEndEffector(const Eigen::VectorXd &positions, Eigen::MatrixXd &jacobian) const
Generates the Jacobian for the end effector (leaf node) frames(s).
HebiStatusCode addObjective(HebiIKPtr ik) const override
void getJ(FrameType, const Eigen::VectorXd &positions, MatrixXdVector &jacobians) const
Generates the Jacobian for each frame in the given kinematic tree.
bool addJoint(JointType joint_type)
Adds a degree of freedom about the specified axis.
void getFK(FrameType, const Eigen::VectorXd &positions, Matrix4dVector &frames) const
Generates the forward kinematics for the given robot model.
HebiRobotModelElementPtr hebiRobotModelElementCreateLink(HebiLinkType link_type, HebiLinkInputType input_type, HebiLinkOutputType output_type, double extension, double twist)
Creates a rigid body, including mass and static transforms, corresponding to a standard HEBI link...
void getJacobians(FrameType, const Eigen::VectorXd &positions, MatrixXdVector &jacobians) const
Generates the Jacobian for each frame in the given kinematic tree.
size_t hebiRobotModelGetImportWarningCount()
Retrieve the number of warnings corresponding to the last call to hebiRobotModelImport. This must be called on the same thread as the call to hebiRobotModelImport.
void getJacobianEndEffector(const Eigen::VectorXd &positions, Eigen::MatrixXd &jacobian) const
Generates the Jacobian for the end effector (leaf node) frames(s).
RobotModel()
Creates a robot model object with no bodies and an identity base frame.
HebiStatusCode hebiRobotModelAdd(HebiRobotModelPtr robot_model, HebiRobotModelElementPtr existing_element, size_t output_index, HebiRobotModelElementPtr new_element)
Add an element to a parent element connected to a robot model object.
bool addActuator(robot_model::ActuatorType actuator_type)
Add an element to the robot model with the kinematics/dynamics of an X5 actuator. ...
bool tryAdd(HebiRobotModelElementPtr element)
Eigen::Matrix4d getBaseFrame() const
Returns the transform from the world coordinate system to the root kinematic body, as set by the setBaseFrame function.
Success; no failures occurred.
size_t hebiRobotModelGetNumberOfElements(HebiRobotModelPtr robot_model)
Returns the number of elements added to the kinematic tree.
HebiRobotModelElementPtr hebiRobotModelElementCreateBracket(HebiBracketType bracket_type)
Creates a rigid body, including mass and static transforms, corresponding to a standard HEBI bracket...
HebiRobotModelElementPtr hebiRobotModelElementCreateRigidBody(const double *com, const double *inertia, double mass, size_t num_outputs, const double *outputs, HebiMatrixOrdering ordering)
Creates a rigid body defining static transforms to the given outputs.
HebiStatusCode addObjective(HebiIKPtr ik) const override
EndEffectorTipAxisObjective(const Eigen::Vector3d &)
HebiStatusCode hebiRobotModelSetBaseFrame(HebiRobotModelPtr robot_model, const double *transform, HebiMatrixOrdering ordering)
Sets the fixed transform from the origin to the input of the first added model element.
HebiStatusCode hebiRobotModelGetBaseFrame(HebiRobotModelPtr robot_model, double *transform, HebiMatrixOrdering ordering)
Retreives the fixed transform from the origin to the input of the first added model element...
bool addEndEffector(EndEffectorType end_effector_type)
Add an end effector element to the robot model.
void hebiRobotModelRelease(HebiRobotModelPtr robot_model)
Frees resources created by this robot model object.
HebiStatusCode hebiIKAddObjectiveEndEffectorPosition(HebiIKPtr ik, double 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...
void getMasses(Eigen::VectorXd &masses) const
Returns the mass of each rigid body (or combination of rigid bodies) in the robot model...
size_t getFrameCount(FrameType frame_type) const
Return the number of frames in the forward kinematics.
HebiRobotModelElementPtr hebiRobotModelElementCreateEndEffector(HebiEndEffectorType end_effector_type, const double *com, const double *inertia, double mass, const double *output_frame, HebiMatrixOrdering ordering)
Creates a robot model element corresponding to a standard HEBI end effector, or a custom end effector...
HebiStatusCode hebiIKAddConstraintJointAngles(HebiIKPtr ik, double weight, size_t num_joints, const double *min_positions, const double *max_positions)
Define joint angle constraints.
bool addRigidBody(const Eigen::Matrix4d &com, const Eigen::VectorXd &inertia, double mass, const Eigen::Matrix4d &output)
Adds a rigid body with the specified properties to the robot model.
struct HebiRobotModelElement_ * HebiRobotModelElementPtr
size_t hebiRobotModelGetNumberOfFrames(HebiRobotModelPtr robot_model, HebiFrameType frame_type)
Return the number of frames in the forward kinematic tree of the robot model.
struct HebiIK_ * HebiIKPtr
EndEffectorSO3Objective(const Eigen::Matrix3d &)
const char * hebiRobotModelGetImportWarning(size_t warning_index)
Retrieve the 'ith' warning string from the last call to hebiRobotModelImport. This must be called on ...
HebiRobotModelPtr hebiRobotModelImport(const char *file)
Import robot model from a file into a RobotModel object.
void getForwardKinematics(FrameType, const Eigen::VectorXd &positions, Matrix4dVector &frames) const
Generates the forward kinematics for the given robot model.
HebiStatusCode
Enum Types.
std::vector< MatrixXd, Eigen::aligned_allocator< Eigen::MatrixXd > > MatrixXdVector
~RobotModel() noexcept
Destructor cleans up robot model object, including all managed elements.