robotrack.php3 5.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");

$uid = GETLOGIN();
LOGGEDINORDIE($uid);

PAGEHEADER("Real Time Robot Tracking Applet");

#
16
# Verify page arguments. Allow user to optionally specify building/floor.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#
if (isset($building) && $building != "") {
    # Sanitize for the shell.
    if (!preg_match("/^[-\w]+$/", $building)) {
	PAGEARGERROR("Invalid building argument.");
    }
    # Optional floor argument. Sanitize for the shell.
    if (isset($floor) && !preg_match("/^[-\w]+$/", $floor)) {
	PAGEARGERROR("Invalid floor argument.");
    }
}
else {
    $building = "MEB-ROBOTS";
    $floor    = 4;
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
32 33 34 35 36 37 38 39 40 41 42 43
$ppm      = 1;

#
# Grab pixel_per_meters for above map.
#
$query_result =
    DBQueryFatal("select pixels_per_meter from floorimages ".
		 "where building='$building' and floor='$floor'");
if (mysql_num_rows($query_result)) {
    $row = mysql_fetch_array($query_result);
    $ppm = $row["pixels_per_meter"];
}
44 45 46
else {
    USERERROR("No such building/floor $building/$floor", 1);
}
47

Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#
# Draw the legend and some explanatory text.
#
echo "<table cellspacing=5 cellpadding=5 border=0 class=\"stealth\">
      <tr>
       <td align=\"left\" valign=\"top\" class=\"stealth\">
         <table>
           <tr><th colspan=2>Legend</th></tr>
           <tr>
             <td><img src=\"../floormap/map_legend_node.gif\"></td>
             <td nowrap=1>Robot Actual Position</td>
           </tr>
           <tr>
             <td><img src=\"../floormap/map_legend_node_dst.gif\"></td>
             <td nowrap=1>Robot Destination Position</td>
           </tr>
         </table>
       </td>
       <td class=stealth>This applet allows you to view the robots
67 68
                         as they move around, as well as move the robots
                         with drag and drop. The table at the bottom
Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
69
                         shows the current position (x, y, orientation),
Leigh B. Stoller's avatar
Leigh B. Stoller committed
70
                         the destination position,
Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
71
                         and the battery level (percentage and voltage).
72
                         The shaded areas are <em>exclusion</em>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
73
                         zones where robots are not allowed to go. You can
74 75 76
                         <b>right click</b> on a robot to bring up its
                         info page. See below for instructions on how to
                         use the <b>drag and drop</b> features.
Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
77 78 79 80
        </td>
      </tr>
      </table><hr>\n";

81 82 83 84 85 86 87 88 89 90 91 92 93 94
#
# Create a tempfile to use as a unique prefix; it is not actually used but
# serves the same purpose (The script uses ${prefix}.jpg and ${prefix}.map .)
# 
$prefix = tempnam("/tmp", "floormap");

#
# Get the unique part to send back.
#
if (!preg_match("/^\/tmp\/([-\w]+)$/", $prefix, $matches)) {
    TBERROR("Bad tempnam: $prefix", 1);
}
$uniqueid = $matches[1];

95
$perl_args = "-o $prefix -t -z -n -x -v -y -f $floor $building";
96 97 98 99 100 101 102 103 104 105 106

$retval = SUEXEC($uid, "nobody", "webfloormap $perl_args",
		 SUEXEC_ACTION_IGNORE);

if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    # Never returns.
    die("");
}

$auth    = $HTTP_COOKIE_VARS[$TBAUTHCOOKIE];
107
$pipeurl = "robopipe.php3?building=$building&floor=$floor";
108 109 110
$baseurl = "../floormap_aux.php3?prefix=$uniqueid";

# Temp for debugging.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
111 112
if (isset($fake))
     $pipeurl .= "&fake=yes";
113
     
114
echo "<applet name='tracker' code='RoboTrack.class'
115
              archive='tracker.jar'
116
              width='1025' height='1150'
117 118
              alt='You need java to run this applet'>
            <param name='pipeurl' value='$pipeurl'>
119
            <param name='floorurl' value='$baseurl'>
120 121
            <param name='uid' value='$uid'>
            <param name='auth' value='$auth'>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
122
            <param name='ppm' value='$ppm'>
123 124
            <param name='building' value='$building'>
            <param name='floor' value='$floor'>
125 126
          </applet>\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
127
echo "<br>
128
     <blockquote><blockquote>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
129 130
     <center>
     <h3>Using the Robot Tracker Applet</h3>
131
     </center>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
132 133 134 135 136 137 138 139
     <ul>
     <li> Right Click over a robot or mote will pop up a browser window 
          showing information about the robot/mote.
     <li> Left click and drag over a (stationary) robot allows you to setup a
          move to a new position. Remember to edit the orientation in the
          table, if needed. Cancel by moving back to its original position. 
     <li> Left click over the background image brings up a menu to submit your 
          moves (start the robots on their way), or cancel the moves.
140 141
     <li> Only one move per robot at a time.
     <li> To change just the orientation (no drag), edit the destination
142 143 144
          orientation column in the table.
     <li> A robot destination must not overlap an obstacle (shaded area,
          blue border), and it must be fully within the field of view of at
145 146 147 148
          least one camera (orange boxes).
     <li> A robot destination must not overlap with another robot (its final
          destination). Because of the sensors on the robots, the closest a
          robot can come to anything else is 23cm.
149 150
     </ul>
     <blockquote><blockquote>\n";
151

152 153
PAGEFOOTER();
?>