/* -*- Mode: Text -*-* */ /********************************************************************\ * File: 3section.hs * * Date: 07/21/1997 * * Author: Cem Unsal * * Robotics Institute, Carnegie-Mellon University * * unsal@ri.cmu.edu * * * * Description: * * Straight highway with 3 sections, each with 3 segments and 3 * * lanes. * * For detailed description, see the code. * * * * sec1 sec2 sec3 lnL * * |-----+-----+-----|-----+-----+-----|-----+-----+-----|_/ lnM * * |-----+-----+-----|-----+-----+-----|-----+-----+-----|__/ lnR * * |-----+-----+-----|-----+-----+-----|-----+-----+-----|___/ * * |-----+-----+-----|-----+-----+-----|-----+-----+-----| x=1,2,3 * * seg11 seg12 seg13 seg21 seg22 seg23 seg31 seg32 seg33 * * * * 3 sources at the beginning of seg11. * * * * External C functions: eucdist * * * * This file is distributed under the conditions described in the * * file 'CONDITIONS' which should accompany this file. * \********************************************************************/ #include #include #include #define lw 4 // lane width #define sl 100 // segment length #define pi 3.1415927 #define initiallanedev 0.5 global Lane ln1L, ln1M, ln1R, ln2L, ln2M, ln2R, ln3L, ln3M, ln3R; global Segment seg11, seg12, seg13, seg21, seg22, seg23, seg31, seg32, seg33; global Section sec1, sec2, sec3; global HighwayBuilder hwy := create(HighwayBuilder); global Source source1 := create(Source, gxp := 0, gyp := 0.5*lw+initiallanedev, gzp :=0, section := sec1, lane := ln1L, segment := seg11, rxp := 0, ryp := 0.5*lw+initiallanedev, rzp := 0, lyp := initiallanedev, vgam11 := 1, vgam12 := 0, vgam13 := 0, vgam21 := 0, vgam22 := -1, vgam23 := 0, vgam31 := 0, vgam32 := 0, vgam33 := 1, vehiclesToCreate := 2, duration := 0, period := 1); global Source source2 := create(Source, gxp := 0, gyp := 1.5*lw-1, gzp :=0, section := sec1, lane := ln1M, segment := seg11, rxp := 0, ryp := 1.5*lw-1, rzp := 0, lyp := -1, vgam11 := 1, vgam12 := 0, vgam13 := 0, vgam21 := 0, vgam22 := -1, vgam23 := 0, vgam31 := 0, vgam32 := 0, vgam33 := 1, vehiclesToCreate := 2, duration := 0, period := 1.5); global Source source3 := create(Source, gxp := 0, gyp := 2.5*lw+1.3, gzp :=0, section := sec1, lane := ln1R, segment := seg11, rxp := 0, ryp := 2.5*lw+1.3, rzp := 0, lyp := 1.3, vgam11 := 1, vgam12 := 0, vgam13 := 0, vgam21 := 0, vgam22 := -1, vgam23 := 0, vgam31 := 0, vgam32 := 0, vgam33 := 1, vehiclesToCreate := 2, duration := 0, period := 1.8); type HighwayBuilder { setup define { /* segments */ /* 1st section */ Segment tseg11 := create(Segment, length := sl, xOffset := 0, gxa := 0, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg12 := create(Segment, length := sl, xOffset := sl, gxa := sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg13 := create(Segment, length := sl, xOffset := 2*sl, gxa := 2*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); /* 2nd section */ Segment tseg21 := create(Segment, length := sl, xOffset := 0, gxa := 3*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg22 := create(Segment, length := sl, xOffset := sl, gxa := 4*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg23 := create(Segment, length := sl, xOffset := 2*sl, gxa := 5*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); /* 3rd section */ Segment tseg31 := create(Segment, length := sl, xOffset := 0, gxa := 6*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg32 := create(Segment, length := sl, xOffset := sl, gxa := 7*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); Segment tseg33 := create(Segment, length := sl, xOffset := 2*sl, gxa := 8*sl, gya := 0, gza := 0, orientation := 0, curvature := 0, grade := 0, banking := 0, skid := 0); /* lanes */ Lane tln1L := create(Lane, width := lw, yOffset := 0); Lane tln1M := create(Lane, width := lw, yOffset := lw); Lane tln1R := create(Lane, width := lw, yOffset := 2*lw); Lane tln2L := create(Lane, width := lw, yOffset := 0); Lane tln2M := create(Lane, width := lw, yOffset := lw); Lane tln2R := create(Lane, width := lw, yOffset := 2*lw); Lane tln3L := create(Lane, width := lw, yOffset := 0); Lane tln3M := create(Lane, width := lw, yOffset := lw); Lane tln3R := create(Lane, width := lw, yOffset := 2*lw); /* sections */ Section tsec1 := create(Section, width := 3*lw, length := 3*sl, previousYOffsets := [0]); Section tsec2 := create(Section, width := 3*lw, length := 3*sl, previousYOffsets := [0]); Section tsec3 := create(Section, width := 3*lw, length := 3* sl, previousYOffsets := [0]); /* weather */ Weather tweather := create (Weather, visibility := 100, precipitation := 0); } do { /* lanes */ ln1L := tln1L; ln2L := tln2L; ln3L := tln3L; ln1M := tln1M; ln2M := tln2M; ln3M := tln3M; ln1R := tln1R; ln2R := tln2R; ln3R := tln3R; /* sections */ sec1 := tsec1; sec2 := tsec2; sec3 := tsec3; /* segments */ seg11 := tseg11; seg12 := tseg12; seg13 := tseg13; seg21 := tseg21; seg22 := tseg22; seg23 := tseg23; seg31 := tseg31; seg32 := tseg32; seg33 := tseg33; /* additional definitions - connections */ /* lanes and segment arrays for sections */ lanes(tsec1) := [tln1L, tln1M, tln1R]; lanes(tsec2) := [tln2L, tln2M, tln2R]; lanes(tsec3) := [tln3L, tln3M, tln3R]; segments(tsec1) := [tseg11, tseg12, tseg13]; segments(tsec2) := [tseg21, tseg22, tseg23]; segments(tsec3) := [tseg31, tseg32, tseg33]; /* section arrays for lanes */ section(tln1L):= tsec1; section(tln1M):= tsec1; section(tln1R):= tsec1; section(tln2L):= tsec2; section(tln2M):= tsec2; section(tln2R):= tsec2; section(tln3L):= tsec3; section(tln3M):= tsec3; section(tln3R):= tsec3; /* up-down lane connections for lanes */ laneDown(tln1L) := [tln2L]; laneDown(tln1M) := [tln2M]; laneDown(tln1R) := [tln2R]; laneDown(tln2L) := [tln3L]; laneDown(tln2M) := [tln3M]; laneDown(tln2R) := [tln3R]; laneDown(tln3L) := []; laneDown(tln3M) := []; laneDown(tln3R) := []; /* */ laneUp(tln1L) := []; laneUp(tln1M) := []; laneUp(tln1R) := []; laneUp(tln2L) := [tln1L]; laneUp(tln2M) := [tln1M]; laneUp(tln2R) := [tln1R]; laneUp(tln3L) := [tln2L]; laneUp(tln3M) := [tln2M]; laneUp(tln3R) := [tln2R]; /* up-down section definitions for sections */ sectionUp(tsec1) := []; sectionDown(tsec1) := [tsec2]; sectionUp(tsec2) := [tsec1]; sectionDown(tsec2) := [tsec3]; sectionUp(tsec3) := [tsec2]; sectionDown(tsec3) := []; /* left-right lane connections for lanes */ laneRight(tln1L):=tln1M; laneRight(tln1M):=tln1R; laneRight(tln1R):=nil; laneLeft(tln1L):=nil; laneLeft(tln1M):=tln1L; laneLeft(tln1R):=tln1M; laneRight(tln2L):=tln2M; laneRight(tln2M):=tln2R; laneRight(tln2R):=nil; laneLeft(tln2L):=nil; laneLeft(tln2M):=tln2L; laneLeft(tln2R):=tln2M; laneRight(tln3L):=tln3M; laneRight(tln3M):=tln3R; laneRight(tln3R):=nil; laneLeft(tln3L):=nil; laneLeft(tln3M):=tln3L; laneLeft(tln3R):=tln3M; /* section definitions for segment */ section(tseg11) := tsec1; section(tseg12) := tsec1; section(tseg13) := tsec1; section(tseg21) := tsec2; section(tseg22) := tsec2; section(tseg23) := tsec2; section(tseg31) := tsec3; section(tseg32) := tsec3; section(tseg33) := tsec3; /* up-down segment connections */ upSegment(tseg11) := nil; downSegment(tseg11) := tseg12; upSegment(tseg12) := tseg11; downSegment(tseg12) := tseg13; upSegment(tseg13) := tseg12; downSegment(tseg13) := nil; upSegment(tseg21) := nil; downSegment(tseg21) := tseg22; upSegment(tseg22) := tseg21; downSegment(tseg22) := tseg23; upSegment(tseg23) := tseg22; downSegment(tseg23) := nil; upSegment(tseg31) := nil; downSegment(tseg31) := tseg32; upSegment(tseg32) := tseg31; downSegment(tseg32) := tseg33; upSegment(tseg33) := tseg32; downSegment(tseg33) := nil; /* weather definitions for segments */ weather(tseg11) := tweather; weather(tseg12) := tweather; weather(tseg13) := tweather; weather(tseg21) := tweather; weather(tseg22) := tweather; weather(tseg23) := tweather; weather(tseg31) := tweather; weather(tseg32) := tweather; weather(tseg33) := tweather; }; }