ELASTICPATHING/SOURCECODE/UbiComp2014/Elastic_Pathing_Code/path_decisions.rb
#Rewind the B error by compressing 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 compression factor and the new sample index when rewinding works,
#nil otherwise.
Rewind the B error by compressing 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 compression factor and the new sample index when rewinding works,
nil otherwise.
Rewind the B error by compressing 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 compression factor and the new sample index when rewinding works nil otherwise .
def rewindBError(epath, navigator)
  distance_reduction = 0.0
  path_idx = -1
  while (0 < path_idx and
         1 >= navigator.nextPoints(epath.path[path_idx-1], epath.path[path_idx]).length)
    path_idx -= 1
    distance_reduction += epath.path[path_idx].distance(epath.path[path_idx+1])
    if (distance_reduction >= epath.curSegmentDistance)
      return nil
    end
  end
  if (0 == path_idx)
    return nil
  end
  distance_reduction += LANE_WIDTH/5280.0
  if (distance_reduction >= epath.curSegmentDistance)
    return nil
  end
  epath.path = epath.path[0..path_idx]
  epath.setLandmark(epath.segment_dist/(epath.segment_dist - distance_reduction))
  return epath
end
def rewindBError ( epath , navigator ) distance_reduction = 0.0 path_idx = - 1 while ( 0 < path_idx and 1 >= navigator . nextPoints ( epath . path [ path_idx - 1 ] , epath . path [ path_idx ] ) . length ) path_idx -= 1 distance_reduction += epath . path [ path_idx ] . distance ( epath . path [ path_idx + 1 ] ) if ( distance_reduction >= epath . curSegmentDistance ) return nil end end if ( 0 == path_idx ) return nil end distance_reduction += LANE_WIDTH / 5280.0 if ( distance_reduction >= epath . curSegmentDistance ) return nil end epath . path = epath . path [ 0 .. path_idx ] epath . setLandmark ( epath . segment_dist / ( epath . segment_dist - distance_reduction ) ) return epath end
Rewind the B error by compressing samples from the last landmark to the current
point.
Rewind the B error by compressing samples from the last landmark to the current point .
#Look for the nearest previous intersection along the path, find the #compression factor from the last landmark, compress the distance #from the landmark to there. #First find the last intersection, drop the points from the path after that, #and compare the segment distance to the distance from the last landmark #to the stopping point before the intersection (# of lanes + gutter length) #Failure if we have backed up to the last landmark #Failure case: no more nodes #Also need to back up at least one lane's width from the inersection since #we cannot stop in the middle of it. #Convert lane width in feet into miles (5280 feet in a mile) #Recheck that distance reduction does not hit the landmark #Now drop all of the path that is beyond this intersection since we are #now assuming that the path did not reach those points. #Now set a landmark at this spot
epath
navigator