Commit eda7add2 authored by Leigh Stoller's avatar Leigh Stoller

Add "obstacles" for robots to avoid.

* New database table to store obstacles, in the usual coord system;
  x1,y1, is the upper left corner.

* New web page to dump the entire obstacle list

	https://www.emulab.net/obstacle_list.php3

* New web page to dump a single obstacle, referenced by the above list
  page, and by the floormap generator.

* Hack up the floormap code to add obstacles to the areamap, so that
  when you mouse over them, you get a ballon showing the description,
  and a link to the above mentioned page.
parent 4b1c6cb3
......@@ -1162,6 +1162,24 @@ CREATE TABLE ntpinfo (
PRIMARY KEY (node_id,IP,type)
) TYPE=MyISAM;
--
-- Table structure for table `obstacles`
--
CREATE TABLE obstacles (
obstacle_id int(11) unsigned NOT NULL auto_increment,
floor varchar(32) default NULL,
building varchar(32) default NULL,
x1 int(10) unsigned NOT NULL default '0',
y1 int(10) unsigned NOT NULL default '0',
z1 int(10) unsigned NOT NULL default '0',
x2 int(10) unsigned NOT NULL default '0',
y2 int(10) unsigned NOT NULL default '0',
z2 int(10) unsigned NOT NULL default '0',
description tinytext,
PRIMARY KEY (obstacle_id)
) TYPE=MyISAM;
--
-- Table structure for table `os_info`
--
......
......@@ -2274,6 +2274,18 @@ last_net_act,last_cpu_act,last_ext_act);
PRIMARY KEY (id)
) TYPE=MyISAM;
1.298: Add obstacles table for the robots.
CREATE TABLE obstacles (
obstacle_id int(11) unsigned NOT NULL auto_increment,
floor varchar(32) default NULL,
building varchar(32) default NULL,
x1 int(10) unsigned NOT NULL default '0',
y1 int(10) unsigned NOT NULL default '0',
z1 int(10) unsigned NOT NULL default '0',
x2 int(10) unsigned NOT NULL default '0',
y2 int(10) unsigned NOT NULL default '0',
z2 int(10) unsigned NOT NULL default '0',
description tinytext,
PRIMARY KEY (obstacle_id)
) TYPE=MyISAM;
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -454,6 +454,7 @@ sub dofloor($$)
(defined($pid) ? " and r.pid='$pid' and r.eid='$eid'" : "");
my $query_result = DBQueryFatal($query . " and loc.floor='$floor'");
my $newnodes_query = "select * from new_nodes ".
"where building='$building'";
my $newnodes_result = DBQueryFatal($newnodes_query . " and floor='$floor'");
......@@ -689,6 +690,31 @@ sub dofloor($$)
# Have to adjust the maps cause we just moved everything.
adjustmap($areamap, 0, $head_height);
}
#
# Stick in obstacles, if any.
#
my $obstacles_result =
DBQueryFatal("select * from obstacles ".
"where floor='$floor' and building='$building'");
while (my %obrow = $obstacles_result->fetchhash()) {
my $id = $obrow{"obstacle_id"};
my $x1 = $obrow{"x1"};
my $x2 = $obrow{"x2"};
my $y1 = $obrow{"y1"};
my $y2 = $obrow{"y2"};
my $descr = $obrow{"description"};
my $props = {};
$props->{"X1"} = $x1;
$props->{"Y1"} = $y1;
$props->{"X2"} = $x2;
$props->{"Y2"} = $y2;
$props->{"DESCR"} = $descr;
$props->{"ISOBS"} = 1;
$areamap->{"$id"} = $props;
}
return ($baseimage, $areamap);
}
......@@ -809,11 +835,15 @@ sub writefiles($@)
my $y1 = $map{$nodeid}->{"Y1"};
my $x2 = $map{$nodeid}->{"X2"};
my $y2 = $map{$nodeid}->{"Y2"};
my $isobs = $map{$nodeid}->{"ISOBS"};
my $descr = $map{$nodeid}->{"DESCR"};
my $isnew = $map{$nodeid}->{"ISNEW"};
my $link = ($isnew ?
"newnode_edit.php3?id=${isnew}" :
"shownode.php3?node_id=${nodeid}");
my $title = $nodeid;
my $link = ($isobs ?
"showobstacle.php3?id=${nodeid}" :
($isnew ?
"newnode_edit.php3?id=${isnew}" :
"shownode.php3?node_id=${nodeid}"));
my $title = ($isobs ? $descr : $nodeid);
$title .= " (vname=" . $map{$nodeid}->{'VNAME'} . ")"
if (exists($map{$nodeid}->{'VNAME'}));
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Obstacle List");
#
#
# Only known and logged in users allowed.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Spit out all the obstacles. At some point this page should take
# optional building/floor params.
#
$query_result =
DBQueryFatal("select o.*,f.pixels_per_meter from obstacles as o ".
"left join floorimages as f on f.floor=o.floor and ".
" f.building=o.building and f.scale=1 ".
"order by o.obstacle_id");
if (!mysql_num_rows($query_result)) {
USERERROR("There are no obstacles!", 1);
}
$count = mysql_num_rows($query_result);
echo "<center>
There are $count obstacles.
</center><br>\n";
echo "<table width=\"100%\" border=2 cellpadding=1 cellspacing=2
align='center'>\n";
echo "<tr>
<th rowspan=2>ID</th>
<th>X1</th>
<th>Y1</th>
<th>Z1</th>
<th align=center rowspan=2>Description</th>
</tr>
<tr>
<th>X2</th>
<th>Y2</th>
<th>Z2</th>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$id = $row["obstacle_id"];
$x1 = $row["x1"];
$x2 = $row["x2"];
$y1 = $row["y1"];
$y2 = $row["y2"];
$z1 = $row["z1"];
$z2 = $row["z2"];
$desc = $row["description"];
$ppm = $row["pixels_per_meter"];
if (isset($ppm) && $ppm != 0.0) {
$x1 = sprintf("%.3f", $x1 / $ppm);
$x2 = sprintf("%.3f", $x2 / $ppm);
$y1 = sprintf("%.3f", $y1 / $ppm);
$y2 = sprintf("%.3f", $y2 / $ppm);
$z1 = sprintf("%.3f", $z1 / $ppm);
$z2 = sprintf("%.3f", $z2 / $ppm);
}
echo "<tr>
<td rowspan=2><a href=showobstacle.php3?id=$id>$id</a></td>
<td>$x1</td>
<td>$y1</td>
<td>$z1</td>
<td rowspan=2>$desc</td>
</tr>
<tr>
<td>$x2</td>
<td>$y2</td>
<td>$z2</td>
</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Obstacle Information");
#
#
# Only known and logged in users allowed.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($id) ||
strcmp($id, "") == 0) {
USERERROR("You must provide an Obstacle ID!", 1);
}
# Sanitize.
if (!preg_match("/^[\d]+$/", $id)) {
PAGEARGERROR("Invalid characters in arguments.");
}
$query_result =
DBQueryFatal("select o.*,f.pixels_per_meter from obstacles as o ".
"left join floorimages as f on f.floor=o.floor and ".
" f.building=o.building and f.scale=1 ".
"where o.obstacle_id='$id'");
if (!mysql_num_rows($query_result)) {
USERERROR("There is no such obstacle!", 1);
}
echo "<font size=+2>".
"Obstacle <b>$id</b>".
"</font>\n";
echo "<table border=2 cellpadding=0 cellspacing=2
align=center>\n";
echo "<table width=\"100%\" border=2 cellpadding=1 cellspacing=2
align='center'>\n";
echo "<tr>
<th rowspan=2>ID</th>
<th>X1</th>
<th>Y1</th>
<th>Z1</th>
<th align=center rowspan=2>Description</th>
</tr>
<tr>
<th>X2</th>
<th>Y2</th>
<th>Z2</th>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$x1 = $row["x1"];
$x2 = $row["x2"];
$y1 = $row["y1"];
$y2 = $row["y2"];
$z1 = $row["z1"];
$z2 = $row["z2"];
$desc = $row["description"];
$ppm = $row["pixels_per_meter"];
if (isset($ppm) && $ppm != 0.0) {
$x1 = sprintf("%.3f", $x1 / $ppm);
$x2 = sprintf("%.3f", $x2 / $ppm);
$y1 = sprintf("%.3f", $y1 / $ppm);
$y2 = sprintf("%.3f", $y2 / $ppm);
$z1 = sprintf("%.3f", $z1 / $ppm);
$z2 = sprintf("%.3f", $z2 / $ppm);
}
echo "<tr>
<td rowspan=2>$id</td>
<td>$x1</td>
<td>$y1</td>
<td>$z1</td>
<td rowspan=2>$desc</td>
</tr>
<tr>
<td>$x2</td>
<td>$y2</td>
<td>$z2</td>
</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment