Robot Control using Raspberry Pi

Lecture 4 - A minimal introduction to Github and ROS2

Li Bai

Temple University

September 24, 2023

Github

  • Code Hosting Platform

  • Version Control: GitHub is built around Git, a distributed version control system.

  • Collaboration and Social Features: GitHub provides tools for collaboration,

  • Continuous Integration and Deployment (CI/CD): GitHub offers integration with various CI/CD tools

  • Community and Marketplace: GitHub has a thriving community of developers and offers

Get your own github account

  • How to signup a Github account

    Github Signup

  • How to create a repository and document in README.md

  • How to clone a repository, click here

Github clone

  • Let us clone a github repository
git clone https://github.com/ros2/demos/ 
  • pull to receive newly updated code
git pull

Github branches

git clone -b branch [url] [dest_directory]
git clone -b foxy https://github.com/ros2/demos/  foxydemo

Github Web Interface - Create New Repo

  • create a new repo to upload your code

Github Web Interface - Add Collabotor

  • add collaborator

Recall Docker Example

FROM --platform=linux/amd64  ubuntu:18.04
RUN apt update && apt install -y openssl python3
COPY echo-server.py /echo-server.py

EXPOSE 5001/tcp
  • Create a file named docker-compose.yaml
version: "3"
services: 
  my_image:
    build: 
        context: ./
    image: bionic-bai:latest
  echoserver:
    image: bionic-bai:latest
    command: python3 -u echo-server.py
    ports:
      - "5001:5001"
  • Run the command
sudo apt install docker-compose -y
docker-compose build
  • check what image is available?
docker image list

You can run the docker container and run a test

docker run -it bionic-bai:latest
echo -n password | iconv -t UTF-16LE | openssl md4 
docker-compose --profile echoserver up
  • Terminal 2
python3 echo-client.py abcd

Store Docker Example in Github Webapp

Create a simpleDocker github

Method 1: create file in Github site

Update content

Commit update

  • useful to write a commt message to address changes made

Method 2: upload file in Github site

Commit Changes

Completed files in Github

Copy Url

Git Clone on Cloud 9 instance

Github Readme.MD

  • Project Title Simple overview of use/purpose.

  • Description – An in-depth paragraph about your project and overview of use.

    – Getting Started

    – Dependencies

    – Describe any prerequisites, libraries, OS version, etc., needed before installing program. – ex. Windows 10

Github Readme.MD

  • Installing

    • How/where to download your program
    • Any modifications needed to be made to files/folders
  • Executing program

    • How to run the program
    • Step-by-step bullets
    code blocks for commands

Markdown file

  • Visit this link

    -Any advise for common problems or issues.

    command to run if program contains helper info
  • use “```” in command line function

  • use [] for url

  • use the image in the github directory, or click here for a video

![alt text](http://url/to/img.png)

Create a branch

  • for different hardware, OS, etc.

Create a branch

  • for examle, name it as for rpi

Delete the branch

Github Desktop App

  • you can download the app at here
  • benefits: easy access, good for upload more than 100 files, empty folder, larger files, etc…

Create another Git Repo for a ROS2 example

ROS2 Talker Example Excercise

  • ROS2 talker and listener nodes
  • ROS2 topic
  • publisher and subscriber

Download source

  • Delete all other files and keep demo_nodes_py folders as shown below

Compile ROS2 codes

  • Run setup program update
python3 -m pip install setuptools==58.2.0
  • Let us run the following commands one line at a time
mkdir -p ros2_ws/src
cd ros2_ws/src
git clone -b humble https://github.com/ros2/demos/  humbledemos
cd ..
colcon build

Note

If you have an error from previous command, run

colcon build --allow-overriding demo_nodes_py

ROS2 Talker

source ./install/setup.bash
ros2 run demo_nodes_py talker

ROS2 Listerner

  • open another new terminal
cd ros2_ws/
source ./install/setup.bash
ros2 run demo_nodes_py listener

ROS2 rqt_graph

  • open the third terminal for rqt_graph
export DISPLAY=:0
cd ros2_ws/
source ./install/setup.bash
rqt_graph

ROS2 Github Excercise*

  • Write code on a cloud9 instance
  • Create a Github link to store your ros2_ws code by modifying the talker/listener example
  • In Python code, revise the numerical numbers as english words (For example, 1-> one, 2 -> two, etc.)
  • Revise the python code to display your firstname in listener’s message
  • Rename node’s name as your lastname_talker, lastname_listner

  • show your ROS2 nodes in rqt_graph
  • Display the output from listener
  • show changes made to your source code on Github with instruction

When you submit a report, please include the corrected procedures and give the screen shots based on the checkoff.

Preparation for next week’s class

  • Download Mini pupper v2 image, second Micro-SD card ready

  • Download the 50-cloud-init.yaml from your pi, we will use it next class

cp /etc/netplan/50-cloud-init.yaml  .