ELASTICPATHING/SOURCECODE/UbiComp2014/Elastic_Pathing_Code/path_decisions.rb
#Rewind the A error by expanding samples from the last landmark to the current
#point. This assumes that the recorded distance travelled is less than the
#actual distance covered.
#Returns the expansion factor and the new sample index when rewinding works,
#nil otherwise.
Rewind the A error by expanding samples from the last landmark to the current
point. This assumes that the recorded distance travelled is less than the
actual distance covered.
Returns the expansion factor and the new sample index when rewinding works,
nil otherwise.
Rewind the A error by expanding samples from the last landmark to the current point . This assumes that the recorded distance travelled is less than the actual distance covered . Returns the expansion factor and the new sample index when rewinding works nil otherwise .
def rewindAError(epath, turn_radius, new_node)
  if (epath.time_index>=epath.speed_samples.length)
    return nil
  end
  while (epath.time_index > epath.lastLandmarkTime and
         turn_radius < safeTurnRadius(epath.speed_samples[epath.time_index].speed - 3))
    epath.time_index -= 1
  end
  if (epath.time_index == epath.lastLandmarkTime)
    return nil
  end
  sample_distance = epath.speed_samples[epath.lastLandmarkTime,epath.time_index].inject(0.0){|sum,sample|
    sum += sample.movement
  }
  epath.setLandmark(epath.segment_dist/sample_distance)
  epath.addPoint(new_node)
  return epath
end
def rewindAError ( epath , turn_radius , new_node ) if ( epath . time_index >= epath . speed_samples . length ) return nil end while ( epath . time_index > epath . lastLandmarkTime and turn_radius < safeTurnRadius ( epath . speed_samples [ epath . time_index ] . speed - 3 ) ) epath . time_index -= 1 end if ( epath . time_index == epath . lastLandmarkTime ) return nil end sample_distance = epath . speed_samples [ epath . lastLandmarkTime , epath . time_index ] . inject ( 0.0 ) { | sum , sample | sum += sample . movement } epath . setLandmark ( epath . segment_dist / sample_distance ) epath . addPoint ( new_node ) return epath end
Rewind the A error by expanding samples from the last landmark to the current
point.
Rewind the A error by expanding samples from the last landmark to the current point .
#The time_index of the path will move backwards because we will reach this #point sooner. Find the first spot where the turn radius of the turn is #achievable with the given speed (less three to allow for measurement error) #puts "new #{epath.time_index}+#{epath.speed_samples.length}" #When this happens the expansion factor is undefined so the path is #impossible #Otherwise we can just count the ratio of the distance we would need to reach #this sample at this location to the distance that the path thinks it has #travelled to find the expansion factor. #Set the landmark at the current time given this compression factor #This should be greater than one since we expanded the path #Return this new path with a new landmark at this fixed location
epath
turn_radius
new_node