Example #1
0
    def sample_points(self):
        if self.is_points_valid is False:
            print "Error : Please check the points..."
            return None, None

        step_size, total_steps = self.sample_rate()
        t = np.linspace(0.0, 1.0, total_steps)
        samples = self.bspline(total_steps, self.order)
        yaw_samples = calculate_yaw(samples)
        return samples, yaw_samples
Example #2
0
    def sample_points(self):
        #samples = yaw_samples = []
        if self.is_points_valid is False:
            print "Warning : Error in points (or) first 3 points are being considered"

        step_size, total_steps = self.sample_rate()
        t = np.linspace(0.0, 1.0, total_steps)
        x, y = self.ellipse(step_size)
        samples = np.array((x, y)).T
        yaw_samples = calculate_yaw(samples)
        return samples, yaw_samples
Example #3
0
    def sample_points(self):
        xPoints = np.array([point[0] for point in self.points])
        yPoints = np.array([point[1] for point in self.points])
        nPoints = len(self.points)

        step_size, total_steps = self.sample_rate()
        self.samples = []
        t = np.linspace(0.0, 1.0, total_steps)

        polynomial_array = np.array(
            [bernstein_poly(i, nPoints - 1, t) for i in range(0, nPoints)])

        xvals = np.dot(xPoints, polynomial_array)
        yvals = np.dot(yPoints, polynomial_array)

        samples = np.array((xvals, yvals)).T
        samples = samples[::-1]
        yaw_samples = calculate_yaw(samples)
        return (samples, yaw_samples)
Example #4
0
    def sample_points(self):
        if self.is_points_valid is False:
            print "Error : Please check the points..."
            return None, None

        nPoints = len(self.points)
        xPoints = np.array([point[0] for point in self.points])
        yPoints = np.array([point[1] for point in self.points])

        step_size, total_steps = self.sample_rate()

        x=self.points[:,0]
        y=self.points[:,1]

        tck,u = interpolate.splprep([x,y],k=3,s=0)
        u=np.linspace(0,1,total_steps,step_size)
        out = interpolate.splev(u,tck)

        samples = np.array((out[0], out[1])).T
        yaw_samples = calculate_yaw(samples)
        return (samples, yaw_samples)
Example #5
0
    def sample_points(self):
        if self.is_points_valid is False:
            print "Error : Please check the points..."
            return None, None

        totalDist = 0
        ctrlPtDists = [0]
        ptOffsetRatios = []

        for pt in range(len(self.points) - 1):
            dist = distance(self.points[pt], self.points[pt + 1])
            totalDist += dist
            ptOffsetRatios.append(self.offset_dist / dist)
            ctrlPtDists.append(totalDist)

        step_size, total_steps = self.sample_rate()

        samples = []
        # Starting point
        samples.append(
            self.offset_point(self.points[0],
                              self.points[1][0] - self.points[0][0],
                              self.points[1][1] - self.points[0][1],
                              ptOffsetRatios[0]))

        prevCtrlPtInd = 0
        currDist = 0
        currPoint = self.points[0]
        nextDist = step_size

        for pt in range((int(total_steps))):
            while (nextDist > ctrlPtDists[prevCtrlPtInd + 1]):
                prevCtrlPtInd = (prevCtrlPtInd + 1)
                currDist = ctrlPtDists[prevCtrlPtInd]
                currPoint = self.points[prevCtrlPtInd]

            remainingDist = (nextDist - currDist)
            ctrlPtsDeltaX = self.points[prevCtrlPtInd +
                                        1][0] - self.points[prevCtrlPtInd][0]
            ctrlPtsDeltaY = self.points[prevCtrlPtInd +
                                        1][1] - self.points[prevCtrlPtInd][1]
            ctrlPtsDist = ctrlPtDists[prevCtrlPtInd +
                                      1] - ctrlPtDists[prevCtrlPtInd]
            distRatio = remainingDist / ctrlPtsDist

            if not np.isclose(remainingDist, step_size):
                residue = [currPoint[0], currPoint[1]]
                samples.append(
                    self.offset_point(residue, ctrlPtsDeltaX, ctrlPtsDeltaY,
                                      ptOffsetRatios[prevCtrlPtInd]))
            else:
                currPoint = [
                    currPoint[0] + ctrlPtsDeltaX * distRatio,
                    currPoint[1] + ctrlPtsDeltaY * distRatio
                ]
                samples.append(
                    self.offset_point(currPoint, ctrlPtsDeltaX, ctrlPtsDeltaY,
                                      ptOffsetRatios[prevCtrlPtInd]))

            currDist = nextDist
            nextDist += step_size

        samples.append(
            self.offset_point(
                self.points[len(self.points) - 1],
                self.points[len(self.points) - 1][0] -
                self.points[len(self.points) - 2][0],
                self.points[len(self.points) - 1][1] -
                self.points[len(self.points) - 2][1],
                ptOffsetRatios[len(ptOffsetRatios) - 1]))
        samples = np.asarray(samples)
        return samples, calculate_yaw(samples)