CS378 Introduction to Cyber-physical Systems
Due: Feb 7, 2013
The H. Kopetzí»s paper compares the time-triggered system and event-triggered system in predictability, testability, resource utilization, extensibility, and assumption coverage. Besides these, one potential advantage of event-triggered system over time-triggered system is the lower power consumption. In this assignment, we are going to measure and compare the energy consumed in bringing the inverted pendulum into a stable state in a time-triggered system and event-triggered system. The assignment consists of the following tasks:
1. Modify the way force is applied on the cart.
In the current Inverted Pendulum system, once the Actuator receives the action from the Controller, it will update the action in Physics. Physics will keep applying that action to the simulated system until it receives the next action from Actuator. This is not good for control purposes, especially in event-triggered system. We do not want to apply the action forever. For every action, we want to specify a time interval, for which we shall apply the action on the system. If we do not receive updates from controller in this time interval, we withdraw the action at the end of the time interval.
The first task of this assignment is to modify the current Inverted Pendulum system so that it will support this new type of Actuator. The new Actuator should receive two values from the Controller: action and time_interval. The Actuator will apply the action on Physics for time_interval. It will be good if your new Actuator is compatible with your old Controller. That is, if it only receives action from Controller, it should behave as before.
2. Measure the energy consumption
Assuming that there is a motor driving the cart, we can measure the energy consumption by measuring the energy transferred between the cart and the motor. The energy transferred is measured by the work performed in moving the cart. The work done by a constant force of magnitude F on a point that moves a distance d in the direction of the force is W = Fd.
In our simulation, the force in each simulation step is constant. We also know the position of the cart in each step and thus we can get the value d by comparing the positions of the cart at the beginning of the step and at the end of this step. Then, we can calculate the total work by summing F*d. In our case, you may ignore the direction of the d and just take the absolute value of d in computing energy usage. Your second task is to implement this in Physics and also display the result in the user interface.
3. Develop a controller for event-based sensor.
Your third task is to develop a controller for the event-based sensor. As explained in task 1, the new controller should have two outputs: action and time_interval. Tune your controller so that it can bring the Inverted Pendulum into stable state quickly. This is similar to what you have done in Assignment 1. In this assignment, please use the default setting of the event-based sensor, whose threshold is 5 degree and sampling rate is 100 Hz.
Please pay attention to the time in the system. There are two types of time: real time and simulation time. When you set the interrupt (timer) on the computer, you should use real time. When you calculate the physics parameters in the simulation, you should use the simulation time. You need to choose the proper one and probably do some conversion in your implementation.
Turn in the code for your controller and a description of what you have accomplished in building the controller. Compare the performance of your event-triggered controller to the time-triggered controller you have designed previously.