Download Prospectus


How Robots Learn: Understanding the Main Programming Methods

Go-to-goal behaviour

The Go-to-Goal Behavior is a fundamental behaviour in mobile robot programming that guides a robot to move towards a predefined target position using basic control principles. It assumes that the environment is obstacle-free, allowing the robot to calculate a direct path to the goal. This type of behaviour can be implemented effectively using Python and relies on odometry, reference vectors, and simple angular control.

, How Robots Learn: Understanding the Main Programming Methods

Current Position and Goal Coordinates: The robot’s current position is determined using odometry, which updates based on wheel encoder data or other positional tracking methods. The goal coordinates are known ahead of time and are defined in the robot’s world or reference frame.

Vector to Goal: The vector pointing from the robot’s current position to the goal is crucial for guiding its movement. This vector can be computed using the differences between the goal and current position coordinates:

V goal = ( x goal – x current, y goal -y current)

In the robot’s local reference frame, the vector gives a direction the robot should move toward.

Angular Control (Turning Rate (ω): To align the robot with the goal, we calculate the angle difference between the robot’s current heading and the desired heading (toward the goal). The robot adjusts its turning rate(ω ) (angular velocity) to minimise this difference:

      Δθ = θ goal – θ current           ( where θ is the angle)

The robot rotates until the heading angle aligns with the vector to the goal (Δθ = 0) 

Linear Control (Forward Velocity (v): Once the robot is facing the goal, the control system commands it to move forward with a velocity (v). The forward velocity is applied until the robot reaches the goal, which is determined by checking the distance between the robot’s current position and the goal. When the distance is close to zero, the robot stops.

Example of python code

, How Robots Learn: Understanding the Main Programming Methods

Trajectory: With no obstacles, the robot would follow a smooth trajectory towards the goal. If the robot’s initial heading is not aligned with the goal, it will first rotate to face the goal and then move forward. The path may resemble an arc, especially if there’s a large initial angular error.

Extensions: Obstacle Avoidance: In real environments, obstacles may block the direct path to the goal. In such cases, additional behaviours, like obstacle avoidance, need to be layered on top of the go-to-goal behaviour, dynamically adjusting the reference vector.

Avoidance behaviour

The Avoid-Obstacles Behaviour is a critical behaviour in robotics that enables a robot to safely navigate through an environment by detecting and avoiding obstacles while moving toward its goal. This behaviour is often used in conjunction with other behaviours (such as go-to-goal) in a behaviour-based robotics architecture. 

In the avoid-obstacles behaviour, the robot continuously uses its sensors to scan the environment, identify potential hazards (like walls or objects), and then adjust its movement to prevent collisions

, How Robots Learn: Understanding the Main Programming Methods

Key Concepts of Avoid-Obstacles Behaviour:

Obstacle Detection : The robot uses sensors (such as infrared, ultrasonic, or LIDAR) to detect nearby obstacles. These sensors measure the distance between the robot and the surrounding objects in the environment. The robot identifies when it’s approaching an obstacle and changes its course.

Avoidance Strategy: The robot calculates a new direction or velocity to steer away from the detected obstacle. A common technique involves adjusting the robot’s heading angle to steer around the obstacle, while also considering the goal direction to maintain some level of progress toward the goal.

Reactive Behaviour: The avoid-obstacles behaviour is usually reactive, meaning the robot reacts in real time to sensor inputs without pre-planning its path. This allows for dynamic responses in unknown or changing environments.

Combining with Other Behaviours: This behaviour often works in combination with the go-to-goal behaviour. If there is no obstacle, the robot moves toward its goal. When an obstacle is detected, the avoid-obstacles behaviour takes precedence, temporarily overriding the go-to-goal behaviour to prevent a collision.

Programming an Avoid-Obstacles Behaviour In this example, we will implement a simple obstacle avoidance behaviour using sensor data to detect obstacles in front of the robot and adjusting its direction accordingly.

, How Robots Learn: Understanding the Main Programming Methods
, How Robots Learn: Understanding the Main Programming Methods
, How Robots Learn: Understanding the Main Programming Methods

Trajectory Behaviour: When running the avoid-obstacles behaviour, the robot would typically follow an adaptive trajectory that curves or zig zags around obstacles. The path taken depends on the sensor data and the available space. Without obstacles, the robot would move forward in a straight line, but when obstacles are detected, it alters its heading to avoid collisions, while also making some progress toward its goal.

Combining with Go-to-Goal: In practice, robots often combine go-to-goal and avoid-obstacles behaviours. For instance:

  • The robot moves toward the goal as long as there are no obstacles in the way.
  • When an obstacle is detected, the robot temporarily switches to the avoid-obstacles behaviour to navigate around it.
  • After avoiding the obstacle, the robot resumes its path toward the goal.

This combination can be achieved by giving priority to the avoid-obstacles behaviour when necessary and reverting to the go-to-goal behaviour when the obstacle is no longer a threat.

Extensions: Advanced Obstacle Avoidance: More advanced techniques, such as potential fields or vector field histograms, can be used for smoother avoidance behaviour by calculating repulsive forces from obstacles.

Path Planning: In complex environments, path planning algorithms like A* or Dijkstra’s can be used in conjunction with real-time obstacle avoidance for optimal navigation.

Obstacle Mapping: Some robots build maps of their environment using sensor data, allowing for more informed decisions about how to navigate around obstacles.

This avoid-obstacles behaviour provides the foundation for safe navigation in unknown environments and can be tailored to the complexity of the robot’s operational environment.

Hybrid Automata

Hybrid Automata (or Behaviour State Machine) is a powerful approach used in robot programming to manage complex behaviours that require both continuous control (e.g., motion) and discrete decision-making (e.g., state changes). In this method, the robot’s control system is modelled as a state machine, where the robot switches between different behaviours based on the state of the environment and internal conditions.

, How Robots Learn: Understanding the Main Programming Methods

A Hybrid Automaton combines:

Discrete State Transitions: The robot moves between different states (or behaviours) based on specific conditions or events.

Continuous Control: Each state has its own control logic, allowing continuous execution of tasks until a transition to another state occurs.

Key Concepts of Hybrid Automata

States: A state represents a particular behaviour the robot is executing. For example, go-to-goal, avoid-obstacles, or wander.Each state defines how the robot acts in a given situation.

Transitions: Transitions are the rules that dictate when the robot should move from one state to another. 

Transitions can be triggered by:

  •  Sensor inputs: detecting an obstacle or reaching the goal.
  •  Timeouts: staying in a state for a certain amount of time.
  •  Events: user commands or internal signals.

Control in Each State: While in a given state, the robot performs continuous control actions such as adjusting speed, heading, or interacting with its environment. These actions are defined by the control algorithm associated with each state.

Behaviour State Machine: The entire system can be represented as a state machine with discrete states and transitions between them. Each state encapsulates a behaviour, and the robot’s actions change based on which state it is in.

Benefits of Hybrid Automata:

Each state is a separate behaviour, making the system easy to understand and modify. The robot can adapt in real-time to changing conditions, like new obstacles or goal positions. More states and behaviours can be added for additional capabilities, such as docking, charging, or following.

Real-World Application: Hybrid automata are widely used in autonomous mobile robots, industrial robots, drones, and any robotic systems that require flexible behaviour switching in dynamic environments. For example, a self-driving car might use states like “cruise,” “avoid-pedestrians,” and “stop-at-light.”

The Hybrid Automata (Behaviour State Machine) approach allows for effective, structured programming of complex, real-time behaviours in mobile robotics, ensuring that the robot can switch between behaviours based on environmental and internal events.

Follow-Wall Behaviour

“Follow-wall” behaviour in robot programming is a common task in navigation systems, where a robot is required to navigate an environment while maintaining a specific distance from a wall. This behaviour is often employed in situations where the robot needs to explore or traverse environments without crashing into obstacles but also without straying too far away from them.

, How Robots Learn: Understanding the Main Programming Methods

This is an overview of methods commonly used for implementing follow-wall behaviour in robotics:

Reactive Control: In reactive control, the robot uses its sensors to detect the wall and adjust its movements in real-time. The robot can follow the wall by either staying parallel to it or moving at a constant distance from the wall. 

Commonly used sensors include:

  • Ultrasonic Sensors: These measure the distance to nearby walls and obstacles.
  • Infrared Sensors: used for proximity sensing, especially for short distances.
  • LIDAR: provides precise distance measurements, often used in more advanced wall-following behaviours.

The key concept here is to have the robot continuously adjust its trajectory based on the data received from the sensors. For example, if the robot gets too close to the wall, it steers slightly away, and if it gets too far, it steers closer.

, How Robots Learn: Understanding the Main Programming Methods

Proportional Control (PID)

More advanced wall-following can use Proportional-Integral-Derivative (PID) control. This method provides smoother adjustments to the robot’s steering and movement based on the difference between the measured distance and the desired distance from the wall.

Proportional Term (P): Adjusts the steering angle based on the difference between the actual and desired distance from the wall.

Integral Term (I): Accounts for accumulated errors over time to eliminate steady-state errors.

Derivative Term (D): Helps to reduce overshooting or oscillations by considering the rate of change of the error.

, How Robots Learn: Understanding the Main Programming Methods

Potential Fields

In this approach, the robot navigates the environment by considering the wall (or obstacles) as “repulsive forces” that push the robot away, while open spaces or target locations exert “attractive forces” that pull the robot toward them. This method allows the robot to balance the forces to maintain a smooth path along the wall while avoiding collisions.

, How Robots Learn: Understanding the Main Programming Methods

Bug Algorithms

Bug algorithms, such as Bug1 and Bug2, are classic approaches to obstacle avoidance. In these methods, the robot uses simple rules to follow the perimeter of an obstacle (e.g., the wall) until it can either reach its goal or continue its journey. 

For example, in Bug2:

   1. The robot moves directly toward the goal until it encounters a wall or obstacle.

   2. The robot then follows the wall in one direction until it finds a point where it can resume moving directly toward the goal.

Simultaneous Localization and Mapping (SLAM)

For more advanced and autonomous robots, SLAM can be used to navigate while mapping the environment in real-time. The wall-following behaviour can be integrated as part of the robot’s strategy to explore unknown areas while building a map of the surroundings.

This approach typically uses LIDAR, cameras, or other sensors to gather information about the environment, and the robot processes this data to localise itself and understand where the walls and obstacles are located.

The robot can follow the wall on either its left or right side. The control logic will be symmetric depending on which side the wall is on. The robot’s ability to maintain a consistent distance from the wall depends on the accuracy of the sensors and the responsiveness of the control system. The robot’s speed will influence how quickly it can react to changes in the wall’s position or curvature. Handling curved walls may require the robot to adjust its behaviour more frequently, especially with reactive or PID control.

Common Applications:

  • Maze Solving: Robots navigating through mazes often use follow-wall behaviour to find the exit or explore.
  • Vacuum Robots: Many robotic vacuum cleaners use this technique to clean efficiently along walls and edges.
  • Autonomous Vehicles: In certain scenarios, autonomous vehicles use wall-following or lane-following techniques to navigate narrow passages or avoid obstacles.

Each method has its own strengths depending on the application, sensor quality, and the complexity of the environment.


Interested in our Electrical Engineering Courses?

At iLearn Engineering®, we offer a diverse range of online accredited electrical engineering courses and qualifications to cater to different academic and career goals. Our courses are available in varying credit values and levels, ranging from 40 credit Engineering Diplomas to a 360 credit International Graduate Diploma.

Short Courses (40 Credits)

A selection of our more popular 40 credit electrical diplomas…

Diploma in Electrical and Electronic Engineering

Diploma in Electrical Technology

Diploma in Electronics

Diploma in Renewable Energy (Electrical)

First Year of Undergraduate (Level 4 – 120 Credits)

Higher International Certificate in Electrical and Electronic Engineering

First Two Years of Undergraduate (Level 5 – 240 Credits)

Higher International Diploma in Electrical and Electronic Engineering.

Degree equivalent Graduate Diploma (Level 6 – 360 Credits)

 International Graduate Diploma in Electrical and Electronic Engineering

All Electrical and Electronic Courses

You can read more about our selection of accredited online Electrical and Electronic Engineering courses here.

Complete Engineering Course Catalogue (all courses)

Alternatively, you can view all our online engineering courses here.

Recent Posts

Types of Actuators: Principles, Mechanisms, and Applications

Types of Actuators: Principles, Mechanisms, and Applications Thermal actuators Thermal actuators convert temperature changes into linear movement or “stroke” by utilising the expansion and contraction of thermally sensitive materials within them.  They integrate both temperature sensing and actuation, making them valuable for various applications, including: 1. Temperature control 2. Fluid mixing and diverting 3. Freeze […]

Thermoelectric Transducers: Principles, Types, and Applications

Thermoelectric Transducers: Principles, Types, and Applications Introduction A temperature transducer is a device that converts a thermal quantity (temperature) into another physical quantity, such as mechanical energy, pressure, or an electrical signal, to allow for measurement or control. This conversion enables temperature to be easily monitored and utilised in various applications. A thermocouple is a […]

From Power Stations to Your Home: The Role of Transformers

From Power Stations to Your Home: The Role of Transformers Introduction Since their invention in the late 19th century, electromagnetic transformers have become a cornerstone of electrical power systems. Operating on Faraday’s law of electromagnetic induction, a transformer enables efficient energy transfer between circuits, typically to adjust voltage levels for generation, transmission, and utilization. Whether […]