OpenCyphal-Garage / cyraft

Raft algorithm (for pycyphal)
2 stars 2 forks source link

Cyraft

The objective is to implement the Raft algorithm as an exercise, with the intention of incorporating named topics into pycyphal.

This feature is significant because it enables Cyphal to serve as a communication layer between PX4 and ROS in the future.

(See UAVCAN as a middleware for ROS)

TODO

Questions:

Code improvements:

Setup

Diagrams

demo_cyraft

---
title: cyraft node X
---
flowchart TB
    subgraph 1X:org.opencyphal.pycyphal.raft.node
        direction TB
        subgraph heartbeat_publisher
            direction TB
            heartbeat_publisher_1[/uavcan.node.Heartbeat.1.0\]
        end
        heartbeat_publisher --> uavcan.node.heartbeat
        subgraph request_vote_rpc
            direction TB
            request_vote_1{{sirius_cyber_corp.RequestVoteRPC}}
        end
        10X:sirius_cyber_corp.RequestVote.Request --> request_vote_rpc
        request_vote_rpc --> 10X:sirius_cyber_corp.RequestVote.Response
        subgraph append_entries_rpc
            direction TB
            append_entries_1{{sirius_cyber_corp.AppendEntriesRPC}}
        end
        11X:sirius_cyber_corp.AppendEntriesRPC.Request --> append_entries_rpc
        append_entries_rpc --> 11X:sirius_cyber_corp.AppendEntriesRPC.Response
    end

DSDL datatypes

---
title: RequestVote
---
classDiagram
    class RequestVote_Request{
        -uint64 term
        -uint64 last_log_index
        -uint64 last_log_term
    }

    class RequestVote_Response{
        -uint64 term
        -bool vote_granted
    }
---
title: AppendEntries
---
classDiagram
    class AppendEntries_Request{
        -uint64 term
        -uint64 prev_log_index
        -uint64 prev_log_term
        -uint64 leaderCommit
        -LogEntry.1.0[<=1] log_entry
    }

    class AppendEntries_Response{
        -uint64 term
        -bool success
    }

Sources

Raft paper

lynix94/pyraft

zhebrak/raftos

dronecan/libuavcan

An exploratory study: UAVCAN as a middleware for ROS

Allocators explanation in OpenCyphal/public_regulated_data_types