A toolset for generate random points and map it.

Function define part

random_generate[source]

random_generate(offset_x, offset_y, point_num, area_length_x, area_length_y)

generate random points with mutiple parameters. Args: offset_x : offset for x's range. offset_y : offset for y's range. point_num : number of points to generate. area_length_x : x's range for generate random points. area_length_y : y's range for generate random points. Returns: rand_point_x : list of random points' x coordinate. rand_point_y : list of random points' y coordinate.

sub_random_generate[source]

sub_random_generate(offset_x, offset_y, point_num, area_length_x, area_length_y, sub_area_num, sub_offset_x, sub_offset_y)

generate random points with mutiple parameters, including sub_area_num and sub_offset. Args : offset_x : offset for x's range. offset_y : offset for y's range. point_num : number of points to generate. area_length_x : x's range for generate random points. area_length_y : y's range for generate random points. sub_area_num : sub_offset_x : sub_offset_y : Returns : rand_point_x : list of random points' x coordinate. rand_point_y : list of random points' y coordinate. Outputs : output_point.txt : random points' x and y coordinate.

draw_line[source]

draw_line(sub_area_num, x_min, x_increment, y_min, y_max)

draw straight line in a plot. Args: sub_area_num : number of area that separated by lines. x_min : where the line starts. x_increment : distance of two lines. y_min : line's y lower coordinate. y_max : line's y upper coordinate.

Testing example

we will move to 'data' directory to start all examples, this directory have been added to '.gitignoe' , so is convenient to test in local and light in cloud

import matplotlib.pyplot as plt
cd data
/home/arg/arg_robotics_tools/data

random_generater( )

generate random points and save it in rand_point_x, rand_point_y.

rand_point_x = []
rand_point_y = []
rand_point_x, rand_point_y = random_generate(offset_x = -143,
                                             offset_y = 184,
                                             point_num = 100,
                                             area_length_x = 200,
                                             area_length_y = 50)

plot the lines and points that just generate.

draw_line(sub_area_num = 20, 
          x_min = -233, 
          x_increment = 10, 
          y_min = 160, 
          y_max = 210)
plt.plot(rand_point_x, rand_point_y, 'o', color='red')
[<matplotlib.lines.Line2D at 0x7f9a845646d0>]

sub_random_generate( )

generate sub random points and save it in rand_point_x, rand_point_y.

rand_point_x = []
rand_point_y = []
rand_point_x, rand_point_y = sub_random_generate(offset_x = -143, 
                                                 offset_y = 184, 
                                                 point_num = 100, 
                                                 area_length_x = 200, 
                                                 area_length_y = 50, 
                                                 sub_area_num = 20, 
                                                 sub_offset_x = 10, 
                                                 sub_offset_y = 10)

plot the lines and points that just generate.

draw_line(20, -233, 10, 160, 210)
plt.plot(rand_point_x, rand_point_y, 'o', color='red')
[<matplotlib.lines.Line2D at 0x7f9a84351640>]