Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

 Interacting with the environment

Computer systems have  to communicate with  the world around them,  getting information about  the external world, and  taking  actions  to change the world. The world is dynamic, so that as the machine is calculating, the world is modifying, needing future computation to take to the new part of the world.

There  are  a variety of different paths  to manage computations that  communicate with  a  outer world. Usually speaking, such a calculation requires  to:

1.  get details from sensors,

2.  perform calculation, remembering some of the results, and

3.  take appropriate actions  to modify  the outer world.

 

 

 

 

1.3.1.1 Sequential

 

The most  immediately style  for developing a program that  communicates with  the world is the basic imperative style, in which  the program provides a sequence of 'instructions' to the computer it is controlling. A library of special procedures is described, some of which read details from the sensors  and  others  of which  cause reactions  to be operated.

In this model,  we should  usually write  a program that  goes  an idealized robot  in a square, if there is area in front of it.

if noObstacleInFront:

 moveDistance(1)

turnAngle(90)

moveDistance(1)

turnAngle(90)

moveDistance(1)

 turnAngle(90)

 moveDistance(1)

turnAngle(90)

 

The related  problem with  this model of programming is that  the programme has to check the sensors  sufficiently frequently. If the robot  examine for free space in front, and  then  starts  rolling, it can  turn  out that  a subsequent sensor  reading will give  that  there is something in front  of the robot,  either  because  someone gone in front  of it or because  the last reading was erroneous. It is rigid  to have the discipline, as a programmer, to identify to check  the  sensor  situations frequently enough, and  the  answering programs can be quite difficult to understand and read.

 

 

 

For the robot rolling toward the light, we can  write a program like this:

while lightValue < desiredValue:

moveDistance(0.1)

This would have the robot creep up, one by one, toward the light. We may  want  to change it so that the robot goes to a distance that was correlated to the difference between the desired light values and current.  However, if it takes bigger  steps, then mean while the time that it is rolling it will not be sensitive to possible  modification in the light number  and may not  react immediately to them.

 

1.3.1.2 Event-Driven

User-interface function are usually best managed differently, as event-driven programs. In that case, the program is defined as a collection  of functions that  are related to particular function that  can give  place.  So, for example, there  may  kinds  into  a text area,  or when  the  temperature of a reactor  goes  too high. An "event loop"  executes  continuously, examine  to see whether any  of the triggering function  have occurred, and, if they have, calling the associated function.

 

1.3.1.3 Transducer

An alternative view  is that  programming a machine that  communicates with  an external world is like creating a transducer with  internal state.   Think  of a transducer as a operating box that  executes continuously. At normal intervals,  the transducer takes  all of the  sensors,  does  a short  amount of calculation, saves  some  numbers  it will require  for the  next calculation, and then creates output values  for the actions.

This calculations occur over  and over   again.   Complex behaviour may rise  out  of the temporal functions of outputs and inputs.

 

def step():

distToFront = min(frontSonarReadings)

motorOutput(gain * (distToFront - desiredDistance), 0.0)

 

Executed normally, this  program will automatically calculate the robot's  velocity to be proportional  to the free memory in front of it.

The basic  problem with  the  transducer method is that  it may be very difficult to do  programs  that  are fundamentally sequential.

 

Python, Programming

  • Category:- Python
  • Reference No.:- M9505984

Have any Question?


Related Questions in Python

Assignment1 utilising python 3 build the following

Assignment 1. Utilising Python 3 Build the following regression models: - Decision Tree - Gradient Boosted Tree - Linear regression 2. Select a dataset (other than the example dataset given in section 3) and apply the De ...

Below zero - ice cream storethe local ice-cream store needs

Below Zero - ice cream store The local ice-cream store needs a new ordering system to improve customer service by streamlining the ordering process. The manager of the store has found that many orders are incorrect and s ...

Environment setupthe first mini project will be based on

Environment Setup The first mini project will be based on Ladder Logic programming. We will be using Schneider Electric's IDE called SoMachine Basic to do the programming. The latest ver- sion of SoMachine Basic for Wind ...

Python programming assignment -you first need an abstract

Python Programming Assignment - You first need an abstract base class, called, Account which has the following attributes and methods: accountID: This attribute holds the ID assigned the account , if not provided set to ...

In this programming assignment you will write a client

In this programming assignment, you will write a client pingprogram in Python. Your client will send a simple ping message to a server, receive a correspondingpong message back from the server, and determine the delay be ...

Question write a python program with a graphical user

Question: Write a python program with a graphical user interface that will allow a user to create a custom pizza which they wish to order. At minimum, the user should be able to choose the size of the pizza, the type of ...

Sieve of eratosthenes in pythonthe goal is to find all the

Sieve of Eratosthenes (in Python) The goal is to find all the prime numbers less than or equal to some natural number maxn. We have a list that tells us if any of the numbers 0..maxn are "marked". It can be an array of b ...

A software company sells a package that retails for 99

A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program using python t ...

Lab assignment -background - we have discussed in detail

Lab Assignment - Background - We have discussed, in detail, the function of Stacks and Queues and how they are specifically implemented in Python. To get a better understanding of the utility of these data structures, we ...

Part i the assignment filesone of the most important

Part I: The Assignment Files One of the most important outcomes of this assignment is that you understand the importance of testing. This assignment will follow an iterative development cycle. That means you will write a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As