Skip to content

Commit

Permalink
2023-08-25-ROSfunc.md (#35)
Browse files Browse the repository at this point in the history
* Create 2023-08-25-ROSfunc.md

* Update 2023-08-25-ROSfunc.md

---------

Co-authored-by: Zain <beingzainsv@gmail.com>
  • Loading branch information
richa-sawant and SuperChamp234 authored Sep 3, 2023
1 parent 9b016cf commit 2f8c533
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions _posts/2023-08-25-ROSfunc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
layout: post
title: ROSfunc
tags: Functional Programming, Systems
description: Use functional programming to implement a natively parallel and fault tolerant ROS-like software stack.
---

-- [Richa Sawant](https://github.com/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

0 comments on commit 2f8c533

Please sign in to comment.