1414#include " pose.h"
1515#include " syropod_highlevel_controller/LegState.h"
1616
17- #define IK_TOLERANCE 0.005 // /< Tolerance between desired and resultant tip position from inverse/forward kinematics (m)
18- #define HALF_BODY_DEPTH 0.05 // /< Threshold used to estimate if leg tip has broken the plane of the robot body (m)
19- #define DLS_COEFFICIENT 0.02 // /< Coefficient used in Damped Least Squares method for inverse kinematics
20- #define JOINT_LIMIT_COST_WEIGHT 0.1 // /< Gain used in determining cost weight for joints approaching limits
17+ #define IK_TOLERANCE 0.005 // /< Tolerance between desired & resultant tip position from IK/FK (m)
18+ #define HALF_BODY_DEPTH 0.05 // /< Threshold used to estimate if leg tip has broken the plane of the robot body(m)
19+ #define DLS_COEFFICIENT 0.02 // /< Coefficient used in Damped Least Squares method for inverse kinematics
20+ #define JOINT_LIMIT_COST_WEIGHT 0.1 // /< Gain used in determining cost weight for joints approaching limits
2121
2222#define BEARING_STEP 45 // /< Step to increment bearing in workspace generation algorithm (deg)
2323#define MAX_POSITION_DELTA 0.002 // /< Position delta to increment search position in workspace generation algorithm (m)
@@ -53,7 +53,8 @@ struct ImuData
5353// / This class serves as the top-level parent of each leg object and associated tip/joint/link objects. It contains data
5454// / which is relevant to the robot body or the robot as a whole rather than leg dependent data.
5555// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56- typedef std::map<int , std::shared_ptr<Leg>, std::less<int >, Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Leg>>>> LegContainer;
56+ typedef Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Leg>>> LegAlignedAllocator;
57+ typedef std::map<int , std::shared_ptr<Leg>, std::less<int >, LegAlignedAllocator> LegContainer;
5758class Model : public std ::enable_shared_from_this<Model>
5859{
5960public:
@@ -188,8 +189,10 @@ class Model : public std::enable_shared_from_this<Model>
188189typedef std::vector<double > state_type; // Impedance state used in admittance controller
189190typedef std::map<int , double > Workplane;
190191typedef std::map<double , Workplane> Workspace;
191- typedef std::map<int , std::shared_ptr<Joint>, std::less<int >, Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Joint>>>> JointContainer;
192- typedef std::map<int , std::shared_ptr<Link>, std::less<int >, Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Link>>>> LinkContainer;
192+ typedef Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Joint>>> JointAlignedAllocator;
193+ typedef std::map<int , std::shared_ptr<Joint>, std::less<int >, JointAlignedAllocator> JointContainer;
194+ typedef Eigen::aligned_allocator<std::pair<const int , std::shared_ptr<Link>>> LinkAlignedAllocator;
195+ typedef std::map<int , std::shared_ptr<Link>, std::less<int >, LinkAlignedAllocator> LinkContainer;
193196class Leg : public std ::enable_shared_from_this<Leg>
194197{
195198public:
@@ -419,7 +422,10 @@ class Leg : public std::enable_shared_from_this<Leg>
419422 // / Returns pointer to joint requested via identification number input.
420423 // / @param[in] joint_id_number The identification name of the requested joint object pointer
421424 // / @return Pointer to joint requested via identification number input
422- inline std::shared_ptr<Joint> getJointByIDNumber (const int & joint_id_number) { return joint_container_[joint_id_number]; };
425+ inline std::shared_ptr<Joint> getJointByIDNumber (const int & joint_id_number)
426+ {
427+ return joint_container_[joint_id_number];
428+ };
423429
424430 // / Returns pointer to joint requested via identification name string input.
425431 // / @param[in] joint_id_name The identification name of the requested joint object pointer
@@ -486,11 +492,11 @@ class Leg : public std::enable_shared_from_this<Leg>
486492 Pose applyFK (const bool & set_current = true , const bool & use_actual = false );
487493
488494private:
489- std::shared_ptr<Model> model_; // /< A pointer to the parent robot model object
490- const Parameters& params_; // /< Pointer to parameter data structure for storing parameter variables
491- JointContainer joint_container_; // /< The container object for all child Joint objects
492- LinkContainer link_container_; // /< The container object for all child Link objects
493- std::shared_ptr<Tip> tip_; // /< A pointer to the child Tip object
495+ std::shared_ptr<Model> model_; // /< A pointer to the parent robot model object
496+ const Parameters& params_; // /< Pointer to parameter data structure for storing parameter variables
497+ JointContainer joint_container_; // /< The container object for all child Joint objects
498+ LinkContainer link_container_; // /< The container object for all child Link objects
499+ std::shared_ptr<Tip> tip_; // /< A pointer to the child Tip object
494500
495501 std::shared_ptr<LegStepper> leg_stepper_; // /< A pointer to the LegStepper object associated with this leg
496502 std::shared_ptr<LegPoser> leg_poser_; // /< A pointer to the LegPoser object associated with this leg
@@ -505,25 +511,25 @@ class Leg : public std::enable_shared_from_this<Leg>
505511 ros::Publisher leg_state_publisher_; // /< The ros publisher object that publishes state messages for this leg
506512 ros::Publisher asc_leg_state_publisher_; // /< The ros publisher object that publishes ASC state messages for this leg
507513
508- Eigen::Vector3d admittance_delta_; // /< The admittance controller tip position offset vector
509- double virtual_mass_; // /< The virtual mass of the admittance controller virtual model of this leg
510- double virtual_stiffness_; // /< The virtual stiffness of the admittance controller virtual model of this leg
511- double virtual_damping_ratio_; // /< The virtual damping ratio of the admittance controller virtual model of this leg
512- state_type admittance_state_; // /< The admittance state of the admittance controller virtual model of this leg
514+ Eigen::Vector3d admittance_delta_; // /< The admittance controller tip position offset vector
515+ double virtual_mass_; // /< The virtual mass of the admittance controller virtual model of this leg
516+ double virtual_stiffness_; // /< The virtual stiffness of the admittance controller virtual model of this leg
517+ double virtual_damping_ratio_; // /< The virtual damping ratio of the admittance controller virtual model of leg
518+ state_type admittance_state_; // /< The admittance state of the admittance controller virtual model of this leg
513519
514520 Pose desired_tip_pose_; // /< Desired tip pose before applying Inverse/Forward kinematics
515521 Pose current_tip_pose_; // /< Current tip pose according to the model
516522
517523 Eigen::Vector3d desired_tip_velocity_; // /< Desired linear tip velocity before applying Inverse/Forward kinematics
518524 Eigen::Vector3d current_tip_velocity_; // /< Current linear tip velocity according to the model
519525
520- int group_; // /< Leg stepping coordination group (Either 0 or 1)
526+ int group_; // /< Leg stepping coordination group (Either 0 or 1)
521527
522528 Eigen::Vector3d tip_force_calculated_; // /< Calculated force estimation on the tip
523529 Eigen::Vector3d tip_torque_calculated_; // /< Calculated torque estimation on the tip
524530 Eigen::Vector3d tip_force_measured_; // /< Measured force estimation on the tip
525531 Eigen::Vector3d tip_torque_measured_; // /< Measured torque estimation on the tip
526- Pose step_plane_pose_; // /< Estimation of the pose of the stepping surface plane
532+ Pose step_plane_pose_; // /< Estimation of the pose of the stepping surface plane
527533public:
528534 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
529535};
@@ -541,20 +547,20 @@ class Link
541547 // / @param[in] actuating_joint A pointer to the actuating joint object, from which this link is moved
542548 // / @param[in] id_number The identification number for this link
543549 // / @param[in] params A pointer to the parameter data structure
544- Link (std::shared_ptr<Leg> leg, std::shared_ptr<Joint> actuating_joint, const int & id_number, const Parameters& params);
550+ Link (std::shared_ptr<Leg> leg,std::shared_ptr<Joint> actuating_joint, const int & id_number, const Parameters& params);
545551
546552 // / Copy Constructor for Link object. Initialises member variables from existing Link object.
547553 // / @param[in] link A pointer to an existing link object
548554 Link (std::shared_ptr<Link> link);
549555
550556 const std::shared_ptr<Leg> parent_leg_; // /< A pointer to the parent leg object associated with this link
551557 const std::shared_ptr<Joint> actuating_joint_; // /< A pointer to the actuating Joint object associated with this link
552- const int id_number_; // /< The identification number for this link
558+ const int id_number_; // /< The identification number for this link
553559 const std::string id_name_; // /< The identification name for this link
554- const double dh_parameter_r_; // /< The DH parameter 'r' associated with this link
555- const double dh_parameter_theta_; // /< The DH parameter 'theta' associated with this link
556- const double dh_parameter_d_; // /< The DH parameter 'd' associated with this link
557- const double dh_parameter_alpha_; // /< The DH parameter 'alpha' associated with this link
560+ const double dh_parameter_r_; // /< The DH parameter 'r' associated with this link
561+ const double dh_parameter_theta_; // /< The DH parameter 'theta' associated with this link
562+ const double dh_parameter_d_; // /< The DH parameter 'd' associated with this link
563+ const double dh_parameter_alpha_; // /< The DH parameter 'alpha' associated with this link
558564
559565public:
560566 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
@@ -612,18 +618,18 @@ class Joint
612618
613619 const std::shared_ptr<Leg> parent_leg_; // /< A pointer to the parent leg object associated with this joint
614620 const std::shared_ptr<Link> reference_link_; // /< A pointer to the reference Link object associated with this joint
615- const int id_number_; // /< The identification number for this joint
621+ const int id_number_; // /< The identification number for this joint
616622 const std::string id_name_; // /< The identification name for this joint
617- Eigen::Matrix4d current_transform_; // /< The current transformation matrix between previous joint and this joint
618- Eigen::Matrix4d identity_transform_; // /< The identity transformation matrix between previous joint and this joint
623+ Eigen::Matrix4d current_transform_; // /< The current transformation matrix between previous joint and joint
624+ Eigen::Matrix4d identity_transform_; // /< The identity transformation matrix between previous joint and joint
619625
620- ros::Publisher desired_position_publisher_; // /< The ros publisher for publishing desired position values
626+ ros::Publisher desired_position_publisher_; // /< The ros publisher for publishing desired position values
621627
622- const double min_position_ = 0.0 ; // /< The minimum position allowed for this joint
623- const double max_position_ = 0.0 ; // /< The maximum position allowed for this joint
628+ const double min_position_ = 0.0 ; // /< The minimum position allowed for this joint
629+ const double max_position_ = 0.0 ; // /< The maximum position allowed for this joint
624630 std::vector<double > packed_positions_ ; // /< The defined position of this joint in a 'packed' state
625- const double unpacked_position_ = 0.0 ; // /< The defined position of this joint in an 'unpacked' state
626- const double max_angular_speed_ = 0.0 ; // /< The maximum angular speed of this joint
631+ const double unpacked_position_ = 0.0 ; // /< The defined position of this joint in an 'unpacked' state
632+ const double max_angular_speed_ = 0.0 ; // /< The maximum angular speed of this joint
627633
628634 double desired_position_ = 0.0 ; // /< The desired angular position of this joint
629635 double desired_velocity_ = 0.0 ; // /< The desired angular velocity of this joint
@@ -689,11 +695,11 @@ class Tip
689695 return robot_frame_pose.transform (transform.inverse ());
690696 };
691697
692- const std::shared_ptr<Leg> parent_leg_; // /< A pointer to the parent leg object associated with the tip
693- const std::shared_ptr<Link> reference_link_; // /< A pointer to the reference Link object associated with the tip
694- const std::string id_name_; // /< The identification name for the tip
695- Eigen::Matrix4d current_transform_; // /< The current transformation matrix between previous joint and the tip
696- Eigen::Matrix4d identity_transform_; // /< The identity transformation matrix between previous joint and the tip
698+ const std::shared_ptr<Leg> parent_leg_; // /< A pointer to the parent leg object associated with the tip
699+ const std::shared_ptr<Link> reference_link_; // /< A pointer to the reference Link object associated with the tip
700+ const std::string id_name_; // /< The identification name for the tip
701+ Eigen::Matrix4d current_transform_; // /< The current transformation matrix between previous joint and tip
702+ Eigen::Matrix4d identity_transform_; // /< The identity transformation matrix between previous joint and tip
697703
698704public:
699705 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
0 commit comments