Difference between revisions of "WCPS: Wireless Cyber-Physical Simulator"
Line 156: | Line 156: | ||
* "TestNetworkC.nc" Implements send/receive functionality of a wireless node. | * "TestNetworkC.nc" Implements send/receive functionality of a wireless node. | ||
* "tossim-call.py" configures TOSSIM network and does packet injection into the Tossim network. | * "tossim-call.py" configures TOSSIM network and does packet injection into the Tossim network. | ||
− | * Wireless traces | + | * Wireless traces: [http://research.engineering.wustl.edu/~boli/downloads/building_noise_n_rssi.zip Traces for 5-sensor wireless network in a building]. |
− | |||
==== A simple Simulink Model ==== | ==== A simple Simulink Model ==== |
Revision as of 19:09, 14 March 2013
End-user's Tutorial on using WCPS: The Wireless Cyber-Physical Simulator
WCPS is design for, but not limited to, realistic Wireless Structural Control simulations. The efficient integration of Simulink and TOSSIM has made WCPS an ideal choice for realistic wireless control simulations. The following tutorial introduces how to install and configure MATLAB, TinyOS, and PYTHON environments, as well as the WCPS framework. The tutorial herein is specifically organized for end-users who do not do much development but instead trying to do wireless control simulations with Simulink and TOSSIM. A more advanced tutorial for developers can be found [here].
Contents
Change Log
- Release: March 10, 2013, WCPS v0.1.1 and the four cases studies for the ICCPS'13 paper was released.
- Tutorial: March 09, 2013, WSC Examples from a structural perspective.
WCPS Principle
As shown in the architecture illustrated in the right figure, WCPS simulates the feedback control loop of the control system as follows. Sensor data is generated from structural models. Through a cross-platform function call from Simulink, sensor data is injected to the corresponding wireless sensors in TOSSIM. Following the routes and transmission schedule calculated by the network manager module, TOSSIM simulates the end-to-end wireless communication of the sensor data packets from the sensors to the base station, and then return the packet delay and loss to the Interfacing Block in Simulink through the Python interface. The Packet Collector module then to extracts packet delivery information(the delay and loss)from the message pool of returned values in Simulink. Sensor data and their loss and delay are then provided to the Data Block, which then feed the sensor data to the controller at the right time based on the packet delay (if the packet is not lost). WCPS utilizes basic API (e.g., the dos, UNIX command) of MATLAB to do cross-platform function calls. In TOSSIM, we re-implement a printf method in TinyOS to send TOSSIM simulation results to the Interfacing Block.
User inputs to WCPS includes excitation signals to the structure (e.g., acceleration caused by earthquakes) and wireless traces used as input to TOSSIM. Excitation signal of the structure is provided to the structure models in the format of MAT files. The scheduler module calculates transmission schedules. Networking schedule is then deployed into the MAC layer code of wireless nodes and becomes effective after a TinyOS compilation. The TDMA MAC layer in WCPS is developed based on the MAC Layer Architecture (MLA) library and further adapted for TOSSIM under TinyOS 2.1.1. Received Signal Strength Indication( RSSI) and wireless noises traces are collected from real-world environments and provided to the wireless model used by TOSSIM for realistic wireless network simulations. The interfaces between the Simulink model and TOSSIM are encapsulated as two MATLAB embedded functions in Simulink: the Interfacing Block and the Data Block. The Interfacing Block extracts delay and loss information from TOSSIM messages, and the Data Block decides what data will be used for discrete control during each sampling period. The federated architecture of WCPS provides great flexibilities to incorporate different structural models and implement alternative scheduling-control approaches.
Capability of WCPS
WCPS supports extensive 802.15.4 wireless network simulation. Fig. 1 shows the end-to-end packet delivery ratio of the wireless network. The end-to-end delivery ratio means the fraction of packets from the sensors that are successfully delivered to the controller. As shown in Fig. 1 Sensor 1 has the lowest delivery ratio because it has a 2-hop route to the controller. Recall that OTDC-1 does not perform any retransmission, while OTDC-2 and OTDC-3 performs retransmit each packet once and twice, respectively. Under OTDC-1 Sensors 1 and 4 have delivery ratios of 70% and over 95%, respectively. As expected more retransmissions improve the deliver ratios of all sensors at the cost of longer delays as described earlier.
Efficient integration of TOSSIM and Simulink also enables in-depth tradeoff of data synchronization, network reliability and network delays, as shown in Fig.2 and Fig.3. Fig. 2 shows the resource requirement of different control approaches. OTDC-k approaches (see Fig. 2(a)) consistently require less control power than SC. As k increases, OTDC-k requires slightly less control power. Similarly, as shown in Fig. 2(b), OTDC-1 reduces control force by 80% when compared to SC. The differences in control force among different OTDC-k approaches are negligible. The results that OTDC-1 outperforms SC in both metrics indicate resource requirements are more sensitive to data synchronization than to sensing delays in this building control system. OTDC-k with larger k results in negligible reduction of control power and force, indicating resource requirements are not sensitive to network reliability in this case study. The control performance regarding structural response is shown in Fig. 3. In term of peak inter-story drift in Fig. 3(a), OTDC- k achieves more reduction in inter-story drift than SC. Interestingly, higher k in OTDC-k increases peak inter-story drift. Recall a higher k leads to higher communication reliability but longer sensing delay. Inter-story drift is thus more sensitive to sensing delays than to data loss in this case study. Similarly, as shown in Fig. 3(b), OTDC-3 causes worse peak acceleration than all the other approaches. Hence, building structural responses are more sensitive to sensing delays than to data loss. In addition, OTDC- 1 only slightly outperforms SC, which indicates limited impact of data synchronization on structural response.
WCPS integrates a high-fidelity wireless simulator (TOSSIM) and a standard control system simulator (Simulink). With WCPS,and shows that there exist complex tradeoffs among data synchronization, sensing delay, and network reliability under realistic wireless structural control settings. A realistic, integrated wireless control simulator like WCPS is critical in exploring the design tradeoffs in wireless control design. Finally, a control-scheduling co-design approach is effective in wireless control design. In both case studies the integration of a contant-delay control design and a scheduling scheme achieving data synchronization lead to substantial improvement in control performance when compared to a traditional control design. Our cyber-physical simulation methodology and scheduling-control co-design approaches presented in this work not only represent a promising step toward smart civil infrastructure, but also provide useful insights and tools that can be generalized to other cyber-physical systems employing wireless control.
Live Example
Installation
Install TinyOS
WCPS is implemented and tested on MacOS X (snowleopard), Windows XP, and Windows 7. Current release of WCPS is under TinyOS 2.1.1, which can be installed following the two methods.
- Follow the TinyOS official tutorial on installation of TinyOS for your specific platform: Link
- Directly download the pre-tested TinyOS 2.1.1 image from here: TinyOS2.1.1 for SnowLeopard(and possibly later versions) [Cygwin package coming soon.]
Install Mac Layer Architecture(MLA)
The MAC Layer Architecture (MLA) provides a component-based architecture for MAC protocols in wireless sensor networks. MLA extends the Unified Power Management Architecture to provide the hardware-independent interfaces required by timing sensitive MAC protocols, and defines platform-independent reusable components that implement MAC layer logic on top of them. The MLA architecture can be used to develop a large number of platform-independent MAC implementations, with little or no further effort required to adapt these implementations to new hardware platforms. Our current implementation of MLA is built on top of TinyOS 2.1.1. It currently supports platforms which use the CC2420 radio stack and has been tested on TelosB motes. In addition to providing interfaces and components for building new MAC layer implementations, MLA includes implementations of five representative MAC layers:
- Follow the instructions here: Install MLA.
Install MATLAB and Simulink
If you already have MATLAB MATLAB 7.11.0.584 (2010b) or later version, skip this step. Otherwise, follow the tutorial here: install MATLAB
Install Python
If you already have Python 2.7.2 or later version installed, skip this step. Otherwise, follow the manual here: install Python
A Simple Example with WCPS
Simulate a TDMA wireless network
Wireless network as the communication media of a close-loop control system plays a critical role. Sitting on top of WCPS, simulating a wireless TDMA network is as easy as collecting these NesC files below:
- "Makefile" takes advantage of the fact that it's not necessary to recompile all the project files that has not been changed, and it is also essential in specifying all necessary libraries.
- "TestNetwork.h" defines necessary message structures for the wireless communication.
- "TestNetworkAppC.nc" connects claimed application interfaces to interfaces that are defined in the hardware librare.
- "TestNetworkC.nc" Implements send/receive functionality of a wireless node.
- "tossim-call.py" configures TOSSIM network and does packet injection into the Tossim network.
- Wireless traces: Traces for 5-sensor wireless network in a building.
A simple Simulink Model
Joint Simulation
And you are ready to go for the wireless network setup.
Put all the above files into the same folder, prompt a terminal (or a Cygwin window), and: 1. In the terminal, Make micaz sim and hit return 2. In the terminal ./tossim-call.py
Get Support
- TinyOS and TOSSIM: Bo Li: boli@seas.wustl.edu
- Simulink Models: Zhuoxiong Sun: SUN152@purdue.edu
References
- B. Li, Z. Sun, K. Mechitov, G. Hackmann, C. Lu, S. Dyke, G. Agha and B. Spencer, "Realistic Case Studies of Wireless Structural Control," ACM/IEEE International Conference on Cyber-Physical Systems (ICCPS'13), April 2013.
- Z. Sun, B. Li, D. Dyke, and C. Lu. "A novel data utilization and control strategy for wireless structural control systems with tdma network," In Proc. ASCE IWCCE 2013.
- Z. Sun, B. Li, S.J. Dyke and C. Lu, "Evaluation of Performances of Structural Control Benchmark Problem with Time Delays from Wireless Sensor Network," Joint Conference of the Engineering Mechanics Institute and ASCE Joint Specialty Conference on Probabilistic Mechanics and Structural Reliability (EMI/PMC'12), June 2012.
- H. Lee, A. Cerpa, and P. Levis. Improving wireless simulation through noise modeling. In IPSN, 2007.
- P. Levis, N. Lee, M. Welsh, and D. Culler. Tossim: Accurate and scalable simulation of entire tinyos applications. In Sensys, 2003.