Ejemplo n.º 1
0
    print "Ready!"
    rospy.spin()


if __name__ == "__main__":
    args = parser.parse_args()
    n_subjects = args.n_subjects
    n_books = args.n_books
    seed = args.seed
    print "n_subjectes: ", n_subjects
    print "n_books:", n_books
    if n_subjects > 20:
        print('Maximum no. of subjects available is: 20')
        exit()
    book_sizes = 2
    book_count_of_each_subject = n_books * book_sizes
    book_count_list = [n_books] * n_subjects * book_sizes
    number_of_trollies = n_subjects * 2
    # grid_size = max((((book_count_of_each_subject * n_subjects) / 4) // 1 ) + 1, ((number_of_trollies/4)*7), 10)
    grid_size = 6 * n_subjects
    mazeInfo = Maze(grid_size, 0.5)
    book_count_list = [n_books] * 2
    books = mazeInfo.generate_blocked_edges(book_count_list, seed,
                                            number_of_trollies, root_path)
    mazeInfoCopy = copy.deepcopy(mazeInfo)
    print "blocked_edges: ", mazeInfo.blocked_edges
    rospy.init_node('server')
    robot_action_server = RobotActionsServer(books, root_path,
                                             args.action_seed)
    server()
Ejemplo n.º 2
0

if __name__ == "__main__":
    global robot_action_server
    global mazeInfo
    global mazeInfoCopy
    args = parser.parse_args()
    n_subjects = args.n_subjects
    n_books = args.n_books
    seed = args.seed
    print n_subjects
    print n_books
    if n_subjects > 20:
        print('Maximum no. of subjects available is: 20')
        exit()
    book_sizes = 2
    book_count_of_each_subject = n_books * book_sizes
    book_count_list = [n_books] * n_subjects * book_sizes
    number_of_trollies = n_subjects * 2
    # grid_size = max((((book_count_of_each_subject * n_subjects) / 4) // 1 ) + 1, ((number_of_trollies/4)*7), 10)
    grid_size = 6 * n_subjects
    mazeInfo = Maze(grid_size, 0.5)
    books = mazeInfo.generate_blocked_edges(book_count_list, seed,
                                            number_of_trollies, root_path)
    mazeInfoCopy = copy.deepcopy(mazeInfo)
    print mazeInfo.blocked_edges
    rospy.init_node('server')
    robot_action_server = RobotActionsServer(books, args.headless == 1,
                                             args.action_seed)
    server()
Ejemplo n.º 3
0
    rospy.Service('get_goal_state',GetGoalState,handle_get_goal_state)
    rospy.Service('remove_blocked_edge', RemoveBlockedEdgeMsg,remove_blocked_edge)
    print "Ready!"
    rospy.spin()
	
if __name__ == "__main__":
    args = parser.parse_args()
    n_subjects = args.n_subjects
    n_books = args.n_books
    seed = args.seed
    print n_subjects
    print n_books
    if n_subjects > 20:
    	print('Maximum no. of subjects available is: 20')
    	exit()
    book_sizes = 2
    book_count_of_each_subject = n_books * book_sizes
    book_count_list = [n_books] * n_subjects * book_sizes
    number_of_trollies = n_subjects * 2
    # grid_size = max((((book_count_of_each_subject * n_subjects) / 4) // 1 ) + 1, ((number_of_trollies/4)*7), 10)
    grid_size = 6 * n_subjects
    books, mazeInfo = generate_blocked_edges(grid_size, book_count_list, seed,  number_of_trollies, root_path,0.5)
    path = root_path + "/problem.pddl"
    problem_generator.write_pddl(path ,books)
    # pickle.dump(books,out_file)
    rospy.init_node('server')
    RobotActionsServer(books)
    # rospy.sleep(3)
   	# pprint.pprint(books)
    server()
Ejemplo n.º 4
0
	mazeInfo[1].remove((x, y, x+0.5, y))
	mazeInfo[1].remove((x+0.5, y, x+1, y))
	mazeInfo[1].remove((x+1, y, x+1.5, y))
	mazeInfo[1].remove((x+0.5, y-0.5, x+0.5, y))
	mazeInfo[1].remove((x+0.5, y, x+0.5, y+0.5))
	return "1"

def server():
    rospy.Service('get_successor', GetSuccessor, handle_get_successor)
    rospy.Service('get_initial_state', GetInitialState, handle_get_initial_state)
    rospy.Service('is_goal_state', IsGoalState, handle_is_goal_state)
    rospy.Service('get_goal_state',GetGoalState,handle_get_goal_state)
    rospy.Service('remove_blocked_edge', RemoveBlockedEdgeMsg,remove_blocked_edge)
    print "Ready!"
    rospy.spin()
	
if __name__ == "__main__":
    args = parser.parse_args()
    n_cubes = args.n_cubes
    seed = args.seed
    print n_cubes
    grid_size = 6
    if(n_cubes > 6):
		grid_size = n_cubes

    cubes, mazeInfo = generate_blocked_edges(grid_size, n_cubes, seed, root_path, 0.5)
    path = root_path + "/problem.pddl"
    problem_generator.write_pddl(path ,cubes)
    rospy.init_node('server')
    RobotActionsServer(cubes)
    server()
Ejemplo n.º 5
0
from datetime import datetime
from math import sqrt
from action_server import RobotActionsServer
from mazeGenerator import *

rospy.init_node("search_algorithms")
publisher = rospy.Publisher("/actions", String, queue_size=10)
parser = argparse.ArgumentParser()
parser.add_argument('-a', help="Please mention algorithm to use. Possible arguments = {bfs, ucs, gbfs, astar, dead_end_filling, floodfill,leftHand}. Default value is dead_end_filling.", metavar='dead_end_filling', action='store', dest='algorithm', default="dead_end_filling", type=str)
parser.add_argument('-c', help="Use custom heuristic function. No value needed.", action='store_true', dest='custom_heuristic')
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
mazeInfo = Maze(6, 0.5)
# books = mazeInfo.generate_blocked_edges(1, 32,  1, root_path)
mazeInfoCopy = copy.deepcopy(mazeInfo)
#print "blocked_edges: ", mazeInfo.blocked_edges
robot_action_server = RobotActionsServer({}, root_path, 32)
def manhattan_distance(state1, state2):
    return abs(state1[0]-state2.x) + abs(state1[1]-state2.y)
    
def opt_manhattan_distance(state1, state2):
    dx = 2 * abs(state1[0]-state2.x)
    dy = 2 * abs(state1[1]-state2.y)
    dist = dx + dy
    if dx !=0 and dy != 0:  # Add extra 2 for the turn cost if it is not along the horizontal or vertical to the goal
        dist += 2
    return dist
    
def euclidean_distance(state1, state2):
    dx = state1[0] - state2.x
    dy = state1[1] - state2.y
    return sqrt(dx*dx + dy*dy)
Ejemplo n.º 6
0
def server():
    rospy.Service('remove_blocked_edge', RemoveBlockedEdgeMsg,
                  remove_blocked_edge)
    rospy.Service('check_is_edge', CheckEdge, check_is_edge)
    rospy.Service('reset_world', ResetWorldMsg, handle_reset_world)
    print("Ready!")
    rospy.spin()


if __name__ == "__main__":
    args = parser.parse_args()
    print('houses: ' + str(args.houses * args.streets))
    print('packages: ' + str(args.packages))
    print('streets: ' + str(args.streets))
    print('robots: ' + str(args.robots))
    neighborhoodInfo = Neighborhood(12, 0.5)
    objects = neighborhoodInfo.generate_blocked_edges(args.houses,
                                                      args.streets,
                                                      args.packages, args.seed,
                                                      root_path)
    objects = neighborhoodInfo.generate_launch(args.robots, objects, root_path)
    neighborhoodInfoCopy = copy.deepcopy(neighborhoodInfo)
    rospy.init_node('server')
    robot_action_server = RobotActionsServer(objects, args.robots, root_path,
                                             args.headless, args.seed)
    path = root_path + "/problem.pddl"
    with open(root_path + "/deliveries.json") as json_file:
        deliveries = json.load(json_file)
    problem_generator.write_pddl(path, deliveries)
    server()