1-Program-Logic-Formulation.pdf

Full Transcript

Maria Sheryl R. Macuha Moreno Integrated School  It refers to the process of breaking down a complex problem or task into smaller, logical steps that a computer or robot can understand and execute. It involves creating a structured plan that outlines the sequence of actions,...

Maria Sheryl R. Macuha Moreno Integrated School  It refers to the process of breaking down a complex problem or task into smaller, logical steps that a computer or robot can understand and execute. It involves creating a structured plan that outlines the sequence of actions, decisions, and conditions necessary to achieve a specific goal.  This process ensures that the desired outcome is achieved accurately and efficiently.  Solutions written in English language  Sequence of precise steps to solve the problem – no ambiguity  Finite number of steps.  It is a set of series of instruction for carrying out in particular task.  It is also a procedure to produce the required output from the given input.  Shorter solution the better * Fewer number of instructions the faster the program execution  Solution must be applicable to all possible cases (generic solution)  Don’t be too nerdy or clever. * You are the only one who can understand your solution  Be specific in outlining steps.  Task Decomposition: Robots often need to perform complex tasks that involve multiple actions and decisions. Program logic formulation helps break down these tasks into smaller, manageable steps, making it easier to implement and maintain the robot's behavior.  Algorithm Design: In robotics, algorithms outline the step-by- step instructions required to achieve a specific goal. These algorithms need to be precise and well-structured to ensure that the robot behaves as intended.  Efficiency: Effective program logic formulation helps optimize a robot's actions, minimizing unnecessary movements and decisions. This leads to more efficient use of resources and faster task completion.  Sensing and Decision-Making: Robots interact with their environment through sensors and actuators. Program logic guides how robots interpret sensor data, make decisions based on that data, and perform corresponding actions.  Autonomy: Well-formulated program logic enables robots to operate autonomously without constant human intervention. Robots can follow pre-defined instructions to accomplish tasks without continuous manual control.  Problem Solving: Robotics often involves solving complex real- world problems. Program logic formulation allows engineers and programmers to devise systematic solutions that robots can execute reliably.  Adaptability: Program logic can include conditional statements that allow robots to adapt to changing situations. For instance, a robot might modify its behavior when faced with obstacles or environmental changes.  Testing and Debugging: By breaking down robotic tasks into smaller steps, it becomes easier to identify and fix errors in the programming. Debugging is more manageable when each step's logic is well-defined. ALGORITHM PROGRAM  A step by step problem  A program is a set of solving procedure instructions which are  A sequence of instruction commands to computers that tell how to solve a to perform specific particular problem. operations on data.  A set of instructions for solving a problem,  Instructions within a especially on a computer. program are organized in  A computable set of steps such a way, when the to achieve a desired result. program is run on a computer; it results in the  Written in pseudo code or solution of a problem. flow chart  Written in any programming language  Problem Solving: Robots encounter various tasks and challenges, such as navigating through an environment, picking and placing objects, recognizing obstacles, or planning a path to reach a goal. Algorithms provide the means to tackle these problems by breaking down complex tasks into smaller, manageable steps.  Instructions: An algorithm provides a series of precise instructions that guide a robot's behavior. These instructions can involve sensing the environment through sensors, making decisions based on that sensory input, and then executing appropriate actions.  Sensory Input: Robots use sensors like cameras, lidar, ultrasonic sensors, and more to perceive their surroundings. Algorithms process the data from these sensors to extract meaningful information, such as identifying objects, recognizing obstacles, measuring distances, and detecting changes in the environment.  Decision Making: Once the sensory data is processed, algorithms enable robots to make decisions. For example, a robot navigating through a cluttered space might use an algorithm to decide whether to turn left or right based on obstacle detection.  Path Planning: Algorithms play a crucial role in determining the optimal path a robot should take to reach a destination while avoiding obstacles. This involves algorithms like A* (A-star) for searching and finding the most efficient route.  Control and Actuation: Algorithms control the robot's actuators (motors, joints, wheels) to execute physical movements and actions. For instance, algorithms can dictate the precise movement of a robotic arm to pick up an object or adjust the speed and direction of a wheeled robot.  Learning and Adaptation: In more advanced robotics, machine learning algorithms can be employed to enable robots to learn from experience and adapt their behavior over time. Reinforcement learning, neural networks, and other AI techniques can help robots improve their performance through continuous interaction with their environment.  Localization and Mapping: Algorithms used in simultaneous localization and mapping (SLAM) help robots build maps of their environment while simultaneously tracking their own position within that environment. This is crucial for navigation and exploration tasks.  Communication and Collaboration: In multi-robot systems, algorithms facilitate communication and collaboration between robots. They can coordinate tasks, share information, and distribute work efficiently to achieve a common goal.  Your goal is to determine how many times a name occurs in a list of names  Algorithm 1. Get the list of names 2. Get the name being checked 3. Set a counter to 0 4. Do the following for each name on the list: * Compare the name on the list to the name being checked, and if the names are the same, then add one to the counter 5. Answer is the number indicated by the counter  Imagine you have an unsorted list of random numbers. Your goal is to find the highest number in this list.  Algorithm 1. Get the list of the numbers. 2. Assume that the first number is the largest number in the list 3. Look at the next number, and compare it with the largest number 4. If this next number is larger, then make that the new largest number you've seen so far. 5. Repeat steps 2 and 3 until you have gone through the whole list.  Structured English  Uses key-words for control and structure elements  Suits “verbal” thinkers  Written in a text editor or word processor  A mixture of natural language and symbols, terms (Read, input, enter, write, output, print)  An outline of a program, written in a form that can easily be converted into real programming statements  Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules.  It is simply one step - an important one - in producing the final code.  It enables the programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language.  You can write pseudocodes without even knowing what programming language you will use for the final implementation.  Pseudocode can almost be classified as half- code, half-text.  Used by a programmer to outline the algorithms he or she has written, before they are actually translated into code.  pseudocode to ask the computer to input two numbers, and then print out their sum 1. Get value of A 2. Get value of B 3. C = A + B 4. Display the value of C 1. Receive Input (read or get ) 2. Output (Print, Write, Put Out, Output or Display) 3. Arithmetic: + (add), - (subtract), * (multiply), / (divide) 4. Assign a value to a variable (storage location) 5. Compare two values, then select a course of action 6. Repeat a group of actions  Diagrammatic, with minimal pseudo code  Shapes represent control and structure elements  Arrows between shapes show progression  It is a graphical representation in the solution to the problem in w/c symbol represents system plan, hardware and dataflow. 1. System flowchart – it is a graphic representation of the procedures involved in converting data on input media to data on input media to data in output form. 2. Program flowchart – it describes graphically in detail logical operations and steps within a program and the sequence in which steps are to be executed for the transformation of data to produce the needed output.  Terminal Start / Stop Indicates the starting and stopping points in the flowchart  Input/ Output instructions Input means to enter the data into the computer or to use the computer to read the available data from the magnetic disk  Process Used for data processing operations The main requirements of the problem are usually done here. E.g. Computation of Average; Assignment of the value to the variable  Decision Conditions If the condition is true, the path marked TRUE is to be followed. If the condition is false, the path marked FALSE is to be followed  Arrowheads/Arrows are used to direct the flow of Flow lines the flowchart.  Connector It is used as a continuation symbol of the flowchart in a page. It is also used to indicate the point of entry and the point of exit of repetition  Steps are performed in a strictly sequential manner, each step being executed exactly once. Start Q = 0 INPUT A, B Q = A * B PRINT Q Stop  One of several alternatives is selected and executed. It involves the use of decision based on the given condition. It uses decision block or the diamond-shaped block. Alternative actions are represented by the processing block. Start INPUT N N

Use Quizgecko on...
Browser
Browser