/* -*- Mode: Text -*- */ /********************************************************************\ * File: source_grid.hs * * Date: 11/28/1997 * * Author: Cem Unsal * * Robotics Institute, Carnegie-Mellon University * * unsal@ri.cmu.edu * * * * Description: * * Vehicle Source with updates for grid cell definitions. * * Adapted from Smart-AHS (ver. 0.6) file 'source.hs'. * * * * External C functions: * * * * This file is distributed under the conditions described in the * * file 'CONDITIONS' which should accompany this file. * * * * This file must also be accompanied by the file 'UCBCOPY'. * \********************************************************************/ #ifndef SAHS_SOURCE_HS #define SAHS_SOURCE_HS type Source { output number gxp; // vehicle's global x position number gyp; // vehicle's global y position number gzp; // vehicle's global z position Section section; // vehicle's section Segment segment; // vehicle's segment Lane lane; // vehicle's lane number rxp; // vehicle's road x position number ryp; // vehicle's road y position number rzp; // vehicle's road z position number lyp; // vehicle's lane y position number vgam11; // vehicle to global alignment matrix number vgam12; number vgam13; number vgam21; number vgam22; number vgam23; number vgam31; number vgam32; number vgam33; Cell scell; state number period; continuous number duration; number vehiclesToCreate; Vehicle new_av; CellCreator mycc; export newVehicle; discrete idle, start {duration' = 1;}; setup do { mycc := ccc; }; transition idle -> start {mycc:finished} // To make sure that all cells are created. define { set(Cell) candidates := {cc : cc in Cells | x(cc) <= gxp and x(cc)+cs(cc) > gxp and y(cc) <= gyp and y(cc)+cs(cc) > gyp}; } do { scell := minel c in candidates : 1; }, start -> start {newVehicle} when duration >= period and vehiclesToCreate > 0 define { Vehicle tnew_av := create(Vehicle, source := self); } do { duration := 0; vehiclesToCreate := vehiclesToCreate - 1; new_av := tnew_av; vset(scell) := vset(scell) + {tnew_av}; }; } #endif // SAHS_SOURCE_HS