CD IB fob r s / s 6 / f O ON INTERACTIVE CONTROL FOR INTELLIGENT COLLISION EVASIVE EMERGENCY INTERVENTION IN SMART VEHICLES L I B R A R Y UWVERSiTY OF MORATUWA. SRI L A M L f MORATUWA A thesis submitted to the Department of Electrical Engineering, University of Moratuwa in partial fulfillment of the requirements for the Degree of Master of Science by SAMARANATH RAVIPRIYA RANATUNGA Supervised by: Dr Sisil Kumarawadu University of Moratuwa 93949 Department of Electrical Engineering University of Moratuwa Sri Lanka 6 2 . \ - 3 ° ' ~TH J a n u a r y ^ ' ~ 9 3 9 4 9 Contents Declaration v Abstract vi Acknowledgement viii List of Figures ix List of Tables xi 1. Introduction 1 1.1 Collision Avoidance of Vehicles 1 1.2 Interactive Control of Vehicular Systems 1 1.3 Intelligent Applications in Vehicles 3 1.4 Hierarchy of Control among Vehicles 3 1.5 Inter-Vehicle Communication (IVC) 4 1.6 Modern Sensor Technologies for Smart Vehicular Systems 6 1.7 Main Controller Studies 7 1.8 Changes in Modes of Control and Human Factors Considerations 7 1.9 Simulation and Results 7 1.10 Prototype Studies/Realization of Prototypes 8 2. ANFIS: Adaptive Neuro-Fuzzy Inference Systems 9 2.1 Neuro-Fuzzy Hybrid Systems 9 2.2 Fuzzy Logic 9 2.3 Artificial Neural Networks 10 2.4 ANFIS Networks and Control 11 2.4.1 Hybrid Learning Algorithm 14 2.4.1.1 Least Squares Method 14 2.4.1.2 Gradient Decent Method 15 2.5 Summary 15 3. Auxiliary Functions: Synthesis of Controller 16 3.1 Vehicular Controllers 16 3.2 Auxiliary Functions 17 ii 3.2.1 Collision Condition Function 17 3.2.2 Relative Distance Function 19 3.2.3 Safety Speed Limit Function 20 3.2.4 Master-Slave Function 21 3.2.5 Steering Direction Function 23 3.3 Controller Algorithm 23 3.4 Summary 24 4. Synthesis of Controller and Training 25 4.1 Braking Controller 25 4.1.1 Fuzzy Input Membership Functions (Before Training) 25 4.1.2 Fuzzy Output Membership Functions (Before Training) 27 4.1.3 Training of the Braking Controller 28 4.1.4 Fuzzy Input Membership Functions (After Training) 28 4.1.5 Fuzzy Output Membership Functions (After Training) 31 4.2 Steering Controller 33 4.2.1 Fuzzy Input Membership Functions (Before Training) 33 4.2.2 Fuzzy Output Membership Functions (Before Training) 35 4.2.3 Training of the Steering Controller 35 4.2.4 Fuzzy Input Membership Functions (After Training) 36 4.2.5 Fuzzy Output Membership Functions (After Training) 39 4.3 Summary 39 5. Simulation Study 40 5.1 Vehicle Dynamic Model 40 5.2 Simulation Setup 44 5.3 Matlab/Simulink System Blocks for Simulation Setup 45 5.4 Parameters for each Vehicle in Simulation 48 5.5 Simulation Results 48 5.5.1 Side-End Collisions 48 5.5.2 Rear-End Collisions 52 5.5.3 Head-On Collisions 55 5.6 Summary 58 6. Prototype Realization 59 6.1 Component Selection 59 6.1.1 Controller Board-Oopic R+ 59 iii 6.1.2 Servo Motors 60 6.1.3 Radio Frequency Modules (Transmitter/ Receiver) 61 6.1.4 Ultrasonic Sensors 61 6.1.5 Digital Compass 63 6.1.6 Optical Encoder Modules 64 6.2 Testing of Individual Components for Realization of Prototypes 64 6.2.1 RF Module Testing 64 6.2.2 Servo Motors Calibration and Testing 66 6.2.3 Ultrasonic Sensor Testing 67 6.2.4 Digital Compass Testing 67 6.2.5 Optical Encoder Testing 67 6.3 Development of an Algorithm for Collision Avoidance Studies in Prototypes 68 6.3.1 Algorithm for the Prototype 69 6.3.1.1 Peripheral Obstacle Avoidance (OA) Module 69 6.3.1.2 Collision Avoidance (CA) Module 70 7. Conclusion and Future Directions 71 7.1 Conclusion 71 7.2 Suggestions for Future Directions 72 References 73 Appendices 76 Appendix A: Overview of Simulation Sub-System Blocks 76 Appendix B: Coefficients of the Trained Takagi-Sugeno Output Membership Functions of the ANFIS Braking Controller 83 Appendix C: Coefficients of the Trained Takagi-Sugeno Output Membership Functions of the ANFIS Steering Controller 87 Appendix D: Testing Program for RF Modules (On PC) 91 Appendix E: Testing Program for RF Modules (On Oopic R+) 93 Appendix F: Testing Program for Servo Motors 96 Appendix G: Programs for Checking Addresses of Ultrasonic Sensors 97 Appendix H: Testing Programs for Digital Compass 99 Appendix I: Testing Program for Optical Encoders 100 iv Declaration The work submitted in this thesis is the result of my own investigation, except where otherwise stated. It has not already been accepted for any other degree, and is also not being concurrently submitted for any other degree. S R Ranatunga ) (Candidate) Date: l e \ [ b \ / l o t f I endorse the declaration by the candidate. Dr. Sisil Kumarawadu (Supervisor) V Abstract This research study focuses on finding a solution for collision avoidance of smart vehicular systems. The main paradigm that is used to establish the solution is the interactive control of vehicular systems for negotiating a collision scenario for taking evasive actions. In this study, an interactive controller proposed negotiates collision scenarios between two vehicular systems leading to cooperative maneuvers. Thus, the interactive control actions lead to some maneuvers mutually beneficial to both the vehicles. The objective of this study is to develop a fully operational intelligent interactive controller for the smart vehicles. An Inter-Vehicle Communication (IVC) system plays a pivotal role in exchanging the necessary information in between the vehicles. The IVC system is assumed to be with enough versatility for dealing with multiple collisions in the channel transmitting information. This study is focusing on the vehicles outside the usually considered platoon environment. It is considering for emergency intervention maneuvers for collision evasive solutions. The hierarchical differentiation in control of the participatory vehicles is done by using the Master-Slave concept. The master is given more power in comparison to the slave. But these states are moment-bound and are to change fast. There are two main controllers which have been developed for braking and steering. The two controllers are based on Adaptive Neuro-Fuzzy Inference System (ANFIS). The top tier of this controller includes all important auxiliary functional components for processing the primary sensory variables. The ANFIS controller has been offline trained in the Matlab-7 environment. A simulation study has been done for the controllers in the Matlab/Simulink environment for various categories of collisions between the two vehicles. Even though the above paradigm is discussed for two participatory vehicular sub-systems, it is emphasized, that the same approach can effectively be extended without any major conceptual breakthrough to any number of vehicles for reliable evasion of collisions. In similar way, multiple vehicles can be considered as a multiplication of the number of pairs of vehicles for applying the results of the above study. vi Two fully autonomous prototypes were realized with full capability for testing intelligent interactive collision avoidance trials. Here, all sensor types and equipment were tested for expected functionality to be used in the integrated environment. To this end, software were developed for testing each component in the provided platform. vii Acknowledgement I specially thank my supervisor, Dr. Sisil Kumarawadu for his unwavering guidance, support and advice for carrying out this research work successfully. I am also very appreciative for his extensive help in fulfillment of some publications related to this research work, in some prestigious international forums. I am indebted to my parents and my wife for constant support and encouragement for successfully carrying out this work. My gratitude is also due to Prof. H.Y.R. Perera, Head/Electrical Engineering, for offering me a Research Assistantship in the Department of Electrical Engineering, in support of my studies. My sincere thanks are also due to the chairman and the committee members of the SRC grant committee, University of Moratuwa, for the grant they extended, which existed as an extensive support in my research studies. I would like to take this opportunity to extend my thanks to Dr. Amith Munindradasa, Dr. Rohan Munasingha, Dr. Thrishantha Nanayakkara and Dr. Lanka Udawatta for being the members of the review committee for my research. If not for their guidance and advice this work wouldn't have been a success at the end. Dr. N Munasinghe and his staff, at the Engineering Post Graduate Unit, are also thanked for all assistance extended. I have been assisted extensively by Mr. Geeth Jayendra, in realizing the prototypes for the research work. My appreciations are also due to him. I would also like to thank Mr. Buddhika Jayasekera and Mr. Dharshana Prasad, who have been my colleagues at the Departmental Research Lab, for helping me in various ways for successfully carrying out this work. Finally, my thanks go to various other personnel without whose help this work wouldn't have been a success. Understandably, their individual names cannot be mentioned here due to being large in number. viii List of Figures Figure Page Fig. 1 ANFIS controller common structure for braking and steering controllers 11 Fig. 2 Control system block diagram 16 Fig. 3 Detection of collision condition 18 Fig. 4 State diagram for change of control 22 Fig. 5(a) Membership functions of CollisionCondition_braking controller 25 Fig. 5(b) Membership functions of RelativeDistance braking controller 26 Fig. 5(c) Membership functions of MSSwitch_braking controller 26 Fig. 5(d) Membership functions of SpeedLimit_braking controller 26 Fig. 6(a) Membership functions for CollisionCondition_ braking controller after training 28 Fig. 6(b) Membership functions for RelativeDistance_braking controller after training 28 Fig. 6(c) Membership functions for MSSwitch_braking controller after training.... 29 Fig. 6(d) Membership functions for SafetySpeedLimit_braking controller after training 29 Fig. 6(e) Output control surface for the braking controller 30 Fig. 6(f) Root mean squared error for training ANFIS braking controller 31 Fig. 6(g) Root mean squared error for checking ANFIS_braking controller 31 Fig. 7(a) Membership functions of CollisionCondition_steering controller 34 Fig. 7(b) Membership functions of RelativeDistance_steering controller 34 Fig.7(c) Membership functions of MSSwitch_steering controller 34 Fig. 7(d) Membership functions of SteeringDirection_steering controller 35 Fig. 8(a) Membership functions for CollisionCondition_steering controller after training 36 Fig. 8(b) Membership functions for RelativeDistance_steering controller after training 37 Fig. 8(c) Membership functions for MSSwitch_steering controller after training... 37 Figure Page Fig. 8(d) Membership functions for SteeringDirection_steering controller after training 37 Fig. 8(e) Output control surface for the steering controller 38 Fig. 8(f) Root mean squared error for training ANFIS_steering controller 38 Fig. 8(g) Root mean squared error for checking ANFIS_steering controller 39 Fig. 9(a) Reference frames and position vectors 41 Fig. 9(b) Vehicle model 42 Fig. 10(a) Main Simulink block model for the simulation 45 Fig. 10(b) Sub-system controller block for the vehicle model-1(2) 46 Fig. 10(c) Main vehicle model sub-system with world-coordinate frame transformations 46 Fig. 11(a) Trajectories of the vehicles in near side-end collision scenario 49 Fig. 11 (b) Change of relative distance between the two vehicles 49 Fig. 11(c) Steering command (vehicle-1) 49 Fig. 11(d) Steering command (vehicle-2) 50 Fig. 11(e) Deceleration profile (vehicle-1) 50 Fig. 11(f) Deceleration profile (vehicle-2) 51 Fig. 12(a) Trajectories of the vehicles in near rear-end collision scenario 52 Fig. 12(b) Change of relative distance between the two vehicles 52 Fig. 12(c) Steering command (vehicle-1) 53 Fig. 12(d) Steering command (vehicle-2) 53 Fig. 12(e) Deceleration profile (vehicle-1) 54 Fig. 12(f) Deceleration profile (vehicle-2) 54 Fig. 13(a) Trajectories of the vehicles in near head-on collision scenario 55 Fig. 13(b) Change of relative distance between the two vehicles 55 Fig. 13(c) Steering command (vehicle-1) 56 Fig. 13(d) Steering command (vehicle-2) 56 Fig. 13(e) Deceleration profile (vehicle-1) 57 Fig. 13(f) Deceleration profile (vehicle-2) 57 Fig. 14 Oopic R+ controller board 59 Fig. 15 Hitec HS-422 standard deluxe servo motors 60 Fig. 16 RF communication modules: receiver and transmitter 61 Fig. 17 Beam pattern of the SRF235 'pencil beam' ultrasonic sensor 62 Figure Page Fig 18 SRF235 'pencil beam' ultrasonic sensor 62 Fig 19 Digital compass and external pin connections 63 Fig. 20 The optical encoder and code wheel 64 Fig. 21 Circuit diagram for RF communication between the PC and onboard RF modules 65 Fig. 22 Display for checking existing baud rate of the receiver 65 Fig. 23 Display after adjusting the baud rate to 9600 bps 66 Fig. 24 Pull-up resistors on HEDS-9040 encoder module outputs 67 Fig. 25 Prototype platforms with assembled components 68 List of Tables Table Page Table 1 Typical parameters (nominal) for each vehicle system 48 xi CHAPTER1 Introduction 1.1 Collision Avoidance of Vehicles Collision avoidance studies for vehicles are carried out for preventing any life threat or material loss from vehicular collisions. Traffic accidents have been taking thousands of lives each year around the globe, outnumbering any deadly disease or natural disaster. This shows the real picture of vehicle accidents. It is expected, the results would be worsened in the future if no effective counter action was taken. Studies show that about 60% roadway collisions could be avoided if the operator of the vehicle was provided warning at least one-half second prior to a collision [27]. This is due to the fact that human drivers suffer from perception limitations on roadway emergency events, resulting in large delay in propagating emergency warnings. The intelligent control methods can do an effective work, where the human perception limitations hinder emergency reactions. This study takes on the advantage of some computational intelligence methods giving in a promising solution for the discussed problem. 1.2 Interactive Control of Vehicular Systems An interactive controller plays the prime role in collision avoidance of smart ground vehicles, in this study. The main concern is for proving the paradigm for two vehicles. Further, it can be extended for more vehicles without a major conceptual breakthrough. The importance of the interactive control can be elaborated. For instance, when a vehicle tries to enter the main road from a side road, an on-coming vehicle on the main road can make the former wait by means of intelligent maneuvering, until the passing-by is over. Similar situations can arise in typical lane changing event too. In order to effectively control the flow around a roundabout, the interactive control will prove to be immensely useful. The so called controller creates some cooperative maneuvers within each 1 vehicle intended to create a setup for optimally avoiding a probable collision situation between two vehicles. It can be heuristically verified that more effective collision avoidance is achievable if both the vehicular systems in the verge of a collision take evasive measures after negotiating for a common solution with the other participating vehicles, rather than acting alone by each vehicle. This has led to explore different collision avoidance criteria that will ensure collaboration of all the vehicles on the verge of an accident. The resulting interactive nature of control enhances the perspectives of collision avoidance yielding better results. In the past, there have been a number of occasions where the cooperative control of vehicles with regard to collision avoidance has been studied. Considering world's number one program for developing Automated Highway Systems (AHS) i.e., the California Partners for Advanced Transit and Highways (PATH) program in cooperation with the State of California Department of Transportation (Caltrans) and the United States Federal Highway Administration (FHWA), a multilayer AHS architecture has been discussed in [7], [19] and [18]. But this control architecture has been discussed with relation to platoon environment, i.e., organization of traffic in groups of up to 20 tightly spaced cars. In a platoon environment, to maintain close proximity while traveling at relatively high speeds (90 km/h), the vehicles must be fully automated, since people cannot react quickly enough to drive safely with such small headways as 1-2 [m]. Apart from that, these works have been mainly based on elaborating the architecture of the control design rather than the full design of the controller with development details. In [30], the details were given on three different categories of vehicle controllers for collision avoidance. Here also, the main concern was to elaborate on the control system architectures giving some comparative analysis on the different categories. To the best of my knowledge, this research is the first attempts to realize interactive control of vehicular systems giving full details of the controller performance with resulting maneuvers of cooperative nature suiting for emergency intervention in collision avoidance, outside a platoon environment. Moreover, the methodology suggested here is very well adaptable not only to the fully-automated vehicles but also for the semi-automated vehicles. More importantly, the controller that has been realized in this study is working well for avoiding all-directional collisions without being amenable to a specific direction [20]. 2 1.3 Intelligent Applications in Vehicles Generally speaking, as far as collision avoidance is concerned, there are three main strata: collision warning, where it advises or warns the driver by means of audio-visual outputs, partially controlling the vehicle (driver assistance in the steady- state conditions or as an emergency intervention to avoid a collision), and fully controlling the vehicle (vehicle automation). Collision warning systems include functions such as forward-collision warning, blind-spot warning, lane-departure warning, lane-change or lane-merge warning, rear- impact warning and rollover warning for heavy vehicles. A special category of collision warning is driver monitoring to detect and warn of drowsiness or other impairments that prevent the driver from safely operating the vehicle. If the driver does not adequately respond to warnings, collision-avoidance systems might take control of steering, braking or throttle control to maneuver the vehicle back to a safe state. Driver-assistance systems include functions such as adaptive cruise control (ACC), i.e., one of the recent attractions available in the prestigious commercial vehicles where, ACC senses slower vehicles ahead and adjusts speed to establish a safe following distance [11], [21], lane keeping, precision docking, etc. Vehicle automation systems include low-speed automation, autonomous driving, and close-headway platooning etc. A fully autonomous vehicle will control its own steering and speed all the time [23]. 1.4 Hierarchy of Control among Vehicles In Master-Slave systems, one vehicle or node gives the commands, and another node or collection of nodes executes them. A node can be a master one moment and then be reconfigured at another time. The master has more control on the other vehicle systems during the period of action. On the other hand, slave obeys the latter on selected maneuvers during the time of that stay. This Master-Slave concept which gives the benefit of the centralized control approach, is common in Robotics whereas it is quite novel to the field of smart vehicular systems [24], Comparing the Master-Slave model with the other hierarchical systems, there is the Peer-to-Peer model, in which there is no designated master; all vehicle systems are equal in rank as far as hierarchy is concerned. Each node can both transmit (if the communication bus is active) and receive messages. Similar to the multi-master 3 principle, a node can both transmit messages to several other nodes and vice versa with the multicast (one to many, many to one). In peer-to-peer systems, participants rely on one another for service, rather than solely relying on a dedicated and centralized infrastructure. Further, since the communication and control are decentralized, it offers scalability, robustness, and limits requirements for central administration. Even though, peer-to-peer configurations offer greatest flexibility, they are the most difficult to control. Therefore, in this study, the Master-Slave concept has been used in order to differentiate the control hierarchy among the vehicles. [31] The Inter-Vehicle Communication (IVC) [14] facilitates receipt/transmission of data by/from each vehicular system. The internal auxiliary processing units, associated with the controller, process data relevant to each of the vehicle. The exchange of information is only relevant within a pre-specified perimeter as agreed by both the vehicular systems. Beyond this perimeter, the information received is merely neglected without any acknowledgment. 1.5 Inter-Vehicle Communication (IVC) The integration of communication technology in state-of-the-art vehicles has already begun and in existence for years. The areas of usage include: car phones, internet access from cellular technologies and Bluetooth adapters for integration of mobile devices. But, the reality of direct communication between vehicles using a wireless ad hoc network generally known as inter-vehicle communication (IVC) or car-to-car communication (C2CC) is relatively new [14]. One advantage of this over the cellular technologies is the low communication delay. This is very important in distribution of time-critical data. The advantage is that a communication network is established by the vehicles themselves within a given perimeter between two or many vehicles. The systems become alerted and begin to establish a communication network between them. This network is based on single-hop communication. The vehicle communication is decentralized and is a self-organizing information system. Inter-vehicle ad hoc networks are highly volatile due to high mobility rates of vehicles. These wireless ad hoc networks need to be spontaneously created and re-configured in a variety of traffic situations [2], When the relative distance is less than a critical 4 distance within the above limits, the vehicles start exchanging the relevant sensor and other secondary level information with due 'acknowledgement' from each other. The approach for disseminating information using the IVC is by flooding the local area of the vehicle (as against the method of traditional routing-based). This is quite feasible as the concerned area is within a perimeter of 40[m] radius in the study of this research. Under the general study of IVC systems, the five basic types of messages that are exchanged between vehicles are [6]: 1) Basic Safety Messages containing data describing the sender characteristics and driving conditions. 2) Warning Messages containing critical warning on emergency situations that has occurred or could possibly occur within the traffic. 3) Info-Entertainment Messages containing data about services and resources available and offered by other vehicles and information of general interest (e.g. traffic conditions and meteorological data). 4) Routing Messages containing data used by routing protocols. 5) Inter-Personal Messages containing different profiles of the drivers and the passengers in the vehicles. But in this specific study, the expected main features relevant to the discussion include mainly the numbers 1) and 4). The exchange of information is by means of 'packets' of data, which has a generic format. This format for such communication might include: vehicle identity information, current latitude/longitude, lane-code, current hierarchy of the vehicle, i.e., master/slave statuses or empowerment details, current velocity, acknowledgement information etc. The segment of information in a standard code of format is exchanged in between the vehicles within an agreed upon frequency band. On receipt of valid information within the perimeter, they are acknowledged with a 'handshake' for confirmation by the neighboring vehicular system. As an infrastructure to create such communication, it is required to create an air interface, protocols and applications required. The communication with infrared and millimeter waves are usually directional. Therefore, they are not preferred in this study for IVC usage. Besides, those with VHF and microwaves are of broadcast type. Although VHF waves (e.g. 220[MHz]) have been used because of their long communication distance, the mainstream nowadays is microwaves. It is convincing that the most suitable wave medium for the kind of application as this study requires microwave [13]. A significant challenge in IVC networks would be the implementation of suitable routing protocols so as to ensure successful data packet delivery and lower packet delivery delay [2], The multiple access schemes for the protocols are preferable here. In order to avoid destructive interference with already established channels, the protocols need to transmit additional information to let all nodes be aware of the status of each slot. Under appropriate code assignment and spreading- code schemes, the primary collisions i.e., two nodes with the same code try to access the channel together, can be avoided. For avoiding multi-access interference (MAI) leading to secondary collisions at a receiver, the channel is split into control and data channels. RTS/CTS (Request to Send/Clear to send) are transferred over control channels to let all potentially interfering nodes be aware of the channel status [13]. 1.6 Modern Sensor Technologies for Smart Vehicular Systems Each vehicular sub-system is endowed with most modern surveillance and navigational equipment and sensors for detecting information related to effective collision avoidance. Each IVC unit onboard involves in exchange of information between the vehicles [14]. The speed of the vehicle is measured by speedometer onboard [29]. Laser range scanners are used to detect the distance to each and every moving and non-moving obstacle around and on-path of each vehicle [9], [10]. The navigation sensors based on Differential Global Positioning System (DGPS) detect the latitude/longitude information of each vehicular system [1], [26], The required electronics and software are integrated for each module for error corrections. A digital compass onboard each vehicle detects the heading angle of it [26]. It is common practice to integrate GPS with inertial sensors and possibly other motion sensors to bridge GPS outage gaps and enhance the system integrity. The technology exists today for GPS receivers with processors and electronics contained on a single chip. Progress in the development of semiconductor-processing technology using micro- electromechanical systems (MEMS) has led to the introduction of new inertial sensors in the automotive industry [28]. 6 1.7 Main Controller Studies The main controller is synthesized using an Adaptive Neuro-Fuzzy Inference System (ANFIS) of Takagi-Sugeno type [12]. This option is preferred because it not only allows the proven ability of fuzzy logic in handling the areas of uncertainty and nonlinearities in real world systems but also gives way for the controller to adapt during the training process due to its neural network representation. The ANFIS controller has been trained offline with a satisfactory number of data sets. There are two main ANFIS controllers onboard each of the two vehicular systems: one for the control of braking and the other for control of steering. 1.8 Changes in the Mode of Control and the Human Factors Considerations The controller mode of the vehicle is normally in the Driver Control Mode. When specific conditions arise conducive for a probable collision as discussed in the algorithm, the mode of control of the vehicle can change into Collision Avoidance Mode. It is understood that the sudden changes like the above must not interfere with the normal driving habits. One potential solution is to give a constant visual feedback to the driver whenever a change in the control mode occurs. The driver is likely to get startled when a sudden change of mode of control occurs. But the most promising feature of the controller is that it can even intervene in avoiding a series of likely consecutive collisions which may have arisen due to incapability of the driver to respond positively to the changes of control modes. The most essential requirement of the driver to be efficiently interactive in the environment discussed is to get trained and customized to the sudden changes in the control modes by getting an enough exposure in a simulator environment, beforehand. With enough experience, the driver will be in a position to take the changes in modes with the normal sense [22], 1.9 Simulations and Results The simulation study for the controller has been carried out in the Matlab/Simulink environment. This platform is heavily used in a wide range of applications, including signal and image processing, communications and control design etc. This high-level technical computing environment is well suited for algorithm development, data visualization, data analysis, numerical computation and 7 simulations. With the extensive add-on features of Matlab/Simulink, it allows development of technical solutions faster than with traditional programming languages, such as C/C++ and Fortran. 1.10 Prototype Studies/ Realization of Prototypes In this study, two fully autonomous prototypes were developed with all the required sensory and communication capabilities. After assembling the platforms, each component was individually tested for their performance related to the intended performance. The communication between the prototypes and the central PC is through RF broadcasting. The prototype was intended to detect the obstacles as well as the other prototype in a verge of a collision. The obstacle detection was intended to be done with ultrasonic sensors. Detection of the other prototype was intended to be done with the relative distance information plus the heading information that are fed through the RF communication. The required software were developed and used with each component testing. The most important hardware component i.e., RF receiver/transmitter modules, were extensively tested for their expected performance, after developing some supporting circuits for communication with the central PC and RF modules onboard the prototypes. 8 CHAPTER 2 ANFIS: Adaptive Neuro-Fuzzy Inference Systems 2.1 Neuro-Fuzzy Hybrid Systems Neuro-Fuzzy refers to hybrids of artificial neural networks and fuzzy logic. Hybridization of neuro-fuzzy results in a hybrid intelligent system that synergizes these two techniques by combining the human-like reasoning style of fuzzy systems with the learning and adaptive structure of neural networks. Neuro-fuzzy hybridization is widely termed as Fuzzy Neural Network (FNN) or Neuro-Fuzzy System (NFS) in the literature. Neuro-fuzzy system incorporates the human-like reasoning style of fuzzy systems through the use of fuzzy sets and a linguistic model consisting of a set of IF-THEN rules. The adaptive or learning capability comes from the strength of Neural Networks. One of the well known examples is ANFIS. 2.2 Fuzzy logic In the Fuzzy Set Theory, if X is a collection of objects and denoted generally asx , i.e., x e l , then X is referred to as the universe of discourse or simply as the universe. I m a y consist of discrete objects or continuous space. Then a fuzzy set A can be defined as, where /uA(x) is called the membership function for the fuzzy set A . The membership function maps each element of X to a membership grade between 0 and 1, i.e. A = {(x,/Ua(X))\X&X}, (1) MA{X):X^[ 0,1], A fuzzy set is completely characterized by its membership function. There are a various classes of membership functions and are usually parameterized. In the following study of the ANFIS controller, the Gaussian membership function has been used [12]. A linguistic variable serves to summarize information and express it in terms of fuzzy sets instead of crisp numbers. This looks as an alternative approach to modeling human thinking. A fuzzy if-then rule assumes the form: If x is A then y is B , where A and B are linguistic variables. Often "x is A" is called the antecedent or premise and "y is B " is called the consequence or conclusion. Defuzzification is referred to as the way of extracting a crisp value from a fuzzy set as a representative value. In the Takagi-Sugeno type fuzzy model, which is the type being used in the ANFIS neuro-fuzzy controller, has the form If x is A and y is B then z = f ( x , y ) , where A and B are fuzzy sets in the antecedent, while z = / ( x , y) is a crisp function in the consequent [12]. 2.3 Artificial Neural Networks An artificial neural network is a data processing system consisting of a larger number of simple, highly interconnected processing elements (neurons) in an inspired architecture. These processing elements are usually organized into a sequence of layers. Each of the connections between neurons has an adjustable weight. Neural networks perform two major functions: learning and recall. Learning is the process of adapting the connection weights in an artificial neural network to produce the desired output. Recall is the process of accepting an input stimulus and producing an output response in accordance with the network weight structure. There are a number of training algorithms for the artificial neural networks. The feedforward neural networks operate in a simple straightforward manner. However, when there are feedback connections, either between neurons in the same layer or from the layer to an earlier layer, the process is much more complicated [25], 10 2.4 ANFIS Networks and Control ANFIS is a hybrid neuro-fuzzy controller system. In other words, ANFIS belongs to a class of adaptive networks that are functionally equivalent to fuzzy inference systems. Fig. 1 ANFIS controller common structure used for the control of braking and steering where Xj, x2, x3, and x4 are CollisionCondition, RelativeDistance, MSSwitch, and SafetySpeedLimit (for braking control)/SleerDirection (for steering control), respectively The Adaptive Neuro-Fuzzy Inference System (ANFIS) architecture of linear Takagi-Sugeno type has been adopted in the main controller synthesis of this study. Two ANFIS systems are used: one for braking control and the other for steering control. ANFIS controller is a very effective neuro-fuzzy 'hybrid' scheme based on a fuzzy inference system framework with adaptive network functionality. The main advantage of using an ANFIS is that it enhances fuzzy controllers with self-learning capability for achieving the control objectives with near optimality. ANFIS is a multilayer feed-forward network. The controller structure both common to the braking controller and the steering controller is shown in Fig. 1. There are 4 input variables and one output as characteristic of the general ANFIS. Here, each node performs a particular function on incoming signals. That functional aspect is characterized with a set of parameters pertaining to each node. 11 The square nodes, which are commonly referred to as adaptive nodes, have parameters while the circular nodes (fixed nodes) have none. The collection of adaptive parameters is referred to as the parameter set of the adaptive network. To given training data. Let the output of the / th node in layer / be O,,. The ANFIS architecture adopted here consists of 5 layers in its construction as shown in Fig. 1. Layer 1: Every node i in this layer is an adaptive node and has the node function where xk\k = 1,-• • ,4 is the input to node i and Ai is the linguistic label associated with this node. We use Gaussian membership functions (MFs). Therefore where {c, a } is the parameter set with c and a, respectively, representing the center and the width of the MF. Parameters in this layer are referred to as the premise parameters. Layer 2: Every node in this layer labeled as n is a fixed node whose output is the product of all incoming signals given by, achieve the desired input-output mapping, these parameters are updated with the Ou = Ma, (**) (3) (4) °2,i = w, = Ma, O i)Mb„ (x2)Mcin ( X ) (5) i= 1, 2,..., 54; j,k,m = 1, 2, 3; n=1,2. The node output represents the firing strength of the rule. 12 Layer 3: Every node in this layer is a fixed node labeled N. The z'th node calculates the ratio of the z'th rule's firing strength to the sum of all rules' firing strengths given by w 03i=w, = z'= 1,2,.. . , 54. (6) i The outputs of this layer are the normalized firing strengths. Layer 4: Every node z in this layer is an adaptive node with a node function °4 j = = (p,x, + g,x2 + r,x3 + stx, + Z,) (7) where wt is the normalized firing strength from layer 3, z = 1, 2, ..., 54, and { pi,qi,ri,si,ti} is the parameter set of this node. Parameters in this layer are referred to as consequent parameters. Layer 5: The single node in this layer is a fixed node labeled Z , which computes the overall output as the sum of all incoming signals given by O,, = £ * , / = ( 8 ) Here in this study, ANFIS is used with the effective hybrid learning rule. With this learning algorithm, node outputs go forward until level 4 and the consequent parameters are identified by the least squares method. In the backward pass, the error signals propagate backwards and premise parameters are updated by gradient decent. This hybrid approach converges much faster than the original pure back-propagation method because the latter reduces the search space dimensions [12]. 13 2.4.1 Hybrid Learning Algorithm The hybrid learning algorithm, consisting of Least Squares Method for the forward passing and the Gradient Decent Method for the back propagation, is used to train the ANFIS. There are several ways of combining gradient decent method and the least-square method. 2.4.1.1 Least Squares Method Using the matrix notation, the set of equations obtained from the regression function substituting training data pairs can be written as, A0 = y, (9) where, A is an mxn matrix, consisting of the known functions of the input data, 0 being nx 1 unknown parameter vector, and the y being the mxl output vector. Equations (9) can be modified incorporating an error vector e : AG + e = y (10) The sum of squared error can be defined by, m m = I U - = ere = (y - AG)r (y - AG) (11) ;=i The above squared error minimized for certain G will give as an estimator. The root mean square error is straightforward to obtain from the equation (11). 14 2.4.1.2 Gradient Decent Method The gradient-based optimization techniques are capable of determining search directions according to an objective function's derivative information. Here, a real- valued objective function E is defined on an »-dimensional input space, 0 = [#,,#,,.. . , # J r • Finding a minimum point 0 = 0* that minimizes £"(0) is of primary concern. In the iterative decent methods, the next point 0A+I is determined by a step down from the current point 0^ in the direction vector d: e*+ i=e*+>7A (&=i,2,3,...), (12) where tj is the learning rate, rj is determined by line search methods. The next point should satisfy the following inequality: E(QkJ = E(Qk+r1d) rj and O, Fig. 3 Detection of collision condit ion, for instance, f rom the perspect ive of vehicle-1. In other words, the above condition is satisfied when the vector VR falls within the 'collision cone' of AO,B. The collision condition can be explained in rigorous terms as follows. An extended collision cone is defined by adding /r /18 [rad] from either side of the collision cone, AO,B. If the collision cone area is denoted as, Cc =[-y/ , + ys] , then the extended collision cone can be described as, Cc+ =\-Y-nl\8,^ + ^ + ^/18], If r/eCc, it can be said, the two vehicles are 'in line of collision'. But, if T] e Cc+ f | C'c, where C'c is the complement of Cc , the situation is identified as 'in line of likely collision'. To that end, if T] <£ Cc+, then it will be concluded the vehicles are 'not in line of collision' whatsoever. These different situations are now quantified and then be fuzzified to be used by the ANFIS controllers. The situation, 'in line of collision' is assigned the value o f ' -3 ' . The situations 'in line of likely collision' and 'not in line of collision' are assigned '- 1.5' and '0', respectively. These values are used to initialize the centers of the Gaussian membership functions in the Fuzzy Logic. The Fig. 5(a) and 7(a) give the membership functions before being trained for the braking controller and the steering controller. Fig. 6(a) and 8(a) give the membership functions after being trained for the braking and steering controllers, respectively. 18 LIBRARY DIVERSITY OF MOBATUWA. SSI IAKIW 1 MORATUWA 3.2.2 Relative Distance Function This is the Euclidean distance between the c.o.g. s of the two vehicles as given in terms of the coordinates of the c.o.g. of the two vehicles: RelativeDistance = xl - x2 )2 + (y, - y2)2 ^ . (16) Relative Distance, RD , normally can take the range, RD = [0,co] . But wheni?D <5.0[m], the two vehicles are considered to have 'collided'. Here, the distance, r = 5.0 [m] is the minimum radius of the circle, that can be drawn around twice the size of the vehicle (Collision Condition Function gives more details). Remark 3.1: For simplicity, the two vehicles under this study are assumed to have same dimensions. Relative distance can easily be calculated using positional data obtained through the GPS sensors [1], [26], The positional details of the other vehicle are received through the IVC. It can reasonably be assumed that the absolute position error of GPS is cancelled off when calculating the relative position between two GPS receivers. 93949 19 3.2.3 Safety Speed Limit Function The safety speed of the vehicle is defined in terms of the 'braking critical distance'. The speed of the vehicle is said to be safe when the relative distance between the vehicles is more than the braking critical distance. The braking critical distance, dbr, is defined as follows for the three categories of collisions: Where, v is the speed of the vehicle, vrel is the relative velocity of the vehicle w.r.t. the other, and a is the maximum deceleration of the vehicle. A clear criterion for correct identification of the three different collision scenarios, mentioned in (17), is important. For correct identification of head-on and rear-end collision cases, a cone area is defined using the forward longitudinal-axes directions of the two vehicles. I fU - £ \ e A h o = [11^/12,13^/12] , the case is taken as a head-on collision, where ex,e2 are yaw angles of the vehicle-1 and vehicle-2, respectively. If |f , - s 2 \ e A r e = [ - ; r / 1 2 , /r/12], the collision scenario is a rear-end collision. Otherwise, i.e., when|f , -E 2 \<£ (A RE {J A HO ), it is considered to be one of side-end collision situations. The vehicle will be in the 'manual (driver controlled) mode' if the relative distance, R D > dbr + ks, where ks is a constant. But if RD < 6 [m] , the mode will always be switched to collision avoidance mode, irrespective of the other conditions. If R D < dbr + ks, i.e., when the speed is 'unsafe' (while 77 e Cc+ when RD < 25 [m]), the vehicle is decelerated until RD>dbr+ks, i.e. until the 'safe' speed condition is satisfied. Once again, it can be said that if R D > 25 [m], the mode of control of each vehicle will unconditionally be in the driver control mode. — (v2 +(v-v r e / ) 2 ) , for head-on collisions 2 a^ ' — ( v 2 - ( v -v r e / ) 2 ) , for rear-end collisions 2a ^ ' ——, otherwise . 2 a (17) 20 Two Gaussian membership functions (MFs), 'safe speed' MF with '1' being the center and 'unsafe speed' MF with '0' being the center are used to fuzzify the "Safety Speed" function. This function is used only with the braking controller. Fig. 5(d) gives the membership function for the case before being trained, while Fig. 6(d) gives the membership function for the trained case. 3.2.4 Master-Slave Function This function identifies the control hierarchy of the two vehicles. There are a number of criteria to determine which vehicle is the 'master', and thereby, which is the 'slave'. In this study, the vehicle that moves faster at the moment will be taken as the master for simplicity. For instance, one may adopt other criteria to better suit the locations of the vehicles (say, for instance, at a roundabout) based on GPS and a geographic information system (GIS). The Master-Slave block generates a signal that is fed to the ANFIS controller for decision making. Within each vehicle, the Master- Slave statuses are calculated, exchanged and agreed upon with an acknowledgement by each vehicle with 'handshake' signals through IVC. As given earlier, the vehicles are said to be in definite collision if Rd < dbr +ks <25 [m], and the relative velocity of the vehicles are inside the collision cone, i.e., 77 g Cc+. A special case arises, when RD <6 .0[m] , where the control is always switched on to collision avoidance mode. Whenever, the vehicle is in collision avoidance mode, the 'master' or 'slave' states will soon be realized by the vehicles. Fig. 4 gives a state diagram in which different states of the vehicle and conditions for changes from one state to another are given. As discussed in the Safety Speed Function, v,and v2 are the speeds of the vehicle-1 and vehicle-2, respectively, and dhr is the braking critical distance. MSSwitch function has three variables, viz., master, slave, and driver control. In order to quantify these variables, 'master' is assigned '1 ' while the 'slave' is assigned with '0' . The value given to 'driver control' is '5 ' . As discussed before, these values are taken as the initial centers of the Gaussian membership functions of the corresponding fuzzy variables. The Fig. 5(c) and Fig. 7(c) give the membership functions before the training process for the braking and steering controllers, 21 respectively. Fig. 6(c) and 8(c) give the membership functions after they have been trained, for the two controllers, respectively. remains Master remains Driver Control Fig. 4 State diagram for change of control for veh ic le - l (veh ic le -2 ) 22 3.2.5 Steering Direction Function This function enables to clearly identify the steering directions for both 'master' and 'slave' vehicles in order to avoid a collision. The demarcated steering regions by each vehicle are identified based on the following criteria. Without loss of generality, the absolute value of steering angle can not be greater than 40 degrees [8]. In order to reduce the chances of rollover in a high speed emergency maneuver, in our study, the range for the steering angle, 8, is taken as 8 = \-n / 6 , n / 6]. The steering of the master and slave vehicles is realized based on the following criteria. If j f , - £ 2 | < ; r /2 , the range of the steering angles for the 'master' is S M - (0,/r/6] and that for the 'slave' is 8 S = \-NT 6 ,0 ) . Therefore, the vehicles steer in opposite directions. W h e n | f , - s 2 \ > nil, both 'master' and 'slave' take the same range, i.e., 8m = [0,TT/6] and£s = [0 ,^ /6] , That is, the vehicles steer in the 'same direction'. It is obvious that always8S,8m c 8 . Two Gaussian membership functions (MFs), 'same direction' MF with '0 ' as the center and 'opposite direction' MF with '1 ' as the center are used to fuzzify the "SteerDirection" function. Remark 3.2: The yaw angles are always taken as 4-quadrant angles. The Collision Condition Function gives more details for obtaining yaw angles. 3.3 Contro l l er A lgor i thm The overall control procedure that includes the high level logic control parts for collision avoidance control, is elaborated as follows: If R D e (25 ,40] [m], Start checking IVC information. The vehicular systems alert on this condition. But no action is taken, i.e.,FM ,FS e 0 <=> F° e Fn . Else-If R D E (6 , 25] [m], when, Rd < dbr + ks and 77 e Cc+, F M G F B and F S e F B . But F M ,FS e F S . 23 when, Rd < dhr + ks and 7 g C c + , FM ,FS e 0 o F d e Fn. when, R d > dhr + ks and 77 e Cc+, Fm ,Fs e 0 o F°e F„. /?De [0,6][m], V r j , W b r , F M , F s e F b a n d , F M , F S E F S . i . e . , I f , If,-£-2j < , steering angle of master, = [ 0 , ^ / 6 ] and that of slave, = [ - ^ / 6 , 0 ] , F/s^, i.e., -£"2| > TT/2 , for master and slave, = [ 0 , ^ / 6 ] a n d ^ = [ 0 , ^ / 6 ] , Note 3.1: The set of selectable control functions in a vehicle is given by F N = { F B , F S } , whereF B ,F S are the braking and steering functions, respectively. F M a n dF S g i v e the control functions selected by the master and the slave, respectively, i.e., F M , F S , F° C F N , where F D is the driver control function. Note 3.2: The selected states for the collision avoidance criteria are, Ss = {Master, Slave}, (normally main states of the vehicles, S= {Master, Slave, DriverControl}, where Ss c S). Note 3.3: Ss, Sm c 5 = [-n / 6, n 16], where 5 is the normal range of steering angles. 3.4 S u m m a r y In this chapter, a detailed description on the auxiliary functions, i.e., the secondary level functions which were used to process the primary sensory data, is given. At the end of the chapter, the main controller algorithm is elaborated. 24 CHAPTER4 Synthesis of Controller and Training 4.1 Braking Controller The following describe the aspects of the ANFIS Braking controller. 4.1.1 Fuzzy Input Membership Functions (Before Training) The input variables for the ANFIS braking controller are CollisionCondition, RelativeDistance, MSSwitch, and SafetySpeedLimit. These are kind of secondary variables obtained using primary sensory outputs as explained under auxiliary functions. The output delBrake [m/s2] is the deceleration of the vehicle that can be converted into the braking torque. The relation between the brake pressure and the desired braking torque is rather straight forward [23].The Fig. 5(a) through Fig. 5(d) give the ANFIS membership functions before they are being trained for the braking controller. CollisionCondition Fig. 5(a) Membership function of CollisionCondition Fig. 5(a) gives the membership functions for the input variable, CollisionCondition, which identifies different categories in terms of collision of the vehicle. The set of linguistic variables is: {InCollision, LikelyCollision, NoCollision). 25 Q. IH 0 . 8 I 0 . 6 £ o ID S 0 4 0 . 2 0 5 10 15 20 25 RelativeDistance [m] Fig. 5(b) Membership function of RelativeDistance. o 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5. MSSwitch Fig. 5(c) Membership function of MSSwitch 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 SpeedLimit Fig. 5(d) Membership function of SpeedLimit 26 Fig. 5(b) gives the membership functions for RelativeDistance that identifies different categories in terms of the relative distance in meters between the two vehicles in consideration, under a probable collision. More details are given under Relative Distance Function. The linguistic variables include: {VeryClose, Closeby, ModerateDistant}. The membership functions for MSSwitch are given in Fig. 5(c). It identifies the different hierarchical stages of each vehicle and check whether it is under driver control. The linguistic variables include: {Slave, Master, DriverControl} Fig. 5(d) gives the membership function for Safety SpeedLimit that identifies categories of speed of the vehicle in terms of safety critical braking limits. The linguistic variables include: {UnsafeSpeed, SafeSpeed}. How the universes of discourse for the variables of CollisionCondition, MSSwitch and SafetySpeedLimit are arbitrarily chosen to reflect the relative differences of each MFs were detailed in relevant functional descriptions under auxiliary functions. 4.1.2 Fuzzy Output Membership Functions (Before Training) The coefficients of output membership functions of Takagi-Sugeno type looked like [0, 0, 0, 0, c], in generic format, before training, 'c' is a constant generated by the Matlab/Simulink environment and is different for each of the 54 membership functions. 4.1.3 Training of the Braking Controller The training of the ANFIS braking controller was done in the Matlab/Simulink environment. 4.1.4 Fuzzy Input Membership Functions (After Training) Fig. 6(a) through Fig. 6(d) give the ANFIS trained membership functions for the above input variables. CollisionCondition Fig. 6(a) Membership functions for the input variable CollisionCondition for the braking controller. Relat iveDistance [m] Fig. 6(b) Membership functions for the input variable RelativeDistance for the braking controller. 28 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 MSSwitch Fig. 6(c) Membership functions for the input variable MSSwitch for the braking controller. 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 SafetySpeedLimit Fig. 6(d) Membership functions for the input variable SafetySpeedLimit for the braking controller. The set of data for training consisted of 650 pairs, with the format of four input data plus one output data. This set of training data was generated using a program in a spreadsheet environment in accordance with the controller algorithm. The ranges of the input and output variables were taken into consideration. For each set of program selected input data, the output variable value was selected by intuition in accordance with the proposed control algorithm. For eliminating any possibility to miss data in critical boundaries in the main range of the input variable, an index of all possible combinations was used as guidance. The difference between the input data values within a critical boundary was determined by the fact of the requirement of the 29 number of data sets for training. The generated data set enabled to train the ANFIS so that it mimics the behaviour of an expert driver. The model was validated by checking for model over-fitting with a formulated checking data set, having the same format. The checking data set was formed by adding 5% of the training data with 25% deviation, 10% training data with 20% deviation and the rest (85% of training data) with 10% deviation. Training and validation were done for 1000 number of epochs. The training and validation graphs with the changes in root mean squared error are given in the Fig. 6(f). Fig. 6(e) Output control surface for the braking controller for the input variables, CollisionCondition and RelativeDistance (when MSSwitch =1 and SafetySpeedLimit= 0). Fig.6(e) gives good continuity as is normally expected from a Takagi-Sugeno fuzzy controller. 30 Fig. 6(f) Root mean squared error for training ANFIS for the braking controller. Fig. 6(f) gives the ANFIS training history for the braking controller. Fig. 6(g) Root mean squared error for checking ANFIS for the braking controller. Fig. 6(g) gives the ANFIS checking and validation history for the braking controller. 4.1.5 Fuzzy Output Membership Functions (After Training) Some selected output membership functions of Takagi-Sugeno type for the braking controller after being trained are given below: fx = 1.85 x,+ 1.566e-8;c2 -2.79e-21xj -2.1894e-15x4-1.48 31 f2 = 0.0019x, - 0.039x2- 5.655e-23 x3 - 4.72e-17x4- 4.225 f3 =-0.311 x, -2.892e-6 x2 -5.577e-25 x3 -5.667e-l 8 x4+0.0921 /5 4 =-1.710e-15 x, +4.91 le-18 x2 -4.910e-14 x3 +5.677e-l 5 x4 +5.679e-l 5 The complete list of coefficients of the output membership functions are given in the Appendix A. 32 4.2 Steering Controller The following describe the aspects of the ANFIS Steering controller. 4.2.1 Fuzzy Input Membership Functions (Before Training) The input variables for the ANFIS steering controller are: CollisionCondition, RelativeDistance, MSSwitch and SteeringDirection. These variables are formed as secondary variables from the primary sensory input variables before they are fed into the controller as inputs. The controller output is delSteer [rad], which is the steering angle command to the vehicle. The details of ANFIS input membership functions of the input variables of the steering controller are given in Fig. 7(a) through Fig. 7(d), before training. Fig. 7(a) gives the input membership function for CollisionCondition which is used to identify the collision conditions in the same way as given under the braking controller. In the same way, Fig 7(b) and 7(c) identify the RelativeDistance and MSSwitch, respectively. All these three membership functions are in the same form as in the braking controller. Fig. 7(d) gives the membership functions for SteeringDirection, which takes into account the direction of steering to be adopted by the vehicle at a verge of a collision. The universe of discourse here is a discrete space arbitrarily chosen to separately identify the two regions for the steering direction. The linguistic variables are: {SameDirect, OppDirect}. As given under the braking controller, for the input variables, CollisionCondition, MSSwitch, and SteeringDirection, the universes of discourse are arbitrarily chosen to reflect the relative differences of each MF in contrast to the RelativeDistance variable which is a straightforward distance measurement. 33 Col l i s ionCondi t ion Fig. 7(a): Membership function of CollisionCondition R e l a t i v e D i s t a n c s j m } Fig. 7(b): Membership function of RelativeDistance. Slave Master DriverControl 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 M S S w i t c h Fig.7(c): Membership function of MSSwitch 34 SteeringDirection Fig. 7(d): Membership function of SteeringDirection 4.2.2 Fuzzy Output Membership Functions (Before Training) The coefficients of output membership functions of Takagi-Sugeno type looked like [0, 0, 0, 0, c] in generic format, before training, 'c ' is a constant generated by the Matlab/Simulink environment and is different for each of the 54 membership functions. 4.2.3 Training of the Steering Controller The training of the ANFIS steering controller was done in the Matlab/Simulink environment. 35 4.2.4 Fuzzy Input Membership Functions (After Training) Fig. 8(a) through Fig. 8(d) give the ANFIS trained membership functions for the above input variables. The set of data for training consisted of 650 pairs, with the format of four input data plus one output data. This set of training data was generated using a program in a spreadsheet environment in accordance with the controller algorithm. The ranges of the input and output variables were taken into consideration. For each set of program selected input data, the output variable value was selected by intuition in accordance with the proposed control algorithm. For eliminating any possibility to miss data in critical boundaries in the main range of the input variable, an index of all possible combinations was used as guidance. The difference between the input data values within a critical boundary was determined by the fact of the requirement of the number of data sets for training. The generated data set enabled to train the ANFIS so that it mimics the behaviour of an expert driver. The model was validated by checking for model over-fitting with a formulated checking data set, of the same format as the training data set. The checking data was formed by adding 5% of the training data with 25% deviation, 10% training data with 20% deviation and the rest (85% of training data) with 10% deviation. Training and validation were done for 1000 number of epochs. The training and validation graphs with the changes in root mean squared error are given in the Fig. 8(f). As such, the training of braking and steering controllers are similar in form. CollisionCondition Fig. 8(a) Membership functions for the input variable CollisionCondition for the steering controller 36 o 5 10 15 20 RelativeDistance [m] 25 Fig. 8(b) Membership functions for the input variable RelativeDistance for the steering controller. MSSwitch Fig. 8(c) Membership functions for the input variable MSSwitch for the steering controller. SteerDirection Fig. 8(d) Membership functions for the input variable SteeringDirection for the steering controller. Fig. 8(e) Output control surface for the steering controller for the input variables, CollisionCondition and RelativeDistance (when MSSwitch =1 and SteeringDirection = 0) Fig. 8(e) gives the control surface for the trained steering controller for the variables CollisionCondition and RelativeDistance with the other two variables fixed as given above. Fig.8(e) gives good continuity as is normally expected from a Takagi- Sugeno fuzzy controller. 0.062 ' ' ' ' 0.06 2 0.058 tu a 0.056 es 3 0.054 c | 0.052 0.046 ' ' ' 0 100 200 300 400 500 600 700 800 900 1000 Number of Epochs Fig. 8(f) Root mean squared error for training ANFIS for steering controller. Fig. 8(f) gives the root mean squared error history for training of the ANFIS steering controller. 38 0 IT "°-2 "5 -0.4 T3 - 0 . 6 RelativeDistance (m| -1.5 CollisionCondition 0 100 200 300 400 500 600 700 800 900 1000 Number of Epochs Fig. 8(g) Root mean squared error for checking ANFIS for steering controller. Fig. 8(g) gives the root mean squared error history for checking for model validation of the ANFIS steering controller. 4.2.5 Fuzzy Output Membership Functions (After Training) Following are some of the selected output membership functions of Takagi- Sugeno type for the steering controller after being trained: / , = -0.322 x, + 0.0036 x2 + 5.798e-22 x3 + 0.00459 x4 +0.233 / 2 = -0.0141 jc, + 0.00321 jc2 + 1,069e-22 x3 + 0.00021 x4 + 0.621 / 3 = -0.151 x, +0.000659 x2 + 1,996e-23 x3 +0.0039 x4 +0.0652 /5 4 = 2.69e-24x, + 1.755e-24x2-3.91 le-25 x3 + 2.691e-23 x4 -1.217e-23 Appendix B gives the full list of the coefficients of the Takagi-Sugeno output membership functions for the steering controller. 4.3 Summary In this chapter, all the Takagi-Sugeno type fuzzy membership functions for the controller are described. Even their changes after the training process have been elaborated. 39 CHAPTER5 Simulation Studies Simulation studies have been done for the interactive ANFIS controller in the Matlab/Simulink environment. The details are given below. 5.1 Vehicle Dynamics Model Newton-Euler equations have been used to derive the below model of the vehicle. This mathematical model is to be adopted for the controller evaluation in the simulation studies. The main assumptions made in deriving the model are [23]: 1) Roll, pitch and bounce motions are negligible 2) The effect of suspension on the tire axels is negligible 3) Brake, throttle, and steering dynamics are discounted. The first assumption is valid without appreciable loss in accuracy under typical and severe maneuvers for highway vehicles. The first two assumptions applicable to vehicle lateral motion control are assumed to be not considerably restrictive. The Fig. 9(a) shows two reference frames, namely, world fixed frame {W) and vehicle frame {V). As bounce motion is not considered, all the reference frames are assumed to be in horizontal plane. The origin of the vehicle frame is defined at the center-of-gravity (c.o.g.) of the vehicle. The origin of the vehicle frame can be defined by an orthogonal basis, ev = [iv,jvf, with iv taking along the longitudinal axis of the vehicle frame, and jv along the lateral axis of the same frame. It is possible to define the velocity of the vehicle's c.o.g. as, rv =xiv + yjv =[x y]*v (18) where i a n d j>are the components of the vehicle's velocity along and perpendicular to the vehicle's longitudinal axis, respectively. 40 Fig. 9(a) Reference f rames and position vectors The acceleration of the vehicle is given by rv =[x y]ev+[* y]K (19) where ev = Qev , with f l being the velocity tensor of {V) w.r.t. {W] .At this point, it is to be noted that the speed of rotation of {V) is equal to the yaw rate of the vehicle, s . i2 can be approximated, for smaller angular displacements, as I" 0 e\ £1 = - £ 0_ This results in F = [x- sy]iv + [y + sx]jv. (20) The Newton-Euler equations governing the motion of the vehicle under the influence of external dynamics can be written as follows, with reference to the Fig. 9(b) m(x-ey) = Fxr +FxfcosS - Fyfs\nS - kDx2 (21) m(y + sx) = Fvr + Fxf sin 8 + Fyfcos8 (22) I,£ = aFxfs\nS + aFyfcos<5 - bFyr (23) where x and y , respectively, are the longitudinal velocity (along vehicle's longitudinal axis) and the lateral velocity of the vehicle. And, £ is the yaw rate. The steering angle, 8 , is assumed to be the same for both the front tires of the FWS (Front Wheel Steering) vehicle system. F^ and F^are the longitudinal forces on the front and rear tires, and Fyf and Fw are the tire lateral forces. The tire/road interaction forces are symmetrical about the vehicle's x-axis in magnitude. kDx2 is the aerodynamic drag force. 41 b a Fig. 9(b) Vehicle model The tire lateral forces, Fyf and Fn are due to the difference between the direction of each tire and the heading of each tire described by side slip angle , a , which is defined as a - tan f • \ ys (24) where yg and xg=x + j£ respectively are the lateral and longitudinal velocities of the vehicle in the ground plane. Here, c is the track (length of the axle). With some mild assumptions, ^)•> and x $ e, the front and rear side slip angles can be approximated as af = y + ae „ y - be (25) x x respectively. Using a linear model of the tire/road interface, the tire lateral forces can be obtained as Fyf=-Cfaf, Fyr = -Crar (26) where Cf and Cr are the front and rear cornering stiffnesses, respectively. Furthermore, the tire longitudinal forces Fvf and Fxr can be written as -r(mg-kLx2) a + b Fxr=-f —r(mg-kLx ) a + b (27) (28) where F is the net force exerted on the wheels, i.e., Fengine - Fhraking . Parameters / and kL , respectively, are the rolling friction coefficient and the aerodynamics lift ? parameter, g =9.81 [m/s ] is the acceleration of gravity. Table 1 completes the terminology. Substituting the results in (25) through (28) into (21) through (23) yield the following form. mx = F - f ( m g - k . x 2 ) cos<5 + C, a + bv ' ' ) y + ae - 8 sin 8 + mye ~f ~~T (mg-k Lx2)- kDx2 a + bx (29) my • F- f ^ (mg-k.x2) s i n 8 - C , + °£ -S | c o s 8 - m x s J a+b{ L ' f{ x J ( V. -C y-be F - - £ - a F-f —~—j-(mg-kLx2^ | s i n 8 - C f \ ^ — S y + ae cos 8 +—Cr a y-be V x J (30) (31) The linear velocities, x andj>, in (29) through (30) are the instantaneous velocities in the directions of the vehicle's longitudinal axis and the lateral axis, respectively. The following transformations, i.e., (32) and (33) are used to refer them to the fixed world coordinate frame, {W}: x = xw cos s + yw sin e (32) y = y„cos£-x„sin£ (33) Integrating the dynamic equations in its new form will yield vehicle's coordinate positions, [*w,>'w], in the world coordinate frame. 43 5.2 Simulation Setup The simulation studies were performed in Simulink/Matlab environment. The fixed step length was taken as 0.01 [s] and the external information through IVC was obtained with an added delay of 0.05 [s] in order to simulate the delays caused by information processing, transmission etc., (It was assumed that the GPS delays could be approximately compensated during each feed from the GPS sensor by a Dead Reckoning (DR) algorithm using the data from the digital compass and the speedometer). In the simulation, the ordinary differential equations type-4 (Runge- Kutta) was used. The embedded hardware (for simulation and code generation) was selected as 'unspecified (32 bit generic)'. The model parameters are given in the Table 1 [23], The vehicles were assumed to be identical. The maximum deceleration for both the vehicles was taken as 4 [m/s2]. The steering angle was limited to [ - / r / 6 , + ; r /6] [ rad] . r is taken to be 5 [m], which is the radius of the smallest circle that can be drawn around the dimensions of twice the size of the vehicle (The Collision Condition Function provides more details). The dimensions of the vehicle are 4.45 [m] in length and 1.72 [m] in width. In simulation studies, ks = 3 [m]. 44 5.3 Matlab/Simulink System Blocks for Simulation Setup The following figures give the system block diagrams those were used to perform the simulation in the Matlab/Simulink environment. ke input 1/Normal ih /KJ xy dot to Spee - 0 To Workspace • 0 To Workspacel eps i l on l | To Workspace2 To Workspace3 • j p s i l o n l d To Workspace8 Brake input2/Normal e| is i lon2 Steer input2/Normal xy dot to Speed 1 • 0 To Workspaces V 0 o Workspace4 > - | epsi lon2 | To Workspace6 To Workspace? — • ^ p 3 l o n 2 d o | To Woikspace9 Fig. 10(a) Main Simulink block model for the s imulat ion Fig. 10(a) gives the main system block for the simulation in the Simulink/Matlab environment. All parameter feeding and outputs are designated clearly here. Information passing between the two vehicular blocks are added with a signal delay in order to allow for the IVC communication delay. 45 CE>n In2 cn>] In3 (Z> In6 ( CZZ/ Ina Collision Condiiton CollislonCondiiton Conditon Ver Relative Displace RelDi^ SafetySpeedLimit I In2 In3 In4 Out1 Master-Slave Switch riv er input [_ iriverdata control Anfis Controller for Brake CD— In10 driv e_direction DriverDataControl Anfis Controller for Steer Steering Direction relativedisplacementl brakingforcel 1Out1 Out2 20ut3 yw K ^ ) e p s i l o n Q i ^ l ^ - v epsilon v / Vehicle(Global) Fig. 10(b) Sub-system controller block for the vehicle m o d e l - l ( 2 ) Fig. 10(b) gives the controller block which identifies the two controllers and the auxiliary functional blocks together with other inputs and outputs. The optional driver control blocks are fed whenever the controller is not in operation. In1 Out1 Out2 In2 Out3 epsiltfn Veh i c l e System (local f rame) epsilon epsilon In1 In2 0ut1 In3 y w Out1 xy to yw epsilon >GD Out2 In1 In20ut1 In3 xy to xw > C D Out3 Fig. 10(c) Main vehicle model with the wor ld -coord ina te t ransformat ion blocks 46 Fig. 10(c) gives the model equations for the vehicle. The supporting blocks are to transform the model equations from the vehicle coordinate frame to the world coordinate frame. 5.4 Parameters for each Vehicle in Simulation Table 1 gives the parameters for the vehicle mode used in the simulation studies. More details can be found under Vehicle Dynamics Model. T A B L E 1 TYPICAL PARAMETERS (NOMINAL) OF EACH V E H I C L E S Y S T E M D e s c r i p t i o n V a l u e m Total mass of the vehicle 1640 kg Iz Y a w inertia 3105 kgm 2 / Rolling friction coeff ic ient 0.02 D Wheel base (a+b) 2.78 m a Distance - front axle to c.o.g. 1.193 m Cf Corner ing s t i f fness - front 131391 N / r a d C, Cornering s t i f fness - rear 115669 N / r a d A, Aerodynamics - lift parameter 0 .008 Ns2m"2 kD Aerodynamics - drag parameter 0 .49 Ns2m"2 5.5 Simulation Results The speed range of the vehicles was taken to be 15-30 [m/s] at the verge of a collision. Following are the different vehicle positions for collision evasion scenarios. The two vehicles can be considered to have not collided as long as the relative distance is not less than 5 [m], 5.5.1 Side-End Collisions Fig. 11(a) gives an account of an evasion of a dangerous scenario, which otherwise would definitely have led to a collision if had not been equipped with the collision avoidance controller. The crossing point of the trajectories is circled and the time each vehicle passed this point is given by /,and t2 for vehicle-1 and vehicle-2, respectively. The relative distance has not reached 5 [m] value as shown in Fig. 11(b) (solid line) clearly indicating that the two vehicles have successfully avoided a probable collision. The circled point shows the instant the controller is switched on. 48 Fig. 11(a) Trajector ies of the vehicles in the near s ide-end collision scenario and consequent evasion Fig. 11(b) Change of relative distance between the two vehicles ( f rom the perspective of vehicle-1). Min imum relative dis tance is at 5.8 [m] (for controlled state). 0.6 Fig. 11(c) Steering command (vehicle-1). 49 0.2 0 . 1 5 0 1 - 3 0 j 20 . I » LI 0i 1 - 5 0 - 4 0 - 3 0 - 2 0 - 1 0 0 1 0 2 0 3 0 4 0 5 0 X-coordinate [m] Fig. 12(a) Trajector ies of the vehicles in the near rear-end collision scenario and consequent evasion. Fig. 12(a) shows a case of a near rear-end collision. Here, vehicle-1 (with a maximum speed of 30 [m/s]) is fast approaching vehicle-2 (maximum speed of 20 [m/s]). Fig. 12(b) shows change of relative distance for the case as given in Fig. 12(a). Proper collision avoidance has been ensured by the fact that min(i?D) > 5 [m]. The controller was switched on at the moment given by the circled point. Fig. 12(b) Relative distance be tween the two vehicles ( f rom the perspective of vehicle-1) . 0 . 1 4 0 . 1 2 0 .1 -0.02 1 0 2 4 6 8 1 0 0 2 4 6 8 Time [s] Fig. 12(c) Steering command (vehicle-1). 4 6 Time [s] Fig. 12(d) Steering c o m m a n d (vehicle-2). Fig. 12(c)-12(d) show the mild steering commands applied in this case. Steering directions are in compliance with the policy described in Steering Direction Function. From the looks of Fig. 12(e)-12(d), it is clear that the braking controller of vehicle-1 was only actively involved in avoiding the probable collision. This is also evident in Fig. 12(a). Fig. 12(f) shows that the vehicle in the front (vehicle-2) has not put on brakes. Understandably, braking by the lead vehicle is highly unacceptable in the face of a probable rear-end collision scenario. Vehicle-1 that is behind vehicle-2 has largely depended on braking even though it also had to steer due to its high moving speed demonstrating a very natural collision avoidance performance. 53 Time [s] Fig. 12(e) Decelerat ion profi le (vehicle-1). 4 5 6 Time [s] Fig. 12(f) Deceleration prof i le (vehicle-2). 5.5.3 Head-On Collisions Fig. 13(a) through Fig. 13(f) elaborate on how the controller can successfully avoid a possible head-on collision. X-coordinate [m] Fig. 13(a) Trajector ies of vehicles in case the near head-on collision scenario and consequent evasion. Fig. 13(a) gives the scenario of avoiding a probable head-on collision. Time [s] Fig. 13(b) Relative distance between the two vehicles ( f rom the perspective of vehicle-1). Min imum relative distance is 6.6 [m]. Relative distance profile given in the Fig. 13(b) depicts successful collision avoidance with min(/?0) = 6.6 [m]. The circled point shows the instant of controller switch on. 55 0 4 5 0 . 4 , , 0 3 5 ! 0 3 M 0 . 2 5 a M 0 . 2 5 0 . 1 5 tu 7 3 0.1 0 . 0 5 0 - 0 . 0 5 Fig. 13(c) Steering c o m m a n d (vehicle-1). 4 6 Time [s] Fig. 13(d) Steering c o m m a n d (vehicle-2). As given in the Fig. 13(c)-13(d), both the steering controllers have been actively involved in avoiding this collision. As expected, the vehicles rightly steer away from each other. 56 in £ l c c - 2 - 3 - 4 0 1 2 3 4 5 6 7 8 9 1 0 Time [s] Fig. 13(e) Deceleration profi le (vehicle-1). 4 | 3 2 w 1 c o g 0 u u o - I a •2 - 3 .41 0 1 2 3 4 5 6 7 8 9 1 0 Time [s] Fig. 13(f) Deceleration profi le (vehicle-2). Fig. 13(e)-13(f) give the braking controller outputs. In this case the braking controllers have not played an active role in avoiding the collision. Remark 5.1: In the simulations, it has been assumed that an emergency steering of a vehicle to avoid a collision does not build up another collision scenario or the vehicle does not get out of the road. But in practice, this may not be the case. This problem may be solved by introducing a simple logic controller that will stop the vehicle immediately after a particular collision is avoided in case it had to steer to avoid that collision. In case if a second collision scenario has already built up, the vehicle will naturally perform another collision avoidance maneuver. 57 Remark 5.2: In case the other vehicle does not have the IVC facility or in case the collision scenario has been developed with a roadside obstacle, collision avoidance will totally depend on the peripheral sensors and the algorithm will work like a typical collision avoidance algorithm. Interactive and cooperative collision avoidance approach like the one proposed in this study can also be adopted to ensure optimal collision avoidance maneuvers in a fleet of vehicles particularly in military applications that may also include helicopters and unmanned surface vehicles (USVs). Remark 5.3: As the above outcomes are as a result of emergency intervention due to sudden actions of avoiding a collision, the accelerations that incur being comparatively high can be allowed. 5.6 Summary This chapter contains the details of the simulation study and the results. A vehicle model was used which has been derived using Newton-Euler dynamic equations. The results of the simulation were discussed under three main categories of vehicle collisions, i.e., head-on collisions, side-end collisions and rear-end collisions. 58 CHAPTER6 Prototype Realization 6.1 Component Selection The following components have been selected for realization of two prototypes intended for studying intelligent interactive collision avoidance studies in smart vehicular systems. 6.1.1 Controller Board - Oopic R+ Fig. 14 Oopic R+ Controller board Oopic R+, by Savage Innovations, Inc., is a new kind of controller board which is programmable in the object oriented style. This enables to rapidly develop or change the programs that interact with the hardware components attached to the Oopic R+ controller board. For all testing, the 'Basic' style programming was used. In Oopic R+ language, all functionality and processing are confined to the specially defined objects. This reduces the number in the instruction set making it easy to use for applications. These objects are specifically addressing some of the known functions of the hardware components, e.g. oPWM object generates a modulated 59 pulse as specified by the other properties of the object. In this development, the Oopic R+ firmware used is of the version B2.2+. The microcontroller used is based on the Microchip's PIC16F877 microcontroller. The 31 number of input lines can be connected to the given hardware options. There are 5 steps involved in creation of an application in Oopic R+: 1. Starting the Oopic Software development kit 2. Designing a hardware interface 3. Writing code 4. Connecting the hardware 5. Downloading and running the application The I2C connectivity, a versatile IC connection bus, is facilitated by the Oopic R+ board enabling effective networking with some sensors and hardware components which are featured with the same facility. This adds to easy interface made already effective by the relevant object types [15]. 6.1.2 Servo Motors The HS-422 standard deluxe servomotors, by Hitec RCD Inc., are 3-pole ferrite type attached with an in-built potentiometer. These motors are with the control system of pulse width 1500// s neutral type. The operating voltage range is 4.8v to 6.0v. The speed of operation varies from 0.21sec/60° at no load to 0.16sec/60° at no load. The stall torque lies between Fig. 15 Hitec HS-422 standard deluxe Servo Motors 60 3.3kg.cm (45.82oz.in) to 4.1kg.cm (56.93oz.in) with the two voltage extremes, respectively [5], The EasyRadio (ER) ER400TS Transmitter, ER400RS Receiver, by LPRS Ltd., were used to give a high performance communication link between the central PC and the prototypes. These RF devices can transfer data over a range of up to 250 metres Line Of Sight (LOS), even though this much of range is not required in this application. For this kind of application, these devices can be optimized with frequency, data rate and power output. The embedded software reduces design and development time significantly, together with the vendor-supplied programming and testing platform [4], 6.1.4 Ultrasonic Sensors These ultrasonic sensors, by Devantech Ltd., are for the purpose of clearly identifying obstacles around each vehicle prototype, while moving. The ultrasonic sensors were not meant to identify the other vehicle prototypes in close proximity (the adjacent prototypes are meant to be identified, by each other, with the RF communication between them). With the selection of this type of ultrasonic sensor with a very low beam pattern, as indicated in Fig. 16, gives the opportunity to detect the obstacles accurately around it against detecting the floor as an obstacle with a false alarm. Mounting arrangements of these sensors were also considered with special concern [3], 6.1.3 Radio Frequency Modules (Transmitter/ Receiver) Fig. 16 RF communication Modules: Receiver and Transmitter 61 Fig. 17 Beam pattern of the SRF235 'pencil beam' ultrasonic sensor The ultrasonic sensor is with a single transducer for both transmit and receive. Therefore, there is a blanking zone out to 10cm, so the effective range is 10cm to 1.2m. Communication with the SRF235 ultrasonic rangefinder is via the I2C bus. Therefore, this is easily connected to the Oopic R+ with its capability of I2C. In order to connect these sensors to the Oopic R+, the address of the sensors have to be changed. The Appendix G gives more details. Fig 18 SRF235 'pencil beam' ultrasonic sensor 6.1.5 Digital Compass This digital compass module, by Devantech Ltd., simply can be used as an aid to navigation in the prototypes. Especially, together with the optical encoders, this compass is meant to be used for dead reckoning purposes of the prototype. The compass uses the Philips KMZ51 magnetic field sensor, which is sensitive enough to detect the Earths magnetic field. The output from two of them mounted at right angles to each other is used to compute the direction of the horizontal component of the Earth's magnetic field. The compass readings can be obtained both from the I2C channels as well as a PWM signal. The resolution of the compass is 0.1 degrees. The compass is required to be calibrated before it can be used in the area being used [3]. Pin 9 • Ov Ground Pin 8 - No Connect Pin 7 - 50/60HZ Pin 6 - Calibrate Pin 6 - No Connect Pin * - PWM Pin 3 • SDA Pin 2 • SCt Pin 1 - Fig. 19 Digital Compass and the external pin connections 63 6.1.6 Optical Encoder Modules These optical encoder modules, by Agilent Technologies, Inc., are with three channel incremental encoders with a code wheel. The speed of the two wheels of the prototype is intended to measure using this. Optical encoder outputs together with that of the digital compass can be used for dead reckoning in navigation purposes of the prototypes. Fig. 20 Optical Encoder and code wheel 6.2 Testing of Individual Components for Realization of Prototypes 6.2.1 RF Module Testing The following circuit was realized for connecting to a central PC for communicating with the onboard RF modules on the two prototypes. The circuit is with the Max232 communication chip. With the 12V range operating with the RS232, the RF modules (with operating range of 5 V) cannot be directly connected without the circuit given in Fig. 20 [4]. As shown in the Fig. 20, the Transmitter/Receiver programming switches are selected i.e., either 1 or 2, in accordance with the requirement of programming of Receiver or Transmitter, respectively, while the RS232 socket is being connected to the central PC. 64 0 Volt Antenna Receiver Fig. 21 Circuit diagram for RF communication between onboard RF modules The central PC is installed with the 'Easy Radio Evaluation software v2.07'; a vendor supplied programming environment in PC platform that is required for programming the RF modules. The most important steps of programming the RF modules are given below. easyf&dio Evaluation Software 11,01 Pie Help Module Seting j Commuxcatnn Mode ; Module Frequency • ER40Q Module Type: r TS Find Module BAUO Rate ; Manual Command: pR'lociT? Send Command 600 £R_CMD#T3 1200 ER_CM0#T3 2400 ER_CMD#73 4800 ER_CMD#T3 9600 ER_CMD*T3 14400 ER_CM0#T3 19200 ER CMD#T3 ER_CM0#T3 ACK ER400TRS Module BAUD Rate: 19200 I-02V2.01.8 RS232 PORT; COM! Fig. 22 Checking for existing baud rate of the receiver The Fig.22 shows how the existing baud rate of the receiver is checked. It has been verified that it is currently at 19200 bps. Programmif g Switch GND PC AT Vin = 8-12V DC 1N4148 XT 100n 65 | jn-.y!l..(l t VdlgdIIOn S<V. itr- »,' t) I Module Settings | Cowrwr*cabor, Mode : Jf Mocki« Fre: j:MO#h1 (Handshaking ON) - | Update | TEST MODES . CMO*TQ CHb*i Skis Carrier 01 • | JJpdateJ Testing 8AU0: SENT: Test ing BAUD: SENT: RECEIVED: SENT: RECEIVED: 9600 ER_CMD#T3 19200 ER_CMD#T3 ER_CM0#T3 ACK ER400TRS Module BAUD R a t e : 19200 -02V2.01.8 SENT: RECEIVED: SENT: SENT: RECEIVED: SENT: RECEIVED: SENT: RECEIVED: SENT: RECEIVED: ER CMD#U3 ER_CMD#U3 ACK ER_CMD#C? ER_CMD#C1 ER_CMD#C3 ER CMD#C3 ACK u»~06wvra*'~*f Product Divide Gain2 ^ C / F Subtractl In1 Add In3 delja cos ) * Productl K D Out1 Constant2 Trigonometric Function 76 Sub-system blocks arrangement for the equation (18) term3 in x Sub-system blocks for the first term of the equation (18). Productl Gain2 77 Sub-system blocks for the second term of the equation (18). In 1 du/dt Derivative Math Function H Gain 9 Subtract Constant Gainl Constantl Divide Add Constant2 1 > Gain3^ X j • Product Gain2 Add1 • C D Out1 Sub-system blocks for CollisionCondition - (auxiliary function) In8 Relative velocity angle 78 Sub-system blocks for RelativeDistance - (auxiliary functions) F u n c t i o n l Sub-system blocks for SafetySpeedLimit - (auxiliary functions) Sub-system blocks for Critical Braking Distance Detection -( in safety speed limit blocks) Critical Braking distance criteria e p s i l o n - e x r e l a t i ve veloci ty Othewise criteria Sub-system blocks for Relative Velocity Detection-(in safety speed limit blocks) uint d > In1 In2 epsilon_int uext GL> In3 ^ r - y In4 epsilon_ext X -, psilon an ihrn— i n t . uext epsilon_ext cos 1 + sqrt Add1 " C D Out1 80 Sub system blocks for Critical Braking Distance Calculation-(in safety speed limit blocks) Sub system blocks for MSSwitch - (auxiliary function) 81 Sub system blocks for SteeringDirection -(auxiliary function) 4 quad angle convert l 82 Appendix I Coefficients of the trained Takagi-Sugeno output membership functions for the ANFIS braking controller MF1=[1.85493287780397 1.56656347832792e-008 -2.78777090594755e-021 - 2.18943002507114e-015 -1.47751322144338] MF2=[0.00188818805114922 -0.0391046120505595 -5.655468621802166e-023 - 4.71960315458807e-017 -4.25502989814296] MF3=[-0.311206059912852 -2.89230193177666e-006 -5.57726489921515e-018 - 5.66733518617125e-018 0.092168684912706] MF4=[1.78090516036869 0.000448993461274673 -2.65215602105404e-020 - 1,61378250847955e-015 -1.33107888133085] MF5=[0.00143095653842926 -0.695511639183691 4.51766108155919e-022 5.99693924992079e-017 -0.196165342759359] MF6=[-0.235474150671901 -0.0008022408540194 -4.02386402571529e-022 - 2.53532083262607e-016 0.0784913817814176] MF7=[1.78219754314681 -1.49971542355548e-006 -2.65247457224244e-020 2.86186326363054e-017 -1.32925671149844] MF8=[0.00143307733892926 -0.000550923380512301 -6.02285906402626e-023 - 3.18901862812465e-018 -0.00109487194865714] MF9=[-0.236575880406084 3.51602726741409e-006 -4.03706286669063e-022 4.51208867943279e-018 0.0788586250234672] MF10=[1.41236876156383 7.74836548921895e-005 -0.940761632951512 - 1.69293387371334e-015 -0.940761632952336] MF11=[0.000851550495225324 -0.12290699135066 -1.93407614510477 - 2.90325205500156e-015 -1.93407614512668] MF12=[0.0568838067008842 -0.000138967826958646 -0.0189612699600531 - 1.4619123355947e-016 -0.0189612699595914] MF13=[ 1.43067185425142 0.000322396262969765 -0.928295869708696 - 1.1895977977084e-015 -0.928295869730925] MF14=[0.000880456057858715 -0.498736800920241 0.0158125167511968 - 3.76097371711935e-017 0.0158125166457378] 83 MF15=[0.0422524470949704 -0.000577151930909829 -0.0140841501258741 - 3.36360450743086e-016 -0.0140841501219997] MF16=[1.43050272287111 6.95786293633979e-006 -0.928407367059313 1.60510371436439e-017 -0.928407367292285] MF17=[0.000880185010786668 -0.0124488847441026 -0.00210809437561626 - 1.55711640963045e-018 -0.00210809437543177] MF18=[0.0423910410731516 -1.25851479860497e-005 -0.0141303481217863 5.71738476864628e-018 -0.014130348120857] MF19=[ 1.08414267218279e-010 1.67520089870481 e-013 -6.92559667040256e-011 -8.94690537838035e-026 -7.16219661069277e-011] MF20=[6.53655492616008e-014 -5.2493165112919e-016 2.42136558593993e-011 - 1.65194642352065e-025 -1.13926111300394e-010] MF21=[4.36641240708894e-012 -1.06672422411122e-014 -1.45547650880719e-012 2.8796032094274le-027 -1.45547088341401 e-012] MF22=[ 1.09819223879661 e-010 6.80224264591896e-013 -7.12563333225284e-011 -6.15842544549948e-026 -7.12565340126381 e-011] MF23=[6.75843579401656e-014 -1.13952777928779e-014 1.22073674279561e-012 -2.24226483623394e-027 1.21515315719545e-012] MF24=[3.24330020601853e-012 -4.43025356782097e-014 -1.08110636537503e-012 -6.21616582829639e-027 -1.08110015244337e-012] MF25=[ 1.09806241205619e-010 1.6894925031795le-014 -7.12377063463645e-011 8.24981021890162e-028 -7.12596553597257e-011] MF26=[6.75635524234489e-014 -2.25075188548078e-016 1.43244776521596e-012 -8.70791626630218e-029 1.57034768421012e-013] MF27=[3.2539386624286e-012 -9.6604'3596374453e-016 -1.08465254666739e-012 1.26069877150266e-028 -1.08464630466676e-012] MF28=[ 1.40954224747582 -0.018891882017138 -2.05923520450994e-020 - 0.92989898455487 -0.929898984157109] MF29=[0.000834673712229795 -0.158311478028552 -3.53143080360956e-020 - 1.86035276476269 -1.86035276483816] MF30=[0.0698185461069066 0.0246760731120892 -1.77822736795729e-021 - 0.0232728497244504 -0.023272849727017] MF31=[1.32101380978095 -0.0815101645262228 -1.4469919343987e-020 - 0.687065769800061 -0.687065769595765] 84 MF32=[0.000481801086359453 -0.48095867278042 -4.57473839665651e-022 0.0255318897079654 0.0255318896925871 ] MF33=[0.32382284571127 0.086458193655589 -4.09139005008161e-021 - 0.107940949162273 -0.107940949161876] MF34=[-0.0234682174030531 0.110522246076779 1.95240116715718e-022 0.0121843449987058 0.0121843449989397] MF35=[-8.54744408335168e-006 -0.0105708296676607 -1.89403081617568e-023 - 0.00135772046360727 -0.00135772046371755] MF36=[-0.00576304733315131 0.0169641008091585 6.95445945046986e-023 0.00192101578831545 0.00192101578831691] MF37=[ 1.21647748595465 -0.0174266273547775 -0.720764356304056 - 0.720764356369119 -0.720764356382051] MF38=[0.000573295840690735 -0.158021655897377 -1.23605572304533 - 1.23605572323918 -1.2360557234049] MF39=[0.186722171123285 0.0178399178810316 -0.0622407243688787 - 0.0622407243760833 -0.0622407243835856] MF40=[1.1437093340048 -0.101517684744655 -0.506469688538764 - 0.506469688588521 -0.506469688607826] MF41=[0.000243583665672331 -0.466613433388744 -0.0160122959535769 - 0.0160122960655791 -0.016012296173864] MF42=[0.429615050331612 0.102157517705376 -0.143205017106381 - 0.143205017108502 -0.143205017110729] MF43=[-0.0168017891915329 0.0598667351752015 0.00683370783725823 0.00683370783718899 0.00683370783702196] MF44=[-2.42584734688325e-006 -0.00457626219347974 -0.000662940252393523 - 0.000662940252340684 -0.000662940252343155] MF45=[-0.0073025070041557 0.0213992347858687 0.00243416900437736 0.00243416900437532 0.00243416900437569] MF46=[5.2039842657982e-011 2.80764456243822e-017 3.08486327833713e-011 - 3.80913313467262e-011 -3.8091331360747e-011 ] MF47=[3.80898084118402e-014 3.68989994805484e-016 2.78647409739092e-011 - 7.0331400602729e-011 -7.03314005626012e-011] 85 MF48=[-3.67796187233628e-012 5.81675699789329e-016 2.52404612504839e-011 1.22598724670116e-012 1.22598724689592e-012] MF49=[4.64091459092637e-011 3.95547012878422e-018 2.44106577034843e-011 - 2.62194149544053e-011 -2.62194149392098e-011] MF50=[2.09226110387692e-014 6.43631175374455e-017 1.43230483292808e-013 - 9.54641239373371 e-013 -9.54641247690823e-013] MF51=[7.93957306832783e-012 1.3434346270498e-016 3.07373740224877e-011 - 2.64652438369614e-012 -2.64652438697474e-012] MF52=[-6.71888450119944e-013 9.21089033324976e-019 -3.42067170169733e-013 3.51234579552481 e-013 3.51234579819694e-013] MF53=[-2.49329672958528e-016 2.09104525578082e-017 1.81818386212095e-014 -3.70738384174794e-014 -3.70738384049999e-014] MF54=[-1.71022249265169e-015 4.91148346166778e-018 -4.91022431025983e-014 5.66740833132776e-015 5.66940834233913e-015] Appendix C Coefficients of the trained Takagi-Sugeno output membership funct ions for the A N F I S steering controller MFl=[-0.322805222781183 0.00362686564582176 5.79872081449726e-022 0.00459643530203612 0.233700716367951] MF2=[-0.0141401283986403 0.00321630064447319 1.06921842723302e-022 0.000213828079351621 0.621299384797979] MF3=[-0.151411132031514 0.000659448306702709 1,96664552202557e-023 0.00394773596868353 0.065251827280593] MF4=[-0.205016519995446 0.00834115996663714 5.02713143430929e-022 0.00462899768246495 0.173744077047217] MF5=[-0.0104282735824621 0.0113064529218618 1.0131801389655e-021 0.000231076288179999 0.464134594707426] MF6=[-0.138182807882656 0.00322993071781877 1.85112013804364e-022 0.00403895685578697 0.0535539157672092] MF7=[0.00533148927894381 -0.0346608665848006-1.26216595392427e-023 2.69347057593369e-005 -0.00416699816015225] MF8=[0.000271052334358062 -0.0640224703149074 -1.47264981032215e-023 1.3693391045203e-006 -0.00811108501259] MF9=[0.00362214433976581 -0.0117758497539056 -4.9353652489758e-024 1.83029491618058e-005 -0.00140211434468265] MF10=[-0.17800019493801 0.00133846798138546 0.138865688065683 - 0.00450653677097079 0.13886568805093] MF11 =[-0.00899907153467869 0.00034423133578969 0.271422875882059 - 0.000224476027383358 0.271422875947102] MF12=[-0.131513396798413 0.00089641433958575 0.0503030385314004 - 0.00403430163598855 0.0503030385339973] MF13=[-0.164812486804915 0.00502519651146597 0.12930768053794 - 0.00453805499180304 0.129307680529237] MF14=[-0.00831734756202328 0.00289689172334492 0.260609803589193 - 0.000226125063567489 0.26060980358097] 87 MF15=[-0.124916741168366 0.00366326905257527 0.0476144407481921 - 0.00404592658589342 0.0476144407180423] MF16=[0.00451159016967478 -0.0271449023268344 -0.00324653838842148 - 4.6688127832172e-005 -0.00324653838837297] MF17=[0.000228169609157629 -0.0293739470705651 -0.00378794415026845 - 2.43548050652633e-006 -0.00378794415028086] MF18=[0.00331670267250217 -0.0106724814854268 -0.00126947274150056 - 1.87404839608323e-005 -0.00126947274155334] MF 19=[-9.401027073839e-021 8.03353173348444e-023 7.3344627408673le-021 - 2.37838114040954e-022 7.3333548175287e-021] MF20=[-4.75286759381198e-022 1.67205037230794e-023 1.42973758534986e-020 -1.54185987470079e-023 1.43258934246299e-020] MF21 =[-6.94510915302454e-021 4.90460316170534e-023 2.65708605956778e-021 -2.12965849731965e-022 2.65649851444954e-021 ] MF22=[-8.70966018961069e-021 2.65570459024276e-022 6.84658422004529e-021 -2.37817396400502e-022 6.83199549223022e-021 ] MF23=[-4.3954747014222e-022 1.51038215970592e-022 1.3731153688715e-020 - 1.50273245992969e-023 1.37558444314271e-020] MF24=[-6.59924585193978e-021 1.93422881478181e-022 2.5201885176145e-021 - 2.13071808517929e-022 2.51553762230068e-021 ] MF25=[2.38227030481622e-022 -1.43372353711075e-021 -1.71316406976815e-022 -2.45311050426079e-024 -1.71415195811736e-022] MF26=[1.20481508531602e-023 -1.5456876349406e-021 -1.9922199613713e-022 - 4.78202732603647e-026 -1.99868316922924e-022] MF27=[ 1.75125980177255e-022 -5.63557006620458e-022 -6.70023598667599e-023 -9.86162002939691 e-025 -6.70300909664824e-023] MF28=[-0.279032466168259 0.000373882171985563 -5.06663288544759e-022 - 1.07612448196234 0.163233244072163] MF29=[-0.0144282663548714 -0.00542410818124636 5.61538479269187e-022 - 0.273943098662236 -0.212108617523474] MF30=[-0.138738023361368 3.53807734622694e-006 -1.98335729743113e-022 - 1.03177695745302 0.0566076728865548] MF31=[-0.27630345449876 0.000822403383236042 -5.11886984753064e-022 - 1.08395601228554 0.166903023864185] 88 MF32=[-0.0142770467337974 -0.0155851027667066 4.60959076955583e-022 - 0.212274261377137 -0.149832263550062] MF33=[-0.139501704462152 -8.13787228674899e-005 -1.98861305387748e-022 - 1.03466275021874 0.0567540155790804] MF34=[-0.00114140212535761 -0.0017501178569574 -5.23914923863933e-024 - 0.00616257530978748 0.00111578652920885] MF35=[-5.86059971371137e-005 0.0350419639463808 -1.31691021775514e-023 0.00385341080411334 0.00422343695428751] MF36=[-0.000654346082080189 0.000210910116017864 -9.53080203141531e-025 - 0.00468563198771975 0.000260235537506062] MF37=[0.220261881249638 -0.000331448744049112 -0.130323735234651 1.08744361501534 -0.130323735192707] MF38=[0.0112978808295927 0.00310964774519205 0.144438710630962 0.20509716980539 0.144438710679008] MF39=[0.128706387544945 -1.38115582205173e-005 -0.0510158397104172 1.03914298126503 -0.0510158397361683] MF40=[0.218868266370653 -0.000575886714570655 -0.131667372345395 1.09461690828622 -0.131667372338044] MF41=[0.0112197840553246 0.00986199746114663 0.118567715575698 0.179671781373333 0.118567715605922] MF42=[0.129279738338163 3.04041103323236e-005 -0.0511510280838205 1.04214911521409 -0.0511510280792445] MF43=[0.00159561305953783 0.00160510920473727 -0.0013476119423147 0.0112685677547858 -0.00134761194013871] MF44=[8.36415833212739e-005 -0.0278459067217783 -0.00338735137206393 - 0.00272922989350578 -0.00338735137194877] MF45=[0.000555162964865607 -9.46905808907182e-005 -0.000245150923068885 0.00481894832724281 -0.00024515092092942] MF46=[ 1.12600645392293e-020 2.59146064702886e-021 -6.50777085933625e-021 5.7462038220459e-020 -6.80715664305557e-021] MF47=[5.76893028049699e-022 -2.29599694157831e-022 -2.00523957459086e-021 9.86730128512556e-021 5.70084994485713e-021] 89 MF48=[6.71996243783951e-021 4.6110976906535le-022 -2.49553404336573e-021 5.48938501700803e-020 -2.65430082252077e-021] MF49=[9.8255859905167e-021 2.4996835525671e-023 -2.0252066689852e-021 5.82961899502198e-020 -5.96740654345533e-021 ] MF50=[5 02377036586726e-022 -2.87528570197262e-024 -2.07878680622196e-021 8.65392546060255e-021 4.59320518303025e-021] MF51=[6 07841211221842e-021 -4.68339657029822e-024 -1,13015982576662e-021 5.51898463378213e-020 -2.38693708581223e-021] MF52=[7.98201008753218e-023 8.23977576243958e-024 -3.7794619679078e-023 5.98395920431725e-022 -6.44895791865845e-023] MF53=[4.20135526082886e-024 5.45571151505902e-024 3.94371786562974e-023 - 1.22291094811302e-022 -1.35213205602259e-022] MF54=[2 69414860882848e-024 1.75542892362668e-024 -3.91141831656535e-025 2.69110811973662e-023 -1.21722882141599e-023] Appendix D Testing program for RF modules (On PC) The following program is written in Visual Basic language. Dim Situ As Variant Dim InputV As String Dim InputData As Single Private Sub Form_Load() MSComml .Por tOpen = True Situ = "A" End Sub Private Sub Form_Unload(Cancel As Integer) MSComml .Por tOpen = False End Sub Private Sub Joyst ick l_JoyMove() If Joyst ick l .XPos > 20 Then Situ = "R" End If If Joyst ick l .YPos > 20 Then Situ = "B" End If If Joyst ick l .XPos < -20 Then Situ = "L" End If If Joyst ick l .YPos < -20 Then Situ = "F" End If If Joystick!..XPos < 20 And Joyst ick l .XPos > -20 And Joyst ick l .YPos < 20 And Joyst ick l .YPos > -20 Then Situ = "S" End If End Sub Private Sub MSComml_OnComm() InputV = MSComml . Input Labe l l . Caption = InputV + Label l ,Capt ion End Sub Private Sub T imer l_T imer() If Situ = "F" Then MSComml .Output = "d" End If If Situ = "L" Then MSComml .Output = "e" End If If Situ = "R" Then MSComml . Output = "f" End If If Situ = "B" Then MSComml .Output = "g"' End If If Situ = "S" Then MSComml .Output = "h" End If If Situ = "A" Then MSComml .Output = "6" End If End Sub 92 Appendix D Testing program for RF modules (On OOpic R+) They are in the OOpic 'Basic' Language form. This program creates two oSerialX Objects. One is used to receive a 'Serial signal and the other are used to send a serial signal. 'An oD io l is used to show that while 'the oSerialX object is waiting 'For incoming serial data, the 'program flow is stopped. Dim A As New oSerialX Dim B As New oSerialX Dim C As New oDIOl Dim D As New oDIO l Dim V As New Byte Dim L As New oPWM Dim R As New oPWM Sub Main() C.IOLine = 5 D.IOLine = 6 C.Direction = cvOutput D.Direction = cvOutput B.IOLineS = 25 B.IOLineF = 18 B.Baud = cv9600 A.IOLineS = 26 A.IOLineF = 16 A.Baud = cv9600 L.PreScale=2 L.IOLine=17 R.PreScale=2 R.IOLine=18 L.Period = 79 R.Period = 79 Do 'A=B A.Value=99'c 'A.String="B" C.Invert V= B 'Cruising If V=100 Then'd L.Value=10 R.Value=10 L.Operate=l R.Operate=l Endlf 'Left Turn If V=101 Then'e L,Value=14 R.Value=10 L.Operate=l R.Operate=l Endlf 'Right Turn If V=102 Then'f L.Value=10 R.Value=14 L.Operate=l R.Operate=l Endlf 'Reverse If V=103 Then L.Value=16 R.Value=16 L.Operate=l R.Operate=l Endlf ' Stop If V=104 Then D.Invert L.Value=10 R.Value=10 L.0perate=0 R.0perate=0 Endlf Loop End Sub Appendix F Testing program for servo motors Dim A As new oPWM Sub Main() A.Value=10 A.PreScale=2 A.IOIine=l A.Period=79 Do A.Operate=l Loop End Sub The potent iometer was adjusted until the rotation of the motor stops. 96 Appendix I Program for changing addresses of ultrasonic sensors The following program is to change the address of the first of ultrasonic sensor in prototype to change its address to xEO, 'Change the address of each sonar sensor 'Below are the addresses to be changed for each sonar sensor ' EO -> 224 ' E2 -> 226 ' E4 -> 228 ' E6 -> 230 Dim A As New oI2C sub main () A.Node=112 'address of xEO right shifted/divided by 2 A.NoInc= cVTrue 'or 1 A.Mode=cv l0b i t A.width=cv8bit A.Location=0 A=160 'Hex AO A=170 'Hex AA A=165 'Hex A5 A=226 'New address to be changed to end sub When the address is changed successfully, it can be verified by applying power to the particular sonar sensor, which will indicate the new address with a series of long and short pulses of LED. 97 'Single Sonar sensor operation and measurement Dim Ver As New oByte Dim SR235 As New oI2C Spk As oSpeaker Sub main() SRF235.Node=112 1 address of the sonar sensor SRF235.Mode=cvl0bi t SRF235.NoInc = l SRF235.width=cv8bit SRF.Location = 0 Do SRF235=81 Do Ver=SRF235 Loop while Ver=255 If ((Ver<25) Or (Ver>20)) Then Spk.Beep (60757,10, 200) Loop End Sub Appendix D Testing program for digital compass Dim Compass As New oI2C ' Create the compass objects Dim Led As New oDIO l Dim Bearing As New oByte ' Store the reading Spk As oSpeaker Sub main () Setup ' Setup the LED and compass Do Compass.Location = 1 ' Address of single byte bearing Compass.Width = cv8Bit ' Compass Data is 1-byte wide. Bearing = Compass.Value ' Get the value If ((Bearing<5) Or (Bearing>250)) Then Spk. Beep(60757,100,200) Else ' Light the Led if within 5 degrees of north Spk.Beep(60757,10,200) End If Loop End Sub Sub Setup() Compass.Node = 96 ' Decimal of Hex address OxCO shifted right by 1 Compass.Mode = cvlOBit ' I2C mode is 10-Bit Addressing. Compass.Nolnc = 1 1 No increase Led.IOLine = 30 1 Pin 28 on 40 way connector Led.Direction = cvOutput End Sub Appendix I Testing program for optical encoders 'Checking optical encoder Spk As oSpeaker Dim Encoder As New oQencode Dim Speed As New 0DIO8 Sub Main() Encoder . IOL ine l = 31 ' B input Encoder.IOLine2=3C) ' A input Encoder. Operate=cvT rue Encoder.S igned=0 ' count from 0 to 65535 Do ooPIC.Delay=50 Speed=Encoder Beep Loop End Sub Sub Beep() If Encoder.Value > 3000 Then Spk. Beep(60757,10,200) End If Encoder.Value=0 End Sub 100