Italy’s Mirai Robotics raises $4.2M to build autonomous vessels for the ‘blue economy
Back to Tutorials
techTutorialbeginner

Italy’s Mirai Robotics raises $4.2M to build autonomous vessels for the ‘blue economy

March 9, 202625 views5 min read

Learn to build a basic autonomous vessel navigation system using Python. This beginner-friendly tutorial teaches fundamental concepts of maritime AI and path planning.

Introduction

In a world where software is transforming every industry, the ocean remains one of the last frontiers yet to be fully digitized. Italian startup Mirai Robotics is pioneering the development of autonomous vessels for what they call the 'blue economy' – the sustainable use of ocean resources for economic growth. In this beginner-friendly tutorial, we'll explore how to create a basic simulation of an autonomous maritime navigation system using Python. This hands-on project will teach you fundamental concepts of autonomous navigation, GPS positioning, and path planning that are central to Mirai's technology.

Prerequisites

To follow this tutorial, you'll need:

  • A computer with Python 3.7 or higher installed
  • Basic understanding of Python programming concepts
  • Internet connection for installing packages
  • Text editor or IDE (like VS Code or PyCharm)

No prior experience with robotics or maritime systems is required – we'll build everything from scratch!

Step-by-Step Instructions

1. Setting Up Your Python Environment

First, we'll create a dedicated project folder and install the required Python libraries. Open your terminal or command prompt and run:

mkdir maritime_nav_system
 cd maritime_nav_system
 python -m venv venv
 source venv/bin/activate  # On Windows: venv\Scripts\activate

Why: Creating a virtual environment isolates our project dependencies and prevents conflicts with other Python projects on your system.

2. Installing Required Libraries

Next, we'll install the libraries we'll need for our navigation simulation:

pip install numpy matplotlib

Why: NumPy will help us with mathematical calculations and array operations, while Matplotlib will visualize our vessel's path and environment.

3. Creating the Basic Vessel Class

Let's create our first Python file called vessel.py to define a basic autonomous vessel:

import numpy as np
import matplotlib.pyplot as plt


class AutonomousVessel:
    def __init__(self, x=0, y=0, heading=0):
        self.x = x  # Current x position
        self.y = y  # Current y position
        self.heading = heading  # Current heading in degrees
        self.speed = 2.0  # Speed in knots
        self.history = [(x, y)]  # Track vessel's path

    def move(self, target_x, target_y):
        # Calculate distance to target
        dx = target_x - self.x
        dy = target_y - self.y
        distance = np.sqrt(dx**2 + dy**2)
        
        # Calculate required heading
        target_heading = np.degrees(np.arctan2(dy, dx))
        
        # Adjust heading to face target
        self.heading = target_heading
        
        # Move vessel
        self.x += np.cos(np.radians(self.heading)) * self.speed * 0.1  # 0.1 time unit
        self.y += np.sin(np.radians(self.heading)) * self.speed * 0.1
        
        # Record position
        self.history.append((self.x, self.y))

    def get_position(self):
        return (self.x, self.y)

    def plot_path(self):
        x_coords, y_coords = zip(*self.history)
        plt.plot(x_coords, y_coords, 'b-', linewidth=2, label='Vessel Path')
        plt.plot(self.x, self.y, 'ro', markersize=10, label='Current Position')
        plt.xlabel('X Position')
        plt.ylabel('Y Position')
        plt.title('Autonomous Vessel Navigation')
        plt.legend()
        plt.grid(True)
        plt.axis('equal')
        plt.show()

Why: This class represents our autonomous vessel with basic navigation capabilities. We're simulating movement by calculating the direction to a target point and moving towards it.

4. Creating a Simple Navigation System

Now let's create a main script to test our vessel navigation system. Create a file called main.py:

from vessel import AutonomousVessel
import matplotlib.pyplot as plt


def main():
    # Create a vessel at starting position (0, 0)
    vessel = AutonomousVessel(0, 0)
    
    # Define target points
    targets = [(10, 5), (15, 10), (5, 15), (0, 20)]
    
    print("Starting autonomous navigation simulation...")
    
    # Navigate to each target point
    for i, (target_x, target_y) in enumerate(targets):
        print(f"Navigating to target {i+1}: ({target_x}, {target_y})")
        vessel.move(target_x, target_y)
        
    # Plot the vessel's path
    vessel.plot_path()
    
    print("Navigation complete!")

if __name__ == "__main__":
    main()

Why: This script creates a vessel, sets up a series of target points, and demonstrates how our vessel navigates from point to point autonomously.

5. Running the Simulation

Execute the simulation by running:

python main.py

Why: This command runs our main script, which creates the vessel, sets navigation targets, and visualizes the path taken.

6. Enhancing Navigation with Obstacle Avoidance

Let's improve our vessel with basic obstacle avoidance capabilities. Update your vessel.py file with the following enhanced class:

import numpy as np
import matplotlib.pyplot as plt


class EnhancedAutonomousVessel(AutonomousVessel):
    def __init__(self, x=0, y=0, heading=0):
        super().__init__(x, y, heading)
        self.obstacles = []  # List of obstacle coordinates

    def add_obstacle(self, x, y):
        self.obstacles.append((x, y))

    def avoid_obstacles(self, target_x, target_y):
        # Simple obstacle avoidance
        for obstacle_x, obstacle_y in self.obstacles:
            distance_to_obstacle = np.sqrt((obstacle_x - self.x)**2 + (obstacle_y - self.y)**2)
            
            # If obstacle is close, adjust heading
            if distance_to_obstacle < 3:  # Within 3 units
                obstacle_angle = np.degrees(np.arctan2(obstacle_y - self.y, obstacle_x - self.x))
                # Turn away from obstacle
                self.heading = obstacle_angle + 90  # 90 degrees to avoid
                
        # Move towards target
        self.move(target_x, target_y)

    def plot_with_obstacles(self):
        x_coords, y_coords = zip(*self.history)
        plt.plot(x_coords, y_coords, 'b-', linewidth=2, label='Vessel Path')
        plt.plot(self.x, self.y, 'ro', markersize=10, label='Current Position')
        
        # Plot obstacles
        if self.obstacles:
            obs_x, obs_y = zip(*self.obstacles)
            plt.plot(obs_x, obs_y, 'ks', markersize=8, label='Obstacles')
            
        plt.xlabel('X Position')
        plt.ylabel('Y Position')
        plt.title('Autonomous Vessel Navigation with Obstacle Avoidance')
        plt.legend()
        plt.grid(True)
        plt.axis('equal')
        plt.show()

Why: This enhanced version adds obstacle detection and avoidance, simulating how real autonomous vessels must navigate around obstacles like other ships or underwater structures.

7. Testing Enhanced Navigation

Update your main.py file to test the enhanced navigation system:

from vessel import EnhancedAutonomousVessel


def main():
    # Create an enhanced vessel
    vessel = EnhancedAutonomousVessel(0, 0)
    
    # Add some obstacles
    vessel.add_obstacle(5, 2)
    vessel.add_obstacle(8, 7)
    vessel.add_obstacle(12, 10)
    
    # Define target points
    targets = [(10, 5), (15, 10), (5, 15), (0, 20)]
    
    print("Starting enhanced autonomous navigation simulation...")
    
    # Navigate to each target point
    for i, (target_x, target_y) in enumerate(targets):
        print(f"Navigating to target {i+1}: ({target_x}, {target_y})")
        vessel.avoid_obstacles(target_x, target_y)
        
    # Plot the vessel's path with obstacles
    vessel.plot_with_obstacles()
    
    print("Enhanced navigation complete!")

if __name__ == "__main__":
    main()

Why: This enhanced simulation shows how our vessel would navigate around obstacles while reaching its targets, demonstrating a more realistic maritime navigation scenario.

Summary

In this tutorial, we've built a foundational simulation of an autonomous maritime navigation system. We've learned:

  • How to create a basic autonomous vessel class with position and heading
  • How to implement simple path planning to reach target coordinates
  • How to add obstacle detection and avoidance capabilities
  • How to visualize vessel movement using matplotlib

This simulation represents the core concepts behind companies like Mirai Robotics. While our system is simplified, it demonstrates the fundamental principles of autonomous navigation that are essential for building real autonomous vessels. As you continue learning, you can expand this system by adding more sophisticated sensors, communication protocols, and navigation algorithms that mirror the technology being developed in the blue economy sector.

Source: TNW Neural

Related Articles