/** * homing() * * set trajectory behavior for each joint during the homing process. */ void homing(struct DOF* _joint) { const float f_period[MAX_MECH*MAX_DOF_PER_MECH] = {1, 1, 1, 9999999, 1, 1, 1, 1, 1, 1, 1, 9999999, 1, 1, 1, 1}; const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, -40 DEG2RAD, -40 DEG2RAD}; switch (_joint->state) { case jstate_wait: break; case jstate_not_ready: // Initialize velocity trajectory //log_msg("Starting homing on joint %d", _joint->type); _joint->state = jstate_pos_unknown; start_trajectory_mag(_joint, f_magnitude[_joint->type], f_period[_joint->type]); break; case jstate_pos_unknown: // Set desired joint trajectory update_linear_sinusoid_position_trajectory(_joint); break; case jstate_hard_stop: // Wait for all joints. No trajectory here. break; case jstate_homing1: start_trajectory( _joint , DOF_types[_joint->type].home_position, 2.5 ); _joint->state = jstate_homing2; case jstate_homing2: // Move to start position // Update position trajectory if ( !update_position_trajectory(_joint) ) { _joint->state = jstate_ready; log_msg("Joint %s ready", jointIndexAndArmName(_joint->type).c_str()); } break; default: // not doing joint homing. break; } // switch return; }
/** * homing() * * \param _joint The joint being controlled. * * \brief Set trajectory behavior for each joint during the homing process. * * \todo Explain why sinusoid is used for homing??? * * \todo Homing limits should be Amps not DAC units * * \todo Change square vs. diamond to a config-file based runtime system instead of #ifdef * * \ingroup Control */ void homing(struct DOF* _joint) { // duration for homing of each joint const float f_period[MAX_MECH*MAX_DOF_PER_MECH] = {1, 1, 1, 9999999, 1, 1, 1, 1, 1, 1, 1, 9999999, 1, 1, 1, 1}; // degrees for homing of each joint #ifdef RAVEN_II_SQUARE //roll is backwards because of the 'click' in the mechanism const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, -80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, -80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; #else #ifdef DV_ADAPTER const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; #else //default const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; #endif #endif switch (_joint->state) { case jstate_wait: break; case jstate_not_ready: // Initialize velocity trajectory //log_msg("Starting homing on joint %d", _joint->type); _joint->state = jstate_pos_unknown; start_trajectory_mag(_joint, f_magnitude[_joint->type], f_period[_joint->type]); break; case jstate_pos_unknown: // Set desired joint trajectory update_linear_sinusoid_position_trajectory(_joint); break; case jstate_hard_stop: // Wait for all joints. No trajectory here. break; case jstate_homing1: start_trajectory( _joint , DOF_types[_joint->type].home_position, 2.5 ); _joint->state = jstate_homing2; case jstate_homing2: // Move to start position // Update position trajectory if ( !update_position_trajectory(_joint) ) { _joint->state = jstate_ready; log_msg("Joint %d ready", _joint->type); } break; default: // not doing joint homing. break; } // switch return; }
/** * \fn void homing(struct DOF* _joint, tool a_tool) * * \brief Set trajectory behavior for each tool joint during the homing process. * * \param _joint The joint being controlled. * \param a_tool The tool being controlled. * * \ingroup Control * * \return void */ void homing(struct DOF* _joint, tool a_tool) { // duration for homing of each joint const float f_period[MAX_MECH*MAX_DOF_PER_MECH] = {1, 1, 1, 9999999, 1, 1, 1, 1, 1, 1, 1, 9999999, 1, 1, 1, 1}; // // degrees for homing of each joint //#ifdef RAVEN_II_SQUARE // //roll is backwards because of the 'click' in the mechanism // const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, -80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, // -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, -80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; //#else //#ifdef DV_ADAPTER // const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, // -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; //#else //default // const float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, // -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; //#endif //#endif //check if scissors int scissor = ((a_tool.t_end == mopocu_scissor) || (a_tool.t_end == potts_scissor))? 1 : 0; float f_magnitude[MAX_MECH*MAX_DOF_PER_MECH] = {-10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, -10 DEG2RAD, 10 DEG2RAD, 0.02, 9999999, 80 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD, 40 DEG2RAD}; if(a_tool.t_style == square_raven){ if(a_tool.mech_type == GOLD_ARM) f_magnitude[TOOL_ROT_GOLD] = -80 DEG2RAD; else if(a_tool.mech_type == GREEN_ARM) f_magnitude[TOOL_ROT_GREEN] = -80 DEG2RAD; } if (scissor){ if(a_tool.mech_type == GOLD_ARM) f_magnitude[GRASP2_GOLD] = -40 DEG2RAD; else if(a_tool.mech_type == GREEN_ARM) f_magnitude[GRASP2_GREEN] = -40 DEG2RAD; } switch (_joint->state) { case jstate_wait: break; case jstate_not_ready: // Initialize velocity trajectory //log_msg("Starting homing on joint %d", _joint->type); _joint->state = jstate_pos_unknown; start_trajectory_mag(_joint, f_magnitude[_joint->type], f_period[_joint->type]); break; case jstate_pos_unknown: // Set desired joint trajectory update_linear_sinusoid_position_trajectory(_joint); break; case jstate_hard_stop: // Wait for all joints. No trajectory here. break; case jstate_homing1: start_trajectory( _joint , DOF_types[_joint->type].home_position, 2.5 ); _joint->state = jstate_homing2; break; case jstate_homing2: // Move to start position // Update position trajectory if ( !update_position_trajectory(_joint) ) { _joint->state = jstate_ready; log_msg("Joint %d ready", _joint->type); } break; default: // not doing joint homing. break; } // switch return; }