GithubHelp home page GithubHelp logo

ttk4145-heis's Introduction

Elevator project for TTK4145 - Real Time Programming

By Lars Musæus, Knut Vågnes Eriksen and Jakob Eide Grepperud.

Our Stack

Language

The system is written in Python, built with colcon and the hardware/simulator driver is written in C and interpreted with Ctypes.

Network

For our network module we use ROS2 which is a open source library for both Pyhton and C++.

Modules & System overview

System overview can be found in design-review/uml.

Driver module - C to Python

We use the driver interface provided and interface with it using ctypes. A simple example is shown in example.py. The library is simply compiled using gcc and then imported into the python file. (Shoutout to sindrehan).

The following line shows how to compile the driver library.

gcc --std=gnu11 -shared -fPIC io.c elev.c -o driver.so /usr/lib/libcomedi.so

ROS2 & Colcon

Installation

The project is running on ROS2 Eloquent and built with Colcon. To install ROS2 follow this guide: https://index.ros.org/doc/ros2/Installation/Eloquent/Linux-Install-Debians/

Colcon is installed with apt:

sudo apt install python3-colcon-common-extensions
sudo apt install libcomedi-dev

Ros Domain

To talk between ros nodes on different computers you need to have the same domain id:

export ROS_DOMAIN_ID=42

4 Installeringer

Start VM og last ned ROS og Colcon som beskrevet over på VM

Build and run

To build and run the system we have made scripts for this so you don't have to retype commands all day long:

Build

. build_elevator.sh

Start simulator (optional if your'e not on the Sanntidssal)

. simulator.sh

Start ROS and elevator program

. launch_elevator.sh

Packetloss simulation

1. Script

We have made scripts to simulate both packetloss and complete network loss, packet_loss.sh and no_network.sh, respectively. NOTE: They accept ports used by discord to be able to use discord during packet_loss.

Simulate full network loss

. no_network.sh

Simulate 20% packetloss

. packet_loss.sh

If u want to do it yourself without using the scripts follow instruction below.

2. Manually

ROS/DDS uses 4 UDP ports which generates by a function of ROS_DOMAIN_ID(we use 42). More info about this can be read here: https://community.rti.com/howto/statically-configure-firewall-let-omg-dds-traffic-through

Three out of four port are static, and in our case:

17900
17912
17913

The last port can be found with the following shell command:

lsof -i
Stenge kommunikasjon mellom portene

When you have the four ports, you can block them completely (example):

sudo iptables -A INPUT -p udp --dport 17900 -j DROP
sudo iptables -A INPUT -p udp --dport 17912 -j DROP
sudo iptables -A INPUT -p udp --dport 17913 -j DROP
sudo iptables -A INPUT -p udp --dport 48904 -j DROP

To only "loose" a certain amount of packages(here 20%) use this instead:

sudo iptables -A INPUT -p udp --dport 17900 -m statistic --mode random --probability 0.2 -j DROP
sudo iptables -A INPUT -p udp --dport 17912 -m statistic --mode random --probability 0.2 -j DROP
sudo iptables -A INPUT -p udp --dport 17913 -m statistic --mode random --probability 0.2 -j DROP
sudo iptables -A INPUT -p udp --dport 48904 -m statistic --mode random --probability 0.2 -j DROP

ttk4145-heis's People

Contributors

larsgmu avatar jkaob avatar csletten avatar knuteriksen avatar marilinnerud avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.