Avatar The Society of Robotics and Automation is a society for VJTI students. As the name suggests, we deal with Robotics, Machine Vision and Automation

ROSfunc

Use functional programming to implement a natively parallel and fault tolerant ROS-like software stack.

Richa Sawant

ROSfunc

Picture a robot on the dance floor, its moves a mismatched chaos reminiscent of a hipster square dancing. Enter ROS (Robot Operating System), the dance instructor striving to bring order to the spectacle. Yet, even with ROS, the dance isn’t always flawless. Now, imagine functional programming as the cool new dancer in town, arriving with a knack for parallelism and fault tolerance. It’s like watching the robots finally sync their steps, leaving behind the days of crashing catastrophes. Let’s delve into how functional programming adds rhythm and reliability to the ROS dance

Why Functional Programming Rocks the Robot World??

  • Parallelism: Functional programming encourages writing code that is inherently parallelizable. Since functional programs avoid shared mutable state, multiple computations can occur simultaneously without the need for complex synchronization mechanisms. This is crucial for robotics, where multiple components need to interact concurrently to control a robot’s motion, perception, and decision-making processes.
  • Immutability: In functional programming, data is immutable, meaning it cannot be modified after creation. This reduces the chances of unintended side effects and simplifies the reasoning about code behavior, also facilitates fault tolerance and recovery in case of failures.
  • First-Class Functions: Functional programming treats functions as first-class citizens. This means functions can be passed as arguments to other functions, returned as values, and stored in data structures. This capability enhances modularity and allows for flexible and dynamic behavior, which is crucial in a dynamic robotic environment.
  • Reduced State Complexity: The absence of mutable state and side effects simplifies the overall complexity of a robotic software stack. Debugging becomes easier as there are fewer hidden interactions and fewer scenarios to consider.

Designing a Native Parallel and Fault-Tolerant ROS-Like Stack with Functional Programming

  • Message Passing with Immutability: Instead of relying on mutable messages for communication, functional programming promotes the use of immutable data structures. Message passing between robot components becomes inherently thread-safe and parallelizable.
  • Actor Model: Embracing the actor model, a concept from functional programming, each robot component becomes an independent actor that communicates through message passing. This decentralized approach eliminates the single point of failure introduced by a central ROS master.
  • Pure Functions for Sensor Fusion: Functional programming’s emphasis on pure functions – functions with no side effects – is ideal for sensor fusion tasks. Data from various sensors can be processed independently and combined using pure functions, reducing the chances of bugs and making the system more resilient.
  • State Management and Fault Tolerance: Immutable state simplifies the process of managing and recovering from faults. Snapshots of the system’s state can be taken, aiding recovery in the event of a failure. The system can be designed to automatically revert to a previous state or continue from a consistent point.

Challenges and Future Directions

While functional programming brings numerous advantages, its adoption in robotics requires overcoming challenges. Functional programming concepts might be new to many robotics developers, necessitating education and training. Additionally, optimizing for parallelism might require careful consideration of hardware and execution models.

Wrapping up

So, there you have it, the wild and wonderful world of functional programming in robotics. With parallelism, immutability, and a flair for fault tolerance, robots are grooving to a new tune, one where code isn’t just lines on a screen – it’s a choreographed masterpiece.

For this project I’m using Elixir which is is a dynamically-typed, functional programming language known for its scalability and fault-tolerant design. So far, learning a brand new language with an entirely different approach than the object-oriented programming language, I was used to, has been an experience in itself. solving simple programs in Elixir is greatly assisting me in enhancing my understanding of this language.While taking pleasure in the process, I’m curious to see how functional programming will help us program sophisticated robots.

Member

Richa Sawant : 2nd year Btech student pursuing computer engineering form VJTI Mumbai. github profile : https://github.com/richa-sawant