Exemple #1
0
    def Start(self):
        istyle = vtk.vtkInteractorStyleImage()
        istyle.AddObserver("LeftButtonPressEvent", self.Left)
        istyle.AddObserver("RightButtonPressEvent", self.Right)
        iren = Globals.renWin.GetInteractor()
        iren.SetInteractorStyle(istyle)

        self.spline = Spline.PlaneSpline()
        self.renSpline = Spline.RenderSpline(1)
        self.splineExists = 0
def LoadState(sliceCallback, orientationCallback):
    """ loads all the concerned variables
    and restores the state of an application """

    # open file for reading
    handle = tkFileDialog.askopenfile(filetypes=[('SAVE files', '*.save')])
    if not handle: return

    ### 1. read the rendered properties
    Globals.renderProps = pickle.load(handle)

    # 2. load the slice index and the orientation
    pipelineSliceIndex = pickle.load(handle)
    pipelineOrientation = pickle.load(handle)

    # 3. load the region set
    Globals.objectSet.dic.clear()
    # load the number of regions
    numberOfRegions = pickle.load(handle)
    # load each region
    for i in range(numberOfRegions):
        regionIndex = pickle.load(handle)
        sliceIndex = pickle.load(handle)
        orientation = pickle.load(handle)
        ptsZero = pickle.load(handle)
        ptsOne = pickle.load(handle)
        numberOfProfiles = pickle.load(handle)
        profiles = []
        for j in range(numberOfProfiles):
            p = pickle.load(handle)
            s = Spline.PlaneSpline(p)
            profiles.append(s)
        # commit each region
        zero = Spline.PlaneSpline(ptsZero)
        one = Spline.PlaneSpline(ptsOne)
        region = Region.Region()
        region.SetZeroPoints(zero)
        region.SetOnePoints(one)
        region.sliceIndex = sliceIndex
        region.orientation = orientation
        region.profiles = profiles
        region.rendering.UpdateProfiles(region.profiles)
        Globals.objectSet.AddRegion(region, regionIndex)
        region.Hide()

    handle.close()
    orientationCallback(pipelineOrientation)
    sliceCallback(pipelineSliceIndex)
    Globals.renWin.Render()
Exemple #3
0
    def __init__(self, caller):
        caller.imageObservers.append(self.UpdateObserver)
        self.region = Region()
        self.renSpline = Spline.RenderSpline()
        self.InitCurves()

        self.caller = caller
Exemple #4
0
    def test_with_goe144(self):
        file = ["data/goe144.dat"]

        for f in file:
            (ex, ey, ix, iy) = load_foil(f)

            extrados = spline.compute_smthing_dos(ex, ey, 100)
            intrados = spline.compute_smthing_dos(ix, iy, 100)
            plt.plot(extrados[0], extrados[1], color='green')
            plt.plot(intrados[0], intrados[1], color='green')
            plt.plot([0, 1], [0, 0], color='black')
            plt.scatter(ex, ey, color='red')
            plt.scatter(ix, iy, color='red')
            plt.xlim((0, 1))
            plt.ylim((-0.02, 0.09))
            plt.title("Interpolated curve and original points of goe144")
            plt.show()
Exemple #5
0
def main():
    points = get_data_3()

    # calculate new x's and y's
    x_curve = np.linspace(points.x[0], points.x[-1], 1000)
    y_curve = [None] * 1000
    y_curve_opt = [None] * 1000

    knots = [points.x[0], 1, 2, 3, 4, points.x[len(points) - 1]]
    coefficients = [None] * (len(points) + 2)
    knots.append(knots[len(knots) - 2] + 1)
    knots.sort()
    s = splpckg.Spline(coefficients, knots, 3)
    c = CurveFitter(s)
    c.initiate_grid(s, points)
    q = 1e-9
    c.approximate(s, points, q)

    index = 0
    for point in x_curve:
        y_curve[index] = s.get_value(point)
        index += 1

    index = 0
    knots = s.get_knots()
    knots_y_uni = [0] * len(knots)
    for point in knots:
        knots_y_uni[index] = s.get_value(point)
        index += 1

    c.approximate_with_optimal_grid(s, points, q, 1e-3, 1e-3)

    index = 0
    for point in x_curve:
        y_curve_opt[index] = s.get_value(point)
        index += 1

    index = 0
    knots2 = s.get_knots()
    knots_y = [0] * len(knots2)
    for point in knots2:
        knots_y[index] = s.get_value(point)
        index += 1

    plt.plot(x_curve, y_curve, x_curve, y_curve_opt, points.x, points.y, 'o',
             knots, knots_y_uni, 's', knots2, knots_y, 's')
    plt.legend([
        "Spline on uniform grid", "Spline on optimal grid", "Data",
        "Evenly spreaded knots", "Optimally spreaded knots"
    ])
    plt.xlim([points.x[0] - 1, points.x[-1] + 1])
    plt.show()
Exemple #6
0
def Create_pressure_map(file):
    (ex, ey, ix, iy) = airload.load_foil(file)

    hmin = np.min(iy)
    hmax = np.max(ey)

    func_intra = spline.get_func_splint(ix, iy)
    func_extra = spline.get_func_splint(ex, ey)

    #We define here pressures on the upper and lower part of the wing
    pressure_extra = create_pressures(hmax, func_extra, 0.01, 500)
    pressure_intra = create_pressures(hmin, func_intra, 0.03, 500)

    orig_extra = spline.compute_smthing_dos(ex, ey, 200)
    orig_intra = spline.compute_smthing_dos(ix, iy, 200)

    plt.plot(orig_extra[0], orig_extra[1], color='red')
    plt.plot(orig_intra[0], orig_intra[1], color='red')

    for i in range(1, len(pressure_intra)):
        plt.plot(pressure_intra[i][0], pressure_intra[i][1], color='blue')

    for i in range(1, len(pressure_extra)):
        plt.plot(pressure_extra[i][0], pressure_extra[i][1], color='blue')

    plt.title("Pressure map")
    plt.show()

    length_extra = (compute_pressure_with_speed(pressure_extra))
    length_intra = (compute_pressure_with_speed(pressure_intra))

    #now we create a pixel map for the colors
    result = create_colors(pressure_extra, pressure_intra, length_extra,
                           length_intra)

    plt.imshow(result, cmap="hot")
    plt.show()
Exemple #7
0
def CatmullRomChain(occupancy_grid, P):
    """
  Calculate Catmull–Rom for a chain of points and return the combined curve.
  """
    sz = len(P)
    # C contain splines
    C = []
    i = 0
    while i < sz - 3:
        spline = Spline.Spline(P[i], P[i + 1], P[i + 2], P[i + 3])

        # Collect the point with the shortest distance to an obstacle
        points = spline.discretise()
        dist = None
        for j in range(len(points)):
            for d in np.array([[0, 1], [1, 0], [0, -1], [-1, 0]]):
                direc = d * occupancy_grid._resolution
                if occupancy_grid.is_occupied(points[j] + direc):
                    center = occupancy_grid.get_position(
                        *occupancy_grid.get_index(points[j] + direc))
                    dis = np.linalg.norm(points[j] - center)

                    if dist is None or dis < dist[0]:
                        dist = [dis, j]

        # If point is too close to an obstacle, add point as support node and rebuild splines
        if dist and dist[0] < occupancy_grid._resolution:
            if i < 2:
                print(
                    "There is no path which allow for the starting orientation and curvature constraints."
                )
                return []
            else:
                orig = normalize(P[i + 2] - P[i + 1])
                new = points[dist[1]] - P[i + 1]
                point = P[i + 1] + orig * np.dot(new, orig)
                P.insert(i + 2, point)
                sz += 1
                continue

        C.append(spline)
        i += 1

    return C
Exemple #8
0
def graphicTable(x, y, func=False):
    #Spline and Interpolating polinomial calculation
    #initiates classes
    data = spl.Spline(x, y)
    data2 = inter.Interpolation(x, y)

    spline = data.buildNormalSpline()  #calculates the spline for the dataset
    data2_x, data2_y = data2.interpolateData(
    )  #calculates the interpolating pol
    xs = np.arange(x[0], x[-1] + 0.0001, 0.0001)

    plt.plot(x, y, "o", label="Data")
    if func:
        #displays the actual function f
        plt.plot(xs, f(xs), label='True Value')
    plt.plot(xs, spline(xs), label="Spline Trace")
    plt.plot(data2_x, data2_y, label="Interpolation")
    plt.legend(loc='lower left', ncol=2)
    plt.grid()
    plt.show()

    return data, spline, data2
Exemple #9
0
def simulate(spline, points, dt=0.01):
    print("Simulating...")
    vState = SkidSteer.getInitialState()
    posns = []
    xBound = points[-1][0]
    yBound = points[-1][1] * 1.1
    i = 0

    while (vState[0] < xBound and vState[1] < yBound and vState[0] >= 0
           and vState[1] >= 0):
        (x, y, _, _, _) = vState
        lps = Spline.getLearningParameters(spline, points, (x, y))
        (l, r) = Controller.getControl(lps, vState)
        vState = SkidSteer.step(vState, l, r, dt)
        posns.append((vState[0], vState[1]))

        i += 1
        if True or i % 1000 == 0:
            print(vState)

    print("Done Simulating")

    return posns
Exemple #10
0
 def setUp(self):
     uk = np.array([0, 1, 2, 3, 4, 5], dtype='float')
     d = np.array([[-4, -2, 2, 4], [-4, -2, 2, 4]], dtype='float')
     self.testSpline = Spline.Spline(uk, d)  #d is not used in this function
Exemple #11
0
 def InitCurves(self):
     self.renSpline.Hide()
     self.spline = Spline.PlaneSpline()
     self.renSpline = Spline.RenderSpline(1)
Exemple #12
0
 def Del(self):
     pts = self.spline.points
     del pts[-1]
     self.spline = Spline.PlaneSpline(pts)
     self.renSpline.SetInput(self.spline)
     Globals.renWin.Render()
y_p.append(start_p_1[1])
y_p.append(finish_p_1[1])
y_p.append(finish_p_2[1])
feedrate = [25, 30]
"Степень точности обхода угла"
Lt = 2
n = 0.9
d = Lt/(2*n+1)
c = n*d
e = ((7*n+16))/32*d
print("с = " + str(c))
print("d = " + str(d))
print("e = " + str(e))

"Построение графиков со сплайном и теоретической траекторией"
Axes_spline = Spline.Spline_6(Lt, n, start_p_1, finish_p_1, start_p_2, finish_p_2)
cord_x = []
cord_y = []
#Расчет ошибки обработки напрямую.
cord_05 = []
cord_05.append(Axes_spline[6])
cord_05.append(Axes_spline[7])
cord_05.append(Axes_spline[8])
epsilon = Path_length_calculator.Path_linear(cord_05, finish_p_1)
LEN = len(Axes_spline[0])
print('LEN = ', LEN)
cord_x.append(Axes_spline[6])
cord_x.append(finish_p_1[0])
cord_y.append(Axes_spline[7])
cord_y.append(finish_p_1[1])
print("e = " + str(epsilon))
Exemple #14
0
import math
import Graphs

start_point_1 = [20, 10, 0]
finish_point_1 = [42.361, 30, 0]
start_point_2 = [42.361, 30, 0]
finish_point_2 = [64.721, 10, 0]

Lt = 2
n = 0.3
d = Lt / (2 * n + 1)
c = n * d
cd = c + d
print('c =', c)
print('d =', d)
point_1 = Spline.Point_find(start_point_1, finish_point_1, Lt, 0)
point_6 = Spline.Point_find(start_point_2, finish_point_2, Lt, 1)

point_2 = Spline.Point_find(start_point_1, finish_point_1, cd, 0)
point_3 = Spline.Point_find(start_point_1, finish_point_1, d, 0)

point_4 = Spline.Point_find(start_point_2, finish_point_2, d, 1)
point_5 = Spline.Point_find(start_point_2, finish_point_2, cd, 1)

t = 0.5
x1 = math.pow((1 - t), 5) * point_1[0] + 5 * t * math.pow(
    (1 - t), 4) * point_2[0] + 10 * math.pow(t, 2) * math.pow(
        (1 - t), 3) * point_3[0] + 10 * math.pow(t, 3) * math.pow(
            (1 - t), 2) * point_4[0] + 5 * math.pow(
                t, 4) * (1 - t) * point_5[0] + math.pow(t, 5) * point_6[0]
y1 = math.pow((1 - t), 5) * point_1[1] + 5 * t * math.pow(
Exemple #15
0
def generate_from_path(path: WaypointSequence, config: TrajectoryConfig,
                       generate_trajectory: bool):
    if path.num_waypoints < 2:
        return None

    splines: List[Spline] = []
    for i in range(path.num_waypoints - 1):
        splines.append(Spline())
    spline_lengths = []
    for i in range(len(splines)):
        spline_lengths.append(0.0)
    total_distance = 0.0

    for i in range(path.num_waypoints - 1):
        splines[i] = Spline()
        start = path.waypoints[i]
        end = path.waypoints[i + 1]
        print(splines[i].arc_length)
        splines[i] = Spline.reticulate_spline(start.x, start.y, start.theta,
                                              end.x, end.y, end.theta)
        if splines[i] is None:
            return None

        spline_lengths[i] = splines[i].calculate_length()
        total_distance += spline_lengths[i]

    if generate_trajectory:
        traj = generate(config, 0.0, path.waypoints[0].theta, total_distance,
                        0.0, path.waypoints[0].theta)

        cur_spline = 0
        cur_spline_start_pos = 0.0
        length_of_splines_finished = 0.0

        for i in range(len(traj.segments)):
            cur_pos = traj.segments[i].pos
            found_spline = False

            while not found_spline:
                cur_pos_relative = cur_pos - cur_spline_start_pos
                if cur_pos_relative <= spline_lengths[cur_spline]:
                    percentage = splines[
                        cur_spline].get_percentage_for_distance(
                            cur_pos_relative)

                    traj.segments[i].heading = splines[cur_spline].angle_at(
                        percentage)
                    coords = splines[cur_spline].get_xy(percentage)

                    traj.segments[i].x = coords[0]
                    traj.segments[i].y = coords[1]
                    found_spline = True
                elif cur_spline < len(splines) - 1:
                    length_of_splines_finished += spline_lengths[cur_spline]
                    cur_spline_start_pos = length_of_splines_finished
                    cur_spline += 1
                else:
                    traj.segments[i].heading = splines[len(splines) -
                                                       1].angle_at(1.0)
                    coords = splines[len(splines) - 1].get_xy(1.0)
                    traj.segments[i].x = coords[0]
                    traj.segments[i].y = coords[1]
                    found_spline = True
        return traj
    else:
        return splines
Exemple #16
0
            [100, 0, 0]]

"Степень точности обработки углов"
tolerance_angle = [10, 10]
ratio = [0.95, 0.4]

"Определение углов между участками траектории"
print("Анализ углов участков траектории.")
angles = Trajectory_mapping.Trajectory_analisys(st_point, fn_point)
for i in range (len(angles)):
    print(Work_with_files.Write_log("Между участками " + str(i+1) + " и " + str (i+2) + " имеется угол в " + str(angles[i]) + " град."))

length_1 = CIRCLE.Length_linear(st_point[0], fn_point[0])
length_2 = CIRCLE.Length_linear(st_point[1], fn_point[1])

start = Spline.Point_find (st_point[0], fn_point[0], length_1, 0)
finish = Spline.Point_find (st_point[1], fn_point[1], length_2, 1)
spline_result = Spline.Spline6_interpolation(tolerance_angle[0], ratio[0], st_point[0], fn_point[0], st_point[1], fn_point[1], T, V)
spline_result_1 = Spline.Spline6_interpolation(tolerance_angle[1], ratio[1], st_point[0], fn_point[0], st_point[1], fn_point[1], T, V)
print('Острый угол')
print('Минимальная величина сегмента: ' + str(min(spline_result[9])))
print('Максимальная величина сегмента: ' + str(max(spline_result[9])))
print('Число сегментов: ' + str(len(spline_result[9])))
print('Минимальная ошибка: ' + str(min(spline_result[10])))
print('Максимальная ошибка: ' + str(max(spline_result[10])))

print('Тупой угол')
print('Минимальная величина сегмента: ' + str(min(spline_result_1[9])))
print('Максимальная величина сегмента: ' + str(max(spline_result_1[9])))
print('Число сегментов: ' + str(len(spline_result_1[9])))
print('Минимальная ошибка: ' + str(min(spline_result_1[10])))
def Trajectory_mapping(start_points, finish_points, tolerance_list, ratio_list,
                       optimal_ratio_list, optimal_agree):
    x_points = []
    y_points = []
    spline = []
    spline_x = []
    spline_y = []
    spline_x_out = []
    spline_y_out = []
    spline_z_out = []
    for i in range(len(start_points)):
        x_points.append(start_points[i][0])
        x_points.append(finish_points[i][0])
        y_points.append(start_points[i][1])
        y_points.append(finish_points[i][1])
    spline_x.append(start_points[0][0])
    spline_y.append(start_points[0][1])
    for i in range(len(start_points) - 1):
        if optimal_agree[i] == 1:
            spline = Spline.Spline_6(tolerance_list[i], optimal_ratio_list[i],
                                     start_points[i], finish_points[i],
                                     start_points[i + 1], finish_points[i + 1])
        elif optimal_agree[i] == 0:
            spline = Spline.Spline_6(tolerance_list[i], ratio_list[i],
                                     start_points[i], finish_points[i],
                                     start_points[i + 1], finish_points[i + 1])
        spline_x_out.append(spline[0])
        spline_y_out.append(spline[1])
        spline_z_out.append(spline[2])
        epsilon_x = []
        epsilon_x.append(spline[6])
        epsilon_x.append(start_points[i + 1][0])
        epsilon_y = []
        epsilon_y.append(spline[7])
        epsilon_y.append(start_points[i + 1][1])
        epsilon = Path_length_calculator.Path_linear(
            [epsilon_x[0], epsilon_y[0]], [epsilon_x[1], epsilon_y[1]])
        print("Ошибка обработки: " + str(epsilon))
        """Русский язык"""
        #Graphs.Plotting_02(spline[0], spline[1], spline[3], spline[4],
        #"Ось x, мм", "Ось y, мм", "Траектория инструмента в угле " + str(i+1), "Истинная траектория", "Запрограммированная траектория")
        """English language"""
        Graphs.Plotting_02(spline[0], spline[1], spline[3], spline[4], "X, mm",
                           "Y, mm", "Tool trajectory at corner " + str(i + 1),
                           "Final trajectory", "Programmed trajectory",
                           "6Spline" + str(i + 1))
        #Graphs.Plotting_03_help(spline[0], spline[1], spline[3], spline[4], epsilon_x, epsilon_y,
        #"Ось x, мм", "Ось y, мм", "Траектория инструмента в угле " + str(i+1), "Истинная траектория", "Запрограммированная траектория")
        for j in range(len(spline[0])):
            spline_x.append(spline[0][j])
            spline_y.append(spline[1][j])
    spline_x.append(finish_points[len(start_points) - 1][0])
    spline_y.append(finish_points[len(finish_points) - 1][1])
    """Русский язык"""
    #Graphs.Plotting_02_colors(spline_x, spline_y, x_points, y_points,
    #                   "Ось x, мм", "Ось y, мм", "Траектория инструмента", "Истинная траектория", "Запрограммированная траектория")
    """English language"""
    Graphs.Plotting_02_colors(spline_x, spline_y, x_points, y_points, "X, mm",
                              "Y, mm", "Tool trajectory", "Final trajectory",
                              "Programmed trajectory", "6TrajectoryH")

    return spline_x_out, spline_y_out, spline_z_out, spline[6], spline[
        7], spline[8]
Exemple #18
0
import matplotlib.pyplot as mpl
import Spline
import SkidSteer
import Simulate

points = [(0, 0), (0.3, 4), (0.5, 5), (1, 10)]

splines = Spline.makeSpline(points)
print(splines)
rectified = Spline.rectify(splines, points, 0.01)
posns = Simulate.simulate(splines, points)

(xs, ys) = zip(*posns)
(yPath, _, _, _) = zip(*rectified)
xPath = list(
    map(lambda x: x * (points[-1][0] / len(yPath)), range(0, len(yPath))))

print(list(zip(xs, ys)))

mpl.plot(xPath, yPath)
mpl.plot(xs, ys)
mpl.legend(["Path To Follow", "Attempted Following"])
mpl.show()
Exemple #19
0
#---------------------------------------
Xfig.find_coordinates(obj_list, box_margins)
if xy_specified != "None":
    obj_list = Objects.load_xy_coordinates(xy_specified,      \
                                           obj_list,          \
                                           object_hierarchy)

#----------------------------
# Find calls between objects
#----------------------------
obj_list = Finder.get_new_calls(file_paths, obj_list, obj_memb)

#------------------------------------
# Create connections between objects
#------------------------------------          offset          stride
spl_list = Spline.connect_objects(obj_list, box_margins, box_margins * 0.5)

#----------------
# Open Xfig file
#----------------
file = open(Const.FIG_FILE_NAME, "w")

#------------------
# Write header out
#------------------
Xfig.write_header(file)

#-------------------------------------------
# Plot all fortran files starting from root
#-------------------------------------------
Xfig.plot_all(file, obj_list, spl_list, box_margins)
print('Максимальная величина сегмента: ' + str(max(curve_r[4])))

'Построение траектории со скруглениями'
'Траектория'
points = [[2, 2, 0], [2, 5, 0], [6, 8, 0], [8, 4, 0], [5, 0, 0], [2, 2, 0]]
x_points = []
y_points = []
x_no_smooth = []
y_no_smooth = []
for i in range(len(points)):
    x_no_smooth.append(points[i][0])
    y_no_smooth.append(points[i][1])
x_points.append(points[0][0])
y_points.append(points[0][1])
for i in range(len(points) - 2):
    corner_smooth = Spline.Spline_6(Lt, n, points[i], points[i + 1],
                                    points[i + 1], points[i + 2])
    for j in range(len(corner_smooth[0])):
        x_points.append(corner_smooth[0][j])
        y_points.append(corner_smooth[1][j])
x_points.append(points[len(points) - 1][0])
y_points.append(points[len(points) - 1][1])

#Graphs.Plotting_01(x_no_smooth, y_no_smooth, 'Ось X', 'Ось Y', 'Исходная траектория', 'Траектория', 'input_trajectory')
#Graphs.Plotting_01(x_points, y_points, 'Ось X', 'Ось Y', 'Скругление', 'Реальная траектория', 'output_trajectory')
#Graphs.Plotting_02(x_points, y_points, x_no_smooth, y_no_smooth,
#                   'Ось X', 'Ось Y', 'Построение треаектории со скруглениями', 'Реальная траектория', 'Заданная траектория', 'final_trajectories')

#Graphs.Plotting_01(x_coord, y_coord, 'Ось X', 'Ось Y', 'Угол', 'da', 'circle')
#Graphs.Plotting_01(corner_smooth[0], corner_smooth[1], 'Ось X', 'Ось Y', 'Скругление', 'Реальная траектория', 'circle')

#Graphs.Plotting_02(corner_smooth[0], corner_smooth[1], corner_smooth[3], corner_smooth[4],
Exemple #21
0
 def testOverlappingKnotPoints(self):
     self.testSpline = Spline.Spline(
         np.array([0, 1, 2, 2, 2, 2, 6, 7], dtype='float64'),
         np.array([[-6, -4, -2, 2, 4, 6], [-6, -4, -2, 2, 4, 6]],
                  dtype='float64'))
     assert self.testSpline._findHotInterval(3.) == 5
Exemple #22
0
 def setUp(self):
     self.testSpline = Spline.Spline(
         np.array([0, 1, 2, 3, 4, 5, 6, 7], dtype='float64'),
         np.array([[-6, -4, -2, 2, 4, 6], [-6, -4, -2, 2, 4, 6]],
                  dtype='float64'))
Exemple #23
0
"Определение углов между участками траектории"
print(Work_with_files.Write_log("Анализ углов участков траектории."))
angles = Trajectory_mapping.Trajectory_analisys(st_point, fn_point)
for i in range (len(angles)):
    print(Work_with_files.Write_log(
        "Между участками " + str(i+1) + " и " + str (i+2) + " имеется угол в " + str(angles[i]) + " град."))
    
    optimal_ratio.append(round(1/(2.0769)*math.pow(math.radians(angles[i]), 0.9927), 2))
    print(Work_with_files.Write_log("Оптимальное отношение сторон c и d равно " + str(optimal_ratio[i]) + "."))
"Построение траектории запрограммированной и истинной с учетом скругления углов"
spline_coord = Trajectory_mapping.Trajectory_mapping(st_point, fn_point, tolerance_angle, ratio, optimal_ratio, optimal_agree_list)
print("_________________")
print(Work_with_files.Write_log("Анализ допустимой скорости в углах."))
length_angles_list = []
for i in range (len(spline_coord[0])):
    length_angles = Spline.Spline_length(spline_coord[0][i], spline_coord[1][i], spline_coord[2][i])
    length_angles_list.append(length_angles)
    print(Work_with_files.Write_log(
        "Длина пути на углу между " + str(i+1) + " и " + str(i+2) + " блоками равна " + str(round(length_angles, 4)) + " мм."))
"Подсчет допустимой скорости в углах."
feedrate_angles_list = []
for i in range (len(length_angles_list)):
    feedrate_angles = Spline.Corner_feedrate(feedrate_input[i], feedrate_input[i+1], path_l_list[i], path_l_list[i+1],
                                      st_point[i], fn_point[i], st_point[i+1], fn_point[i+1], [max_acceleration, max_acceleration, max_acceleration])
    feedrate_angles_list.append(feedrate_angles)
    print(Work_with_files.Write_log(
        "Максимальная допустимая скорость на углу между " + str(i+1) + " и " + str(i+2) + " блоками равна " + str(feedrate_angles) + " мм/с."))
print("_________________")
print(Work_with_files.Write_log("Анализ длины участков траектории с учетом сгругления углов."))
for i in range (len(path_l_list)):
    if i == 0:
Exemple #24
0
 def setUp(self):
     self.testSpline = Spline.Spline(
         np.linspace(0, 2),
         np.vstack((np.linspace(0, 1, 48), np.linspace(0, 1, 48))))
Exemple #25
0
import Spline
import Profile_generation
import Path_length_calculator
import Block_type
import Graphs

"""Тело программы для расчета индивидуального сплайна и профиля скорости в угле"""
"Точки траектории"
start_p_1 = [20, 10, 0]
finish_p_1 = [42.361, 30, 0]
start_p_2 = [42.361, 30, 0]
finish_p_2 = [64.721, 10, 0]
"Степень точности обхода угла"
tolerance = 2
"Построение сплайна"
Axes_spline_list = Spline.Spline_3(start_p_1, finish_p_1, start_p_2, finish_p_2, tolerance)
"Построение графиков со сплайном и теоретической траекторией"
x_hole = []
x_hole.append(start_p_1[0])
x_hole.append(finish_p_1[0])
x_hole.append(finish_p_2[0])
y_hole = []
y_hole.append(start_p_1[1])
y_hole.append(finish_p_1[1])
y_hole.append(finish_p_2[1])
z_hole = []
z_hole.append(start_p_1[2])
z_hole.append(finish_p_1[2])
z_hole.append(finish_p_2[2])

"""Русский язык"""
Exemple #26
0
# Example code that gets s(u) given knots and boor points and plots the result.
# Note that each knot has a corresponding boor point. It is important that these
# are np.arrays, ordered in rising order, i.e [u1, u2, u3...] and [d1,d2,d3...].

# we define knots and boor points:
u = 0
u_knots = np.array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.])
boor_points = np.array([[0, 0], [1, 1], [2, 4], [3, 2], [4, 7], [5, 7], [6, 6],
                        [7, 5], [8, 7], [8, 2], [7, 2]])
print(type(u), type(u_knots), type(boor_points))

# Either use the spline directly and loop like this
S = np.zeros((101, 2))
for i in range(0, 101):
    u = (i * 0.01)
    S[i, :] = spl.spline(u, u_knots, boor_points)

print(type(S))
plt.plot(boor_points[:, 0], boor_points[:, 1], 'r--')
plt.plot(boor_points[:, 0], boor_points[:, 1], 'ro')
plt.plot(S[:, 0], S[:, 1])
plt.title(
    "Looped spline: Cubic spline with its polynomial segments and it's controll polygon"
)
plt.show()

# Or you can use spline_set and send in an entire grid as a numpy array like this:
u = np.arange(0, 1.01, 0.01)
S = spl.spline_set(u, u_knots, boor_points)

print(type(S))