hns module

Author: David Velasco Garcia @davidvelascogarcia

class hns.HNS[source]

Bases: object

analyze(map, coordinate_x, coordinate_y)[source]

Analyze map status.

Parameters
  • map – int

  • coordinate_x – int

  • coordinate_y – int

Returns

up_status: int, down_status: int, right_status: int, left_status: int

assign_targets(map, init_x, init_y, goal_x, goal_y)[source]

Assign init and goal locations.

Parameters
  • map – int

  • init_x – int

  • init_y – int

  • goal_x – int

  • goal_y – int

Returns

map: int

check_location(map, x_coordinate, y_coordinate)[source]

Check if location is available.

Parameters
  • map – int

  • x_coordinate – int

  • y_coordinate – int

Returns

result: bool

clear_previous_location(map, coordinate_x, coordinate_y)[source]

Clear previous location in map.

Parameters
  • map – int

  • coordinate_x – int

  • coordinate_y – int

Returns

map: int

end_resume(init_time, steps)[source]

Print end resume.

Parameters
  • init_time – datetime

  • steps – int

Returns

get_config()[source]

Get config data. Select map dir, map and initial/goal locations.

Returns

map: string, init_x: int, init_y: int, goal_x: int, goal_y: int

get_distance(coordinate_x, coordinate_y, goal_x, goal_y)[source]

Get distance to goal with and without direction.

Parameters
  • coordinate_x – int

  • coordinate_y – int

  • goal_x – int

  • goal_y – int

Returns

distance_x: int, distance_y: int, abs_distance_x: int, abs_distance_y: int

get_map(map)[source]

Get map and transform to 2D matrix.

Parameters

map – string

Returns

map: int

get_platform()[source]

Get system platform and release.

Returns

sys_platform: string, sys_release: string

goal_achieved()[source]

Goal achived message.

Returns

None

goal_not_achieved()[source]

Goal not achived message :return: None

move(map, command, coordinate_x, coordinate_y)[source]

Move system with decision planned.

Parameters
  • map – int

  • command – string

  • coordinate_x – int

  • coordinate_y – int

Returns

map: int

process(map, init_x, init_y, goal_x, goal_y, yarp_mode, hns_output_port, hns_input_port, screen, screen_width, screen_height, rows, columns, background, wall, robot, sim_period, init)[source]

Process path planning.

Parameters
  • yarp_mode – bool

  • hns_output_port – YarpDataPort

  • hns_input_port – YarpDataPort

  • map – int

  • init_x – int

  • init_y – int

  • goal_x – int

  • goal_y – int

Returns

None

resume(init_x, init_y, goal_x, goal_y)[source]

Print path planning resume.

Parameters
  • init_x – int

  • init_y – int

  • goal_x – int

  • goal_y – int

Returns

None

show_map(map)[source]

Show map with pretty format.

Parameters

map – int

Returns

None

take_decision(up, down, right, left, distance_x, distance_y, abs_distance_x, abs_distance_y, buffer)[source]

Take decision. Preference higher distance sense, second higher distance sense, second higher distance invert sense, higher distance invserse sense.

Parameters
  • buffer – queue

  • up – int

  • down – int

  • right – int

  • left – int

  • distance_x – int

  • distance_y – int

  • abs_distance_x – int

  • abs_distance_y – int

Returns

command: string:, buffer: queue

update_location(coordinate_x, coordinate_y)[source]

Update actual coordinates.

Parameters
  • coordinate_x – int

  • coordinate_y – int

Returns

update_map(map, coordinate_x, coordinate_y)[source]

Update map.

Parameters
  • map – int

  • coordinate_x – int

  • coordinate_y – int

Returns

map: int

yarp_connection(hns_output_port, hns_input_port, target, target_response)[source]

Connect yarp ports.

Parameters
  • hns_output_port – YarpDataPort

  • hns_input_port – YarpDataPort

  • input_target – string

  • output_target – string

Returns

None

yarp_interaction(hns_output_port, hns_input_port, command)[source]

Send command to system and wait until action is executed and received callback.

Parameters
  • hns_output_port – YarpDataPort

  • hns_input_port – YarpDataPort

  • command – string

Returns

None

class hns.Screen[source]

Bases: object

Class PyGame simulation screen.

build_screen(screen_width, screen_height)[source]

Build PyGame screen.

Parameters
  • screen_height – int

  • screen_width – int

Returns

None

config()[source]

Get simulation parameters like screen size, colors and simulation time.

Returns

screen_width: int, screen_height: int, background: int, wall: int, robot: int

get_map_size(map)[source]

Get map parameters. Number of rows and columns.

Parameters

map – int

Returns

rows: int, columns: int

simulate(screen_width, screen_height, map, rows, columns, background, wall, robot, sim_period, coordinate_x, coordinate_y, init)[source]

Simulate PyGame screen.

Parameters
  • screen_height – int

  • screen_width – int

  • map – int

  • rows – int

  • columns – int

  • background – int

  • wall – int

  • robot – int

  • sim_period – float

  • coordinate_x – int

  • coordinate_y – int

Returns

init: bool

class hns.YarpDataPort(name)[source]

Bases: object

Class yarp data ports. Allow build sender and receiver ports and close them.

close()[source]

Close yarp port.

Returns

None

receive()[source]

Receive data from yarp port and return it.

Returns

data: string

send(data)[source]

Send data with yarp port.

Parameters

data – string

Returns

None

hns.main()[source]

Process HNS.

Returns

None