香港理工大学:Department of ELECTRONIC AND INFORMATION ENGINEERING(Controlling Robot Car by Wireless Sensor)

●●● 3. Controlling Robot Car by ●●●● ●●●●● ●●●● ●●●●● Wireless sensor ●●●● o The ultimate objective of the project is to control the car motion using the steering wheel o The only connection between the steering wheel and car racing system is the wireless marker attached to it o We have to make use of the marker data to control the car motion Reference: 1.J.M. Hart, Windows System Programming, 3rd Ed, Addison-Wesley, 2005,Ch.7,12 Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
1 3. Controlling Robot Car by Wireless Sensor ⚫ The ultimate objective of the project is to control the car motion using the steering wheel ⚫ The only connection between the steering wheel and car racing system is the wireless marker attached to it ⚫ We have to make use of the marker data to control the car motion Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun Reference: 1. J.M. Hart, Windows System Programming, 3rd Ed., Addison-Wesley, 2005, Ch.7, 12

●●● Problem of the previous ●●●● ●●●●● ●●●● ●●●●● Program ●●●● e The markers data are obtained by calling the function Latus: UpdatePO ( o In the previous program, Latus:: UpdatepO ( are called inside the functions EIE330ProjectApp: renderInfo and EIE330ProjectApp: process Calculation) The above 2 functions will be called by ogre only when it updates the le screen If the graphics is complex, the update rate can be very slow, e.g. 20 frames/sec or slower It means that the markers data can only be obtained in such a slow rate Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
2 Problem of the Previous Program ⚫ The markers’ data are obtained by calling the function Latus::UpdatePO() ⚫ In the previous program, Latus::UpdatePO() are called inside the functions EIE330ProjectApp::renderInfo and EIE330ProjectApp::processCalculation() ⚫ The above 2 functions will be called by Ogre only when it updates the screen ⚫ If the graphics is complex, the update rate can be very slow, e.g. 20 frames/sec or slower ⚫ It means that the markers’ data can only be obtained in such a slow rate Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun

●●● ●●●● ●●●●● Update ●●●● Ogre main ●●●●● screen ●●●● program process Calculation If the screen is mLatus:: UpdatePO () updated once per 100ms. markers data can only be renderInfo o) obtained in the same rate, i. e mLatus:: UpdatePO( once per 100ms Finish update Department of ELECTRONIC AND INFORMATION ENGINEERING screen 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
3 Ogre main program processCalculation() { : mLatus::UpdatePO() : } Update screen renderInfo() { : mLatus::UpdatePO() : } Finish update screen : If the screen is updated once per 100ms, markers’ data can only be obtained in the same rate, i.e. once per 100ms Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun

●●● ●●●● ●●●●● Solution -Multithreading ●●●● ●●●●● ●●●● Get Markers Ogre main Update data program screen UpdatePOO proces s calculation o renderInfoo Routine and b ru at the Routine B same time Routine a (virtually) Finish update screen
4 Solution - Multithreading Ogre main program processCalculation() { : } Update screen Finish update screen : renderInfo() { : } Routine A UpdatePO() { : } Get Markers’ data Finish : Routine B Routine A and B run at the same time (virtually)

●●● ●●●● ●●●●● ●●●● ●●●●● Processes and threads ●●●● ●●●● In Windows, usually a process will be generated when an application is executed When an application is executed m times, m processes will be generated, each with a different process ID A Windows process contains its own independent virtual address space with both code and data Each process contains one or more independently execution unit, called threads The Windows thread is the basic executable unit A process can Create new threads within the processes Create new, independent processes Manage communication and synchronization between these objects Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
5 Processes and Threads ⚫ In Windows, usually a process will be generated when an application is executed ⚫ When an application is executed m times, m processes will be generated, each with a different process ID ⚫ A Windows process contains its own independent virtual address space with both code and data ⚫ Each process contains one or more independently execution unit, called threads ⚫ The Windows thread is the basic executable unit ⚫ A process can ⚫ Create new threads within the processes ⚫ Create new, independent processes ⚫ Manage communication and synchronization between these objects Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun

●●● ●●●● ●●●●● ●●●● ●●●●● A Process And its threads ●●●● Windows Process 1 Winword Process 5 Process 2 Lab3 Threads Notepad Process 3 Process 4 Winword+ Excel Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
6 A Process And Its Threads Windows Winword Process 1 Notepad Process 2 Winword Process 3 Excel Process 4 Process 5 Threads Lab3 Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun

●●● ●●●● ●●●●● ●●●● ●●●●● Why Threads? ●●●● In normal execution, a program always needs to wait Wait for user input, wait for screen display, wait for file access etc It is unwise to require programs to execute one after the finish of another Program B can make use of the waiting time of program Ato start its execution as long as program B is not waiting for the result from programA It was first proposed to achieve this by having multiple processes However, it was soon found that the overhead(e.g. the time required) for switching between processes is very high Besides, processes are not tightly coupled to one another, it is difficult to share resources, such as open files They motivate the idea of further dividing a process into smaller units. i. e, threads
7 Why Threads? ⚫ In normal execution, a program always needs to wait ⚫ Wait for user input, wait for screen display, wait for file access, etc. ⚫ It is unwise to require programs to execute one after the finish of another ⚫ Program B can make use of the waiting time of program A to start its execution as long as program B is not waiting for the result from program A ⚫ It was first proposed to achieve this by having multiple processes ⚫ However, it was soon found that the overhead (e.g. the time required) for switching between processes is very high ⚫ Besides, processes are not tightly coupled to one another, it is difficult to share resources, such as open files ⚫ They motivate the idea of further dividing a process into smaller units, i.e. threads

●●● ●●●● ●●●●● How Threads are executed? ●●●● ●●●●● ●●●● o a computer has only one CPU, which can execute one program at a time Hence, in reality, threads are not executing at the same time, but alternatively one after the other For a multithreading system, a thread has at least the following thi g ree states Start Finish execution e RI unning execution Sleeping Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
8 ⚫ A computer has only one CPU, which can execute one program at a time ⚫ Hence, in reality, threads are not executing at the same time, but alternatively one after the other ⚫ For a multithreading system, a thread has at least the following three states: Ready Running Sleeping Start execution Finish execution Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun How Threads Are Executed?

●●● ●●●● ●●●●● ● Ready state ●●●● ●●●●● ●●●● All threads that are ready to execute but without the CPU are at the ready state If there is only 1 CPU in the system, all threads except one are at the ready state ● Running state The thread that actually possesses the CPU is at the running state If there is only 1 CPU in the system, at most there is only one thread is at the running state Sleeping state The process that is waiting for other resources e.g. /0 or a preset time, is at the sleeping state Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
9 ⚫ Ready state – All threads that are ready to execute but without the CPU are at the ready state – If there is only 1 CPU in the system, all threads except one are at the ready state ⚫ Running state – The thread that actually possesses the CPU is at the running state – If there is only 1 CPU in the system, at most there is only one thread is at the running state ⚫ Sleeping state – The process that is waiting for other resources, e.g. I/O or a preset time, is at the sleeping state Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun

●●● ●●●● ●●●●● ●●●● ●●●●● ●●●● Threads will alternatively get into the CPU one after the other(called the round robin scheme) At the time that a thread is selected to be in"the cPu It goes from ready state to running state After that, it will be swapped out It goes from running state back to ready state o Or it may due to the waiting of a preset time It goes from running state to sleeping state ● When time-up It goes from sleeping state to ready state Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
10 ⚫ Threads will alternatively get into the CPU one after the other (called the round robin scheme) ⚫ At the time that a thread is selected to be “in” the CPU – It goes from ready state to running state ⚫ After that, it will be swapped out – It goes from running state back to ready state ⚫ Or it may due to the waiting of a preset time – It goes from running state to sleeping state ⚫ When time-up – It goes from sleeping state to ready state Department of ELECTRONIC AND INFORMATION ENGINEERING 3. Controlling Robot Car by Wireless Sensor by Dr Daniel Lun
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 山东大学控制科学与工程学院:《现代控制理论基础》课程教学资源(PPT课件)绪论.ppt
- 贵州电子信息职业技术学院:《自动控制原理 Principles of Automatic Control》课程教学资源(PPT课件讲稿)课程简介、第一章 自动控制系统的基本概念(主讲:朱高伟).ppt
- 《人机交互 human-computer interaction》PPT讲稿:chapter 2 the computer.ppt
- 《人机交互 human-computer interaction》PPT讲稿:chapter 3 the interaction.ppt
- 《人机交互 human-computer interaction》PPT讲稿:chapter 9 evaluation techniques.ppt
- 浙江大学信息学院:《控制仪表和计算机控制装置》课程教学资源(PPT课件)CP1H系列PLC简介(小型高功能PLC).ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)§2-2 三相全控桥可控整流.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)6.2 基本斩波电路工作原理.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.2 有源逆变应用电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.1 有源逆变电路的工作原理.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.4 负载换流式逆变电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.6 脉宽调制(PWM)型逆变电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.3 无源逆变及基本电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第五章 逆变电路 5.5 电压型及电流型逆变电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)3.3 单相交流调压电路.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第四章 全控电力电子器件 4.4 绝缘栅双极晶体管.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第四章 全控电力电子器件 4.3 电力场效应晶体管.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第一章 晶闸管、功率二极管及单相可控整流电路 §1-4 单相半波可控整流.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第四章 全控电力电子器件 4.1 门极可关断晶闸管.ppt
- 《电力电子应用技术》课程电子教案(PPT教学课件)第一章 晶闸管、功率二极管及单相可控整流电路 §1-5 单结晶体管触发电路.ppt
- 三峡大学:《电子技术基础 Fundamental of Electronic Technology》课程教学资源(PPT课件讲稿)05 场效应管放大电路.ppt
- 北京化工大学:用冲击电流计测电容和高电阻(PPT实验讲稿).ppt
- 淄博职业学院:搅拌机电动机转动控制线路设计(学习情境PPT).ppt
- 电子产品防护设计(PPT讲稿)可靠性、电子产品的防护措施、电子电气设备散热及防护、减振和缓冲.ppt
- 河南科技大学:《电子工艺实习》课程教学资源(PPT讲稿)特种加工(电火花基本知识).ppt
- 淄博职业学院:《工厂供配电技术》课程教学资源(PPT课件讲稿)工厂供配电系统的认识.ppt
- 上海交通大学:《自动控制理论》课程教学资源(PPT课件讲稿)Chapter 05 根轨迹分析法 Root Locus.ppt
- 四川大学:《自动控制原理 Automatic Control Principles》课程教学资源(PPT课件讲稿)第十章 非线性控制系统.ppt
- CEG2400 - Microcomputer Systems:Feedback control of motors, based on Demo2017.c and.pptx
- 广东水利电力职业技术学院:机械手的PLC控制系统设计.ppt
- 《家用电器维修技术》课程教学资源(PPT讲稿)第3章 厨房电器 3.2 电烤箱 3.3 电炒锅 3.4 微波炉.ppt
- 北京科技大学:《自动控制原理》课程教学资源(PPT课件讲稿)第五章 线性系统的根轨迹法.ppt
- 《电路理论基础》课程PPT教学课件讲稿(电路分析基础)第8章 三相电路.ppt
- 成都理工大学:《自动控制原理 Principles of Automatic Control》课程电子教案(PPT课件讲稿)第2章 自动控制系统的数学模型.ppt
- 西安电子科技大学:《自动控制原理》课程教学资源(PPT课件讲稿)第一章 自动控制系统的基本概念(主讲:王晓甜).pptx
- 北京机械工业学院:《测试技术与实验方法》课程教学资源(PPT课件讲稿,共十一章).ppt
- 上海交通大学:《数学物理方法》课程教学资源(PPT课件)第六章 保形映射.ppt
- 《自动控制原理》课程教学资源(PPT课件讲稿)总结与复习(频率响应综合法、状态空间方法——现代控制理论、离散控制系统、非线性控制系统).ppt
- 《电力电子技术》课程教学资源(PPT课件讲稿)第四章 逆变电路(无源逆变).ppt
- 西安电子科技大学:《自动控制原理》课程教学资源(PPT课件讲稿)第三章 线性系统的时域分析.pptx