pathPlanning.h 3.16 KB
Newer Older
1 2
/*
 * Copyright (c) 2005 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
 */

#ifndef _rmcd_path_planning_h
#define _rmcd_path_planning_h

/**
 * @file pathPlanning.h
 *
 * Module focused solely on plotting paths for the robots.  Locating and moving
 * the robot is handled by the master controller.
 */

#include "listNode.h"
#include "mtp.h"

#define PP_MIN_OBSTACLE_CROSS 0.20f

/**
 * Return codes for pp_plot_waypoint.
 */
typedef enum {
    PPC_NO_WAYPOINT,		/*< No obstructions, clear to move. */
    PPC_WAYPOINT,		/*< Path obstructed, need to move around. */
    PPC_BLOCKED,		/*< Path completely blocked, try later. */
    PPC_GOAL_IN_OBSTACLE,	/*< Goal is inside an obstacle. */
} pp_plot_code_t;

typedef enum {
    PPT_CORNERPOINT,
    PPT_DETACHED,
    PPT_INTERNAL,
    PPT_OUTOFBOUNDS,
} pp_point_type_t;

enum {
    PPB_HAS_OBSTACLE,
};

enum {
    PPF_HAS_OBSTACLE = (1L << PPB_HAS_OBSTACLE),
};

/**
 * The path plan for a single robot.  The caller of this module is expected to
 * fill out pp_robot, pp_actual_pos, pp_goal_pos, and pp_speed with their
 * desired values.  This module will then take care of plotting a path around
 * any obstacles.
 */
struct path_plan {
    struct lnMinNode pp_link;		 /*< List node header. (unused) */
    unsigned long pp_flags;		 /*< Holds the PPF flags. */
    struct robot_config *pp_robot;	 /*< The robot this plan is for. */
    struct robot_position pp_actual_pos; /*< Current position. */
    struct robot_position pp_waypoint;	 /*< Current waypoint. */
    struct robot_position pp_goal_pos;	 /*< Current goal. */
    struct obstacle_config pp_obstacle;	 /*< First obstacle in the path. */
    float pp_speed;			 /*< Last set speed for the robot. */
};

/**
 * Plot a new waypoint for the given path.
 *
 * @param pp An initialize path object.
 * @return A code that indicates what action to take to reach the goal.
 */
pp_plot_code_t pp_plot_waypoint(struct path_plan *pp);

/**
 * Global data needed for path planning.
 */
struct path_planning_data {
    /**
     * Array of camera bounds for the area.
     */
    struct box *ppd_bounds;

    /**
     * The length of the ppd_bounds array.
     */
    unsigned int ppd_bounds_len;
    
    /**
     * The maximum distance allowed for a line segment.  XXX This is a hack to
     * keep the robot from going too far off course because of a bad angle from
     * vision and such.
     */
    float ppd_max_distance;
};

extern struct path_planning_data pp_data;

#endif