Dependencies: ros_lib_kinetic
Diff: main.cpp
- Revision:
- 20:b2139294c547
- Parent:
- 19:e5acb2183d4e
- Child:
- 21:0b10d8e615d1
--- a/main.cpp Tue Nov 27 16:52:06 2018 +0000 +++ b/main.cpp Tue Nov 27 16:53:06 2018 +0000 @@ -157,87 +157,6 @@ // Unlock mutex, allowing CalculateSmoothPath to run again mutPathIn.unlock(); -/* - //bool isTimeChanged = 0; - double dblMaxRecalculatedTime = input.duration; - // Convert from requested chamber to actuator space and limit actuator positions - for (ii = 0; ii< N_CHANNELS; ii++) { - // If sent a negative requested position, do NOT replan that actuator - if( dblTargetChambLen_mm[ii] < 0.0 ) continue; - //check to see if positions are achievable - dblTargetActPos_mm[ii] = dblTargetChambLen_mm[ii]*FLT_ACTUATOR_CONVERSION[ii]; - dblTargetActPos_mm[ii] = min( max( 0.0 , dblTargetActPos_mm[ii] ) , 40.0 ); - //!! LIMIT CHAMBER LENGTHS TOO - } - // Calculate achievable velocities, and hence time, for the requested move to complete within tolerance - double dblActPosChange; - short sgn; - for (ii = 0; ii< N_CHANNELS; ii++) { // Work out new velocities - // If sent a negative requested position, do NOT replan that actuator - if( dblTargetChambLen_mm[ii] < 0.0 ) continue; - - //dblActPosChange = 1.0; // or = 0.0; - //_dblVelocity_mmps[ii] = 0.0; // DOESN'T CRASH - - //dblActPosChange = dblTargetActPos_mm[ii]; - //_dblVelocity_mmps[ii] = 0.0; // DOESN'T CRASH - - //dblActPosChange = _dblLinearPathCurrentPos_mm[ii]; // DOESN'T CRASH - - //_dblVelocity_mmps[ii] = _dblLinearPathCurrentPos_mm[ii]; // DOESN'T CRASH - - //dblActPosChange = 0.0; - //_dblVelocity_mmps[ii] = _dblLinearPathCurrentPos_mm[ii]; // DOESN'T CRASH - - // DOES CRASH but not with a return at the end of while OR if _ variables are declared globally - //dblActPosChange = _dblLinearPathCurrentPos_mm[ii]; - //_dblVelocity_mmps[ii] = 0.0; - - dblActPosChange = dblTargetActPos_mm[ii] - dblADCCurrentPosition[ii]; - if( fabs(dblActPosChange) < FLT_PATH_TOLERANCE ) { // If actuator ii is already within tolerance - dblActPosChange = 0.0; - //isTimeChanged = 1; - } - //IS BELOW - if( input.duration < 0.000000001 ) { // If max (safe) velocity was requested - sgn = (dblActPosChange > 0) ? 1 : ((dblActPosChange < 0) ? -1 : 0); - _dblVelocity_mmps[ii] = sgn * MAX_SPEED_MMPS; - //isTimeChanged = 1; - } else { - _dblVelocity_mmps[ii] = dblActPosChange / input.duration; - } - //IS ABOVE - // Check to see if velocities are achievable -- this can move into the else section of the above if statement - if(abs(_dblVelocity_mmps[ii]) > MAX_SPEED_MMPS) { - if(_dblVelocity_mmps[ii]>0) { - _dblVelocity_mmps[ii] = MAX_SPEED_MMPS; - } else { - _dblVelocity_mmps[ii] = -1*MAX_SPEED_MMPS; - } - //isTimeChanged = 1; - } - // Recalculate the move's time after altering the position and/or velocity - double dblRecalculatedTime; - if( fabs(_dblVelocity_mmps[ii]) < 0.000000001 ) { - dblRecalculatedTime = 0; - } else { - dblRecalculatedTime = dblActPosChange / _dblVelocity_mmps[ii]; - } - // Find the maximum time for any actuator's move for synchronization - if( dblRecalculatedTime > dblMaxRecalculatedTime ) { - dblMaxRecalculatedTime = dblRecalculatedTime; - } - } - // Finally recalculate all of the velocities based upon this maximum time for synchronization - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!MUTEX FOR dblVelocity_mmps and dblTargetActPos_mm?? - for (ii = 0; ii< N_CHANNELS; ii++) { // Work out new velocities - // If sent a negative requested position, do NOT replan that actuator - if( dblTargetChambLen_mm[ii] < 0.0 ) continue; - - _dblVelocity_mmps[ii] = (dblTargetActPos_mm[ii] - dblADCCurrentPosition[ii]) / dblMaxRecalculatedTime; - dblVelocity_mmps[ii] = _dblVelocity_mmps[ii]; - } -*/ // SEND MESSAGE error_code = hlcomms.send_duration_message(&maxTimeToTarget_s); if( error_code < 0 ) {