@@ -122,7 +122,7 @@ void Model::generateWorkspaces(void)
122122{
123123 // Create copy of model for searching for kinematic limitations
124124 std::shared_ptr<Model> search_model = std::allocate_shared<Model>(Eigen::aligned_allocator<Model>(),
125- shared_from_this ());
125+ shared_from_this ());
126126 search_model->generate (shared_from_this ());
127127 search_model->initLegs (true );
128128
@@ -222,8 +222,8 @@ Leg::Leg(std::shared_ptr<Leg> leg, std::shared_ptr<Model> model)
222222
223223void Leg::generate (std::shared_ptr<Leg> leg)
224224{
225- std::shared_ptr<Joint> null_joint = std::allocate_shared<Joint>(Eigen::aligned_allocator<Joint>()); // Null joint
226- // acts as origin
225+ // Null joint acts as origin
226+ std::shared_ptr<Joint> null_joint = std::allocate_shared<Joint>(Eigen::aligned_allocator<Joint>());
227227 std::shared_ptr<Link> base_link =
228228 std::allocate_shared<Link>(Eigen::aligned_allocator<Link>(), shared_from_this (), null_joint, 0 , params_);
229229 link_container_.insert (LinkContainer::value_type (0 , base_link));
@@ -344,8 +344,8 @@ Workspace Leg::generateWorkspace(void)
344344
345345 // Calculate Identity tip pose
346346 Pose current_pose = model_->getCurrentPose ();
347- Eigen::Vector3d identity_tip_position = current_pose. inverseTransformVector (leg_stepper_->
348- getIdentityTipPose ().position_ );
347+ Eigen::Vector3d identity_tip_position =
348+ current_pose. inverseTransformVector (leg_stepper_-> getIdentityTipPose ().position_ );
349349
350350 // Set zero workspace if unable to reach idenity_tip_pose
351351 if ((identity_tip_position - current_tip_pose_.position_ ).norm () > IK_TOLERANCE)
@@ -376,8 +376,8 @@ Workspace Leg::generateWorkspace(void)
376376 while (true )
377377 {
378378 Pose current_pose = model_->getCurrentPose ();
379- Eigen::Vector3d identity_tip_position = current_pose. inverseTransformVector (leg_stepper_->
380- getIdentityTipPose ().position_ );
379+ Eigen::Vector3d identity_tip_position =
380+ current_pose. inverseTransformVector (leg_stepper_-> getIdentityTipPose ().position_ );
381381 identity_tip_position[2 ] += search_height;
382382
383383 // Set origin and target for linear interpolation
@@ -390,8 +390,8 @@ Workspace Leg::generateWorkspace(void)
390390 {
391391 number_iterations = roundToInt (MAX_WORKSPACE_RADIUS / MAX_POSITION_DELTA);
392392 origin_tip_position = identity_tip_position;
393- Eigen::Vector3d search_limit = (found_lower_limit ? MAX_WORKSPACE_RADIUS : -MAX_WORKSPACE_RADIUS) *
394- Eigen::Vector3d::UnitZ ();
393+ Eigen::Vector3d search_limit =
394+ (found_lower_limit ? MAX_WORKSPACE_RADIUS : -MAX_WORKSPACE_RADIUS) * Eigen::Vector3d::UnitZ ();
395395 target_tip_position = identity_tip_position + search_limit;
396396 }
397397 // Track to new workplane origin at search height
@@ -575,8 +575,8 @@ Eigen::Vector3d Leg::makeReachable(const Eigen::Vector3d& reference_tip_position
575575 // If test tip position is beyond limit, calculate new position along same workplane bearing within limits
576576 if (distance_to_test > distance_to_limit)
577577 {
578- Eigen::Vector3d new_tip_position = Eigen::AngleAxisd (raw_bearing, Eigen::Vector3d::UnitZ ()) *
579- (Eigen::Vector3d::UnitX () * distance_to_limit);
578+ Eigen::Vector3d new_tip_position =
579+ Eigen::AngleAxisd (raw_bearing, Eigen::Vector3d::UnitZ ()) * (Eigen::Vector3d::UnitX () * distance_to_limit);
580580 new_tip_position[2 ] = test_tip_position[2 ];
581581 new_tip_position = pose.transformVector (new_tip_position);
582582 return new_tip_position;
@@ -692,21 +692,18 @@ void Leg::calculateTipForce(void)
692692
693693 // Transpose and invert jacobian
694694 Eigen::MatrixXd identity = Eigen::MatrixXd::Identity (joint_count_, joint_count_);
695- Eigen::MatrixXd transformation = jacobian * ((jacobian. transpose ()*jacobian + sqr (DLS_COEFFICIENT) *
696- identity).inverse ());
695+ Eigen::MatrixXd transformation =
696+ jacobian * ((jacobian. transpose ()*jacobian + sqr (DLS_COEFFICIENT) * identity).inverse ());
697697
698698 Eigen::VectorXd raw_tip_force_leg_frame = transformation * joint_torques;
699699 Eigen::Quaterniond rotation = (first_joint->getPoseJointFrame ()).rotation_ ;
700700 Eigen::VectorXd raw_tip_force = rotation._transformVector (raw_tip_force_leg_frame.block <3 , 1 >(0 , 0 ));
701701
702702 // Low pass filter and force gain applied to calculated raw tip force
703703 double s = 0.15 ; // Smoothing Factor
704- tip_force_calculated_[0 ] = s * raw_tip_force[0 ] * params_.force_gain .current_value + (1 - s) *
705- tip_force_calculated_[0 ];
706- tip_force_calculated_[1 ] = s * raw_tip_force[1 ] * params_.force_gain .current_value + (1 - s) *
707- tip_force_calculated_[1 ];
708- tip_force_calculated_[2 ] = s * raw_tip_force[2 ] * params_.force_gain .current_value + (1 - s) *
709- tip_force_calculated_[2 ];
704+ tip_force_calculated_[0 ] = s*raw_tip_force[0 ]*params_.force_gain .current_value + (1 - s)*tip_force_calculated_[0 ];
705+ tip_force_calculated_[1 ] = s*raw_tip_force[1 ]*params_.force_gain .current_value + (1 - s)*tip_force_calculated_[1 ];
706+ tip_force_calculated_[2 ] = s*raw_tip_force[2 ]*params_.force_gain .current_value + (1 - s)*tip_force_calculated_[2 ];
710707}
711708
712709// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -727,9 +724,8 @@ void Leg::touchdownDetection(void)
727724
728725Eigen::VectorXd Leg::solveIK (const Eigen::MatrixXd& delta, const bool & solve_rotation)
729726{
730- // Calculate Jacobian from DH matrices along kinematic chain
731- // ref: robotics.stackexchange.com/questions/2760/computing-inverse-kinematic-with-jacobian-matrices-
732- // for-6-dof-manipulator
727+ // Calculate Jacobian from DH matrices along kinematic chain. Ref:
728+ // robotics.stackexchange.com/questions/2760/computing-inverse-kinematic-with-jacobian-matrices-for-6-dof-manipulator
733729 std::shared_ptr<Joint> first_joint = joint_container_.begin ()->second ;
734730 Eigen::Vector3d pe = tip_->getTransformFromJoint (first_joint->id_number_ ).block <3 , 1 >(0 , 3 );
735731 Eigen::Vector3d z0 (0 , 0 , 1 );
@@ -774,19 +770,19 @@ Eigen::VectorXd Leg::solveIK(const Eigen::MatrixXd& delta, const bool& solve_rot
774770 double position_range_centre = joint->min_position_ + joint_position_range/2.0 ;
775771 if (joint_position_range != 0.0 )
776772 {
777- position_limit_cost += sqr ( abs (JOINT_LIMIT_COST_WEIGHT * (joint-> desired_position_ - position_range_centre) /
778- joint_position_range));
779- position_cost_gradient[i] = - sqr (JOINT_LIMIT_COST_WEIGHT) * (joint-> desired_position_ - position_range_centre) /
780- sqr (joint_position_range);
773+ position_limit_cost +=
774+ sqr ( abs (JOINT_LIMIT_COST_WEIGHT * (joint-> desired_position_ - position_range_centre) / joint_position_range));
775+ position_cost_gradient[i] =
776+ - sqr (JOINT_LIMIT_COST_WEIGHT) * (joint-> desired_position_ - position_range_centre) / sqr (joint_position_range);
781777 }
782778
783779 // VELOCITY LIMITS
784780 double joint_velocity_range = 2 * joint->max_angular_speed_ ;
785781 double velocity_range_centre = 0.0 ;
786- velocity_limit_cost += sqr ( abs (JOINT_LIMIT_COST_WEIGHT * (joint-> desired_velocity_ - velocity_range_centre) /
787- joint_velocity_range));
788- velocity_cost_gradient[i] = - sqr (JOINT_LIMIT_COST_WEIGHT) * (joint-> desired_velocity_ - velocity_range_centre) /
789- sqr (joint_velocity_range);
782+ velocity_limit_cost +=
783+ sqr ( abs (JOINT_LIMIT_COST_WEIGHT * (joint-> desired_velocity_ - velocity_range_centre) / joint_velocity_range));
784+ velocity_cost_gradient[i] =
785+ - sqr (JOINT_LIMIT_COST_WEIGHT) * (joint-> desired_velocity_ - velocity_range_centre) / sqr (joint_velocity_range);
790786 }
791787 position_cost_gradient *= (position_limit_cost == 0.0 ? 0.0 : 1.0 / sqrt (position_limit_cost));
792788 velocity_cost_gradient *= (velocity_limit_cost == 0.0 ? 0.0 : 1.0 / sqrt (velocity_limit_cost));
@@ -888,10 +884,10 @@ double Leg::applyIK(const bool& simulation)
888884 applyFK ();
889885
890886 // Generate rotation delta vector in reference to the base of the leg
891- Eigen::Vector3d desired_tip_direction = leg_frame_desired_tip_pose. rotation_ .
892- _transformVector (Eigen::Vector3d::UnitX ());
893- Eigen::Vector3d current_tip_direction = leg_frame_current_tip_pose. rotation_ .
894- _transformVector (Eigen::Vector3d::UnitX ());
887+ Eigen::Vector3d desired_tip_direction =
888+ leg_frame_desired_tip_pose. rotation_ . _transformVector (Eigen::Vector3d::UnitX ());
889+ Eigen::Vector3d current_tip_direction =
890+ leg_frame_current_tip_pose. rotation_ . _transformVector (Eigen::Vector3d::UnitX ());
895891 Eigen::Quaterniond difference = Eigen::Quaterniond::FromTwoVectors (current_tip_direction, desired_tip_direction);
896892 Eigen::AngleAxisd axis_rotation (difference.normalized ());
897893 Eigen::Vector3d rotation_delta = axis_rotation.axis () * axis_rotation.angle ();
@@ -991,8 +987,8 @@ Pose Leg::applyFK(const bool& set_current, const bool& use_actual)
991987
992988// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
993989
994- Link::Link (std::shared_ptr<Leg> leg, std::shared_ptr<Joint> actuating_joint, const int & id_number,
995- const Parameters& params)
990+ Link::Link (std::shared_ptr<Leg> leg, std::shared_ptr<Joint> actuating_joint,
991+ const int & id_number, const Parameters& params)
996992 : parent_leg_(leg)
997993 , actuating_joint_(actuating_joint)
998994 , id_number_(id_number)
@@ -1025,8 +1021,8 @@ Link::Link(std::shared_ptr<Link> link)
10251021
10261022// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10271023
1028- Joint::Joint (std::shared_ptr<Leg> leg, std::shared_ptr<Link> reference_link, const int & id_number,
1029- const Parameters& params)
1024+ Joint::Joint (std::shared_ptr<Leg> leg, std::shared_ptr<Link> reference_link,
1025+ const int & id_number, const Parameters& params)
10301026 : parent_leg_(leg)
10311027 , reference_link_(reference_link)
10321028 , id_number_(id_number)
0 commit comments