ELASTICPATHING/SOURCECODE/UbiComp2014/Elastic_Pathing_Code/path_decisions.rb
def advanceAError(epath, turn_radius, new_node, logfile)
  #The time_index of the path will move forwards because we will reach this
  #point later. Find the first spot where the turn radius of the turn is
  #achievable with the given speed (less three to allow for measurement error)
  initial_t_index = epath.time_index
  while (epath.time_index < epath.speed_samples.length and
         turn_radius < safeTurnRadius(epath.speed_samples[epath.time_index].speed - 3))
    epath.time_index += 1
  end
  #When this happens the compression factor is undefined so the path is
  #impossible
  if (epath.time_index == epath.speed_samples.length)
    return nil
  end
  #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 compression factor.
  sample_distance = epath.speed_samples[epath.lastLandmarkTime,epath.time_index].inject(0.0){|sum,sample|
    sum += sample.movement
  }
  logfile.puts "advanceAError: advancing from time index #{initial_t_index} to #{epath.time_index} changing initial distance from #{epath.segment_dist} to #{sample_distance}"
  #Set the landmark at the current time given this compression factor
  #This should be less than one since we needed to use more samples in the same time
  epath.setLandmark(epath.segment_dist/sample_distance)
  #Return this new path with a new landmark at this fixed location
  epath.addPoint(new_node)
  return epath
end
#Advance the A error by compressing samples from the last landmark to the
#current point. This assumes that the recorded distance travelled is more than
#the actual distance covered so more samples fit into that space.
#Returns the compression factor and the new sample index when compression works,
#nil otherwise.
Advance the A error by compressing samples from the last landmark to the
current point. This assumes that the recorded distance travelled is more than
the actual distance covered so more samples fit into that space.
Returns the compression factor and the new sample index when compression works,
nil otherwise.
Advance the A error by compressing samples from the last landmark to the current point . This assumes that the recorded distance travelled is more than the actual distance covered so more samples fit into that space . Returns the compression factor and the new sample index when compression works nil otherwise .
def advanceAError(epath, turn_radius, new_node, logfile)
  initial_t_index = epath.time_index
  while (epath.time_index < epath.speed_samples.length and
         turn_radius < safeTurnRadius(epath.speed_samples[epath.time_index].speed - 3))
    epath.time_index += 1
  end
  if (epath.time_index == epath.speed_samples.length)
    return nil
  end
  sample_distance = epath.speed_samples[epath.lastLandmarkTime,epath.time_index].inject(0.0){|sum,sample|
    sum += sample.movement
  }
  logfile.puts "advanceAError: advancing from time index #{initial_t_index} to #{epath.time_index} changing initial distance from #{epath.segment_dist} to #{sample_distance}"
  epath.setLandmark(epath.segment_dist/sample_distance)
  epath.addPoint(new_node)
  return epath
end
def advanceAError ( epath , turn_radius , new_node , logfile ) initial_t_index = epath . time_index while ( epath . time_index < epath . speed_samples . length and turn_radius < safeTurnRadius ( epath . speed_samples [ epath . time_index ] . speed - 3 ) ) epath . time_index += 1 end if ( epath . time_index == epath . speed_samples . length ) return nil end sample_distance = epath . speed_samples [ epath . lastLandmarkTime , epath . time_index ] . inject ( 0.0 ) { | sum , sample | sum += sample . movement } logfile . puts "advanceAError: advancing from time index #{initial_t_index} to #{epath.time_index} changing initial distance from #{epath.segment_dist} to #{sample_distance}" epath . setLandmark ( epath . segment_dist / sample_distance ) epath . addPoint ( new_node ) return epath end
Advance the A error by compressing samples from the last landmark to the
current point.
Advance the A error by compressing samples from the last landmark to the current point .
#The time_index of the path will move forwards because we will reach this #point later. Find the first spot where the turn radius of the turn is #achievable with the given speed (less three to allow for measurement error) #When this happens the compression 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 compression factor. #Set the landmark at the current time given this compression factor #This should be less than one since we needed to use more samples in the same time #Return this new path with a new landmark at this fixed location
epath
turn_radius
new_node
logfile