/* -*- Mode: Text -*-* */ /********************************************************************\ * File: cell.hs * * Date: 11/28/1997 * * Author: Cem Unsal * * Robotics Institute, Carnegie-Mellon University * * unsal@ri.cmu.edu * * * * Description: * * The cells, rectangular regions in global space, form a grid to be * * used in sensor measurements in conjuction with the sensor * * environment processor (type SEP). See documentation for details. * * * * Cell generation is not automated; the locations and the adjoint * * cell definitions must be defined carefully. (See grid*.hs for * * examples. * * * * External C functions: * * * * This file is distributed under the conditions described in the * * file 'CONDITIONS' which should accompany this file. * \********************************************************************/ #ifndef SAHS_CELL_HS #define SAHS_CELL_HS type Cell { output number x, y; // Coord. of the upper-left corner number cs; // Cell size set(Vehicle) vset; // Set of vehicles set(Vehicle) lvset; // Set of leaving vehicles Vehicle leavingvehicle; // Current "leaving" vehicle set(Cell) NC; // Set of neighbor cells Cell last_neig_proc; // Last neighbor interaction // (for debugging) state continuous number t; // Time number T; // Update frequency setup do { t := 0; T := 1; }; export checking, vehicle_leaving, create_neig; discrete run, update; flow default { t' = 1;}; transition run -> update {checking} // See if any of the vehicles is leaving when t >= T define { set(Vehicle) tempset := {bb : bb in vset | gxp(bb) >= x+cs or gxp(bb) < x or gyp(bb) >= y+cs or gyp(bb) < y}; } do { lvset := tempset; leavingvehicle := if size(tempset) = 0 then nil else minel bbb in tempset : gxp(bbb); }, update -> run {} // If the size of the set of leaving vehicles is zero, or // all leaving vehicles are declared, wait for the next check time when size(lvset) = 0 do { t := 0; }, update -> update {vehicle_leaving} // If there is at least one vehicle leaving, // declare that and move to the next vehicle when size(lvset) > 0 define { Vehicle lvveh := leavingvehicle; } do { lvset := lvset - {lvveh}; vset := vset - {lvveh}; leavingvehicle := if size(lvset) = 0 then nil else minel bbb in lvset : gxp(bbb); }, run -> run {NC:vehicle_leaving(one:cc)} // If one of the neighbor cells indicate a leaving vehicle, // check to see if it entered your region define { set(Vehicle) enteringvehicle := {bb : bb in lvset(cc) | gxp(bb) >= x and gxp(bb) < x+cs and gyp(bb) >= y and gyp(bb) < y+cs}; } do { last_neig_proc := cc; vset := vset + enteringvehicle; }; } #endif // SAHS_CELL_HS