Marco Antoniotti
California PATH, UC Berkeley
September 1997
SmartAHS is a specification, simulation and evaluation framework for modeling, control and evolution of Automated Highway Systems (AHS). SmartAHS is developed using SHIFT, a new programming language with simulation semantics.
This document is an aid to all the users of the California PATH Workstation Network at Richmond Field Station (RFS). I.e. if you have an account on the local network at RFS. If you do not have an account on the network you can stop reading this document.
The document will start out with some conventions and will tell you how to reorganize your projects and to take advantage of the new SHIFT features and of the new SmartAHS organization.
Throughout this document we use the following conventions. Text formatted in typewriter font indicates code. Text formatted in bold typewriter font is input that must be typed in in order to obtain a response from the system. Text typed in italicized typewriter font indicates the output of the system in response to your commands.
Before the SmartAHS Libraries reorganization, you would download (i.e. check out with prcs) a full distribution of the distribution and you would create, modify, and run your project. In the new setup, the main library is decoupled from the single projects and it is installed system-wide. Therefore, you do not need to see the exact code of the main library.
You would proceed in the following way.
The projects repository currently contains the following projects.
These projects are now decoupled from the SMART-AHS-LIB project, which contains the overall SmartAHS Library code and which is also installed system wide in the standard /usr/path/lib/smart-ahs-lib location.
In order to restructure your project, you will need to refer to the overall SmartAHS Library documentation. However, here are some quick instructions about how to proceed.
Suppose that you are working on the platooning project. You wound create a new directory - say sahs-platoon-prj - and in it you would issue the command
your-prompt> prcs checkout SAHS-PLATOON-PRJ
This will create a project file which will be filled later on. The first piece that you will need is an highway layout. You can create one by writing something along the lines of the example hereafter, or you can modify your current layout according to these suggestions.
#ifndef SAHS_PLATOON_HWAY_HS
#define SAHS_PLATOON_HWAY_HS
#include <smart-ahs/roadways/highways.hs>
type highway_builder
{
output Lane lane_1;
Segment seg_1;
Section sec_1;
...
}
#endif // SAHS_PLATOON_HWAY_HS
The first thing to notice is the #include statement. The architecture of the SmartAHS Libraries is hierarchical. All the library code pertaining highways is in the subdirectory roadways of the main SmartAHS Libraries. All SmartAHS components can be found int the <smart-ahs/...> subdirectories and #included when needed. Once again we refer to the SmartAHS Library document for an in-depth description of all the basic types and their relationships with each other.
The biggest part of the work will deal with renaming some of the types that have been used in the past. The following table lists the major changes that will have to be made.
| Pre 1.x Type Name | 1.x Type Name(s) |
|---|---|
| Vehicle |
VehicleDynamics_2D VehicleDynamics3D k_vehicle_dynamics |
| AutomatedVehicle | Vehicle |
| Controller |
|
Other changes regard other types like Sources and Sinks.
Because of the contraints of inheritance with strongly typed languages like SHIFT, there are some problems with the "plug-ing" policy of certain components.
Suppose we have a subclass of type Controller as
type Vehicle_Platoon_Controller : Controller { ... }
Using the SmartAHS Libraries with version 1.x you cannot just plug in the instance of the desired type in the inherited instance variable like in
Controller c := create(Vehicle_Platoon_Controller);
The workaround is to declare a new variable of the correct controller type
output Vehicle_Platoon_Controller vpc;
setup
do {
c := create(Vehicle_Platoon_Controller, ...);
};
...
flow {
default { vpc = narrow(Vehicle_Platoon_Controller, c); };
...
Finally, you can compile the simulation. SUppose you have a top level file called platoon-sim.hs. As you can imagine, it will be necessary to access the right top-level directory mentioned in the #include statements. All of this is now taken care of in a script called csmartahs. At the prompt you will type
your-prompt> csmartahs platoon-sim.hs
This will call the SHIFT compiler as well as the C one, and produce the executable simulation. The csmartahs script is installed in /usr/path/bin along with cshift and shic. All the necessary library dependencies (mostly in the form of -I and -L options to cshift and therefore to the C compiler) are incorporated directly in the script.
You can still write specialized C functions and link them in the simulation in the following way. Suppose your C file is called special-prj-fns.c. In order to compile and link the object file you will write
your-prompt> csmartahs platoon-sim.hs -ff special-prj-fns.c
The resulting platoon-sim.sim will load the proper function objects from the special-prj-fns.o file.
We hope that these directions will help you in the transition to SmartAHS 1.x. If you have problems, send an email to smart-ahs@path.berkeley.edu.
As a summary, remeber: