Example #1
0
int main(void) {
    struct arena_posn loc1 = {40,40};
    struct arena_posn loc2 = {60,60};
	struct robot r1 = create_robot(VINCENT,'E', loc1, 10);
    struct robot r2 = create_robot(MAXIMILLIAN,'W', loc2, 5);
    loop(r1, r2, 0);
}
Example #2
0
int test4()
{
    p1u_setup();
	enable_robot_debug_message();    
    create_robot_world_with_dimensions(5, 5);
    create_robot();
    turn_on_debug_output();
        
    move_beepers();

		// Beepers both present so both should be moved
    P1U_ASSERT_EQUAL("Robot should be at X = 0", 0, get_current_robot_x());
	P1U_ASSERT_EQUAL("Robot should be at Y = 0", 0, get_current_robot_y());    
    P1U_ASSERT_EQUAL("Robot should be facing east", get_current_robot_orientation(), get_east());    
    P1U_ASSERT_FALSE("Robot should survive", is_robot_dead());

    p1u_shutdown();
    return (p1world_shutdown());
}
Example #3
0
int test1()
{	
    p1u_setup();
	enable_robot_debug_message();    
    create_robot_world_with_dimensions(5, 5);
    setup_beeper(0, 1);
    setup_beeper(0, 2);
    create_robot();
    turn_on_debug_output();
    
    move_beepers();

		// Beepers both present so both should be moved
	P1U_ASSERT_EQUAL("There should be 2 beepers at (2, 4)", 2, get_count_of_beepers_at(4, 2));
    P1U_ASSERT_EQUAL("Robot should be at X = 4", 4, get_current_robot_x());
	P1U_ASSERT_EQUAL("Robot should be at Y = 2", 2, get_current_robot_y());    
    P1U_ASSERT_EQUAL("Robot should be facing east", get_current_robot_orientation(), get_east());    
    P1U_ASSERT_FALSE("Robot should survive", is_robot_dead());

    p1u_shutdown();
    
    return (p1world_shutdown());
}
Example #4
0
int
main(int argc, char** argv)
{
  int i;
  int map_idx;
  int planner_idx;
  int have_map;

  pose_t robot_pose;

  gui_data_t gui_data;

  memset(&gui_data, 0, sizeof(gui_data));

  dumpfreq = 5.0;

  gui_data.initial_zoom = 1.0;
  gui_data.aa = 1;
  map_idx = 0;
  planner_idx = 0;

  if(parse_args(argc-1, argv+1, &(gui_data.num_robots), gui_data.hostnames, 
                gui_data.ports, &(gui_data.initial_zoom), &(gui_data.aa),
                &map_idx, &planner_idx) < 0)
  {
    // Input problem, print usage and exit with error
    puts(USAGE);
    exit(-1);
  }

  if (signal(SIGINT, _interrupt_callback) ==SIG_ERR)
  {
    // Couldn't register signal callback, exit with error
    exit(-1);
  }

  gui_data.mclient = init_player(gui_data.clients, 
                                        gui_data.maps, 
                                        gui_data.localizes, 
                                        gui_data.planners, 
                                        gui_data.num_robots, 
                                        gui_data.hostnames, 
                                        gui_data.ports, 
                                        DATA_FREQ,
                                        map_idx,
                                        planner_idx);
  if(! gui_data.mclient )
  {
    // Connection to Player failed, exit with error
    exit(-1);
  }

  // assume the robots all start enabled (should really get the current
  // enable/disable state for each robot from the server).
  for(i=0;i<gui_data.num_robots;i++)
    gui_data.robot_enable_states[i] = 1;

  // use the first robot for the map
  gui_data.mapdev = gui_data.maps[0];

  /* Get the map, just so we know how big to make the window */
  puts("requesting map");
  if(playerc_map_get_map(gui_data.mapdev) < 0)
  {
    have_map = 0;
    fprintf(stderr, "Failed to get map\n");
    // no map yet; guess some values to initialize the GUI
    gui_data.mapdev->width = gui_data.mapdev->height = 400;
    gui_data.mapdev->resolution = 0.1;
    gui_data.mapdev->origin[0] = -20.0;
    gui_data.mapdev->origin[1] = -20.0;
  }
  else
  {
    have_map = 1;
    puts("done");
  }

  init_gui(&gui_data, argc, argv);

  // now draw the map
  if(have_map)
    create_map_image(&gui_data);

  for(i=0;i<gui_data.num_robots;i++)
  {
    if(gui_data.localizes[i] || gui_data.planners[i])
    {
      robot_pose.px = 0.0;
      robot_pose.py = 0.0;
      robot_pose.pa = 0.0;
      create_robot(&gui_data, i, robot_pose);
    }
  }

  gtk_widget_show((GtkWidget*)(gui_data.main_window));

  // setup read function to be called when idle
  g_idle_add((GSourceFunc)player_read_func,
             (gpointer*)&gui_data);

  gtk_main();

  fini_player(gui_data.mclient,
              gui_data.clients,
              gui_data.maps,
              gui_data.localizes,
              gui_data.planners,
              gui_data.num_robots);
  fini_gui(&gui_data);

  return(0);
}