ROS and Raspberry Pi

ROS and Raspberry Pi
Basics working of ROS between two devices

Controller

Controller
Working of Open Loop , Closed-Loop and PID Controller,

AruCo and Whycon Markers

AruCo and Whycon Markers
AruCo and Whycon Markers

Latest Posts

Saturday, 5 December 2020

ROS Basics

Navid

ROS Basics 

So you came across something called ROS, maybe from the internet or XYZ platform. So maybe you have so many questions about what is ROS and how it is working etc...right? So in this blog, we are discussing the basics of ROS with which you can start your little projects. So let's start

All innovative robots running on ROS.

ROS full form is Robotic Operating System, it is a distributed framework And its free open source platform. you can use Python and C++ script to run your robot. So ROS is introduced to reuse research work done by others. So you just need to download and clone the repository and start working. If you need a laser scan code, just clone it and utilise it according to your need. ROS allow you to write code in different RosNodes.

The below diagram shows the basic structure of ROS 

The main part of ROS

  • ROS MASTER- Master Node used to locate the different nodes available in the network
  • ROSNODES- small user-defined script of code inside rosnetwork which can be accessed by other nodes 
  • ROS MESSAGE- information about the type of data to be sent
  • ROS SERVICES- service of ros which enables a user to send a request to get data from a particular node.


So much!!!!!

Don't worry let me explain to you by an example, Assume that "Node A" want to send a message to "Node B" then both nodes should have to be connected with ROSMASTER. If they are not connected with ROSMASTER the Node A and Node B both don't have any possible way to transfer data with each other. ROSMASTER acts as a bridge between them.

In the same example, You can notice we are sending data to Node B from Node A. Now assume we are sending a text message to Node B, In this case, We writing some code in python or in C++, to send this text message to Node B. so this is what a node definition. So ROSNODE is nothing but a piece of the script written to do some particular task. And a text is nothing but String type and that we defined in our ROS MESSAGE Type. this is how we define what type of data we are transferring to another node. and something we define in other nodes

Now, what is ROS Service: Here we send request to get data from a particular node. For example, if we want to check the status of the camera is ON or OFF... we just send a request and camera-related node will respond back with camera status.


Real-Time Example: Assume we have a Robot which has sensors and motors attached to it. So here We will write two Nodes one is for sensors to get data by subscribing(Sensor Node) and one is for the motor to send data publishing(MotorNode). To know more about publishing and subscribing visit(.....will update soon....) Both nodes are registered with ROSMASTER. So here we get sensor information by the sensor node, compute the velocity and will be sent to motors by the motor nodes.


So likewise we can write many nodes separately and we can easily access any node information.




Thursday, 19 November 2020

ROS and Raspberry-Pi (MASTER- SLAVE Configuration)

Navid

I assume that you already installed ROS in Raspberry Pi and in your PC. I also assume that you already succeed in publishing data and subscribing the same. Well done...

If you haven't done these task I recommend you to visit my blog (.........................)


So hey there This is Navid, in this blog you will be learning how to transfer data from one system to other with ROS. 

Basically, ROS nodes communicate with each other with ROS Master, So we need a Ros Master Running in any one of your devices, this device acts as Master and other acts as Slave. Pretty simple The one which running roscore is a Master and other one is Slave. 

In my case, Raspberry Pi will be Master and My PC will be Slave, let's do this

First, open Raspberry Pi terminal and start ROS master by running roscore (Figure.1)

Raspi Ternimal (roscore)


Now, we have master running on Raspberry Pi but other devices unaware of master existence. So in order to communicate with Master, we need to take care of some ROS configuration.  

First, we export Ros Master address in all devices (including ROS Master) , Open New ternimal and execute the following command 

                    export ROS_MASTER_URI=http://IP Adress of MASTER:11311

In my case the IP address of the raspberry pi 

(To find your Ip address you can execute ifconfig in new terminal) 

                    export ROS_MASTER_URI=http://192.168.43.142:11311

Now open a terminal in PC and execute the same line in my case the below line.

                    export ROS_MASTER_URI=http://192.168.43.142:11311

So at this stage, our devices know that there is a master node running in Raspberry Pi but they communicate with each other only through ROS IP address, So declare ROS_IP address in all devices.

    In Raspberry pi  export ROS_IP=IP Adress of Raspberry pi 

         in my case,

                        export ROS_IP=192.168.43.142

    In PC export ROS_IP=IP Adress of PC

      in my case,

                    export ROS_IP=192.168.43.99 (my PC IP Adress )


Have a look, commands executed in Raspberry Pi and PC

In Raspberry Pi 


In PC


if you followed all steps correctly you can share messages between both devices as shown in below video 




You can connect as many devices as a slave to the Master.

Stay tune for new blogs related to ROS....



Difference between open-loop and closed loop controllers and working of PID controller

Navid
There is always need a control system in order to control the robot based on some parameters. Control systems are classified into two types like open loop and closed loop. The main difference between open-loop and closed-loop control system is, the required output within the open loop doesn’t depend on the input whereas, in closed-loop, the required output mainly depends on the input. This article discusses an overview of the difference between open-loop and closed-loop control systems. The open-loop system doesn’t have feedback, whereas the closed-loop system has feedback figure 3 and 4, depending on the feedback controller produce the output.
Open Loop System
Closed-Loop System.

To control the system, we used PID (proportional, integral and derivative), controller. see below figure
PID Controller

In this PID controller,
Term P is proportional term tried to reach the desired output of the system as soon as possible. we use “K” as gain. in general, we use “Kp” for proportional gain. In general Proportion, the term Kp  helps system to reach the desired output as fast as possible. if “Kp” is more then we have lots of oscillations as system overshoots and if we use less then the system takes a longer time to achieve goal.
Term D keeps an eye on the required output, as soon as the system reaches to desire output D term slowdowns the system and helps the system to avoid overshoots. Because of this, the system will not oscillate and remains stable. We used Kd for tuning the controller called a Derivative gain.

Due to these two factors some time the system goes up slightly duo to Kp and sometimes down due to Kd. To solve this problem and to keep the system more stable Integral Ki is added to the controller

Term I term is known for integral gain noted as “Ki” which perform based on past value obtained by the controller results and based on the error received it will try to eliminate the error between the desire output state of the system and present system state

References

1.       A Practical Multirobot Localization System” , T. Krajník, M. Nitsche, J. Faigl, P. Vaněk, M. Saska, L. Přeučil, T. Duckett, and M. Mejail, ,” Journal of Intelligent & Robotic Systems, 2014.

2.       External localization system for mobile robotics” , T. Krajnik, M. Nitsche, J. Faigl, T. Duckett, M. Mejail, and L. Preucil, ,” in Advanced Robotics (ICAR), 2013 16th International Conference on, 2013

3.       https://www.youtube.com/watch?v=6OH-wOsVVjg

WhyCon Markers, AruCo Markers

Navid

 

Do you have a web camera?  And need a high-performance localising system? Then you probably have to look into whyCon Markers

WhyCon Marker:

It is a vision-based localization system that can be used with low-cost web cameras, and achieves millimetre precision with very high performance. The system is capable of efficient real-time detection and precise position estimation of several circular markers in a video stream. WhyCon is meant as an alternative to widely used and expensive localization systems. It is fully open-source. WhyCon-orig is WhyCon's original, minimalistic version that was supposed to be ROS and openCV independent.

Working:

The base of the localization system is an efficient circular target detector. This efficiency allows for the detection of hundreds of targets above camera frame-rate. The targets can be easily printed on a B&W printer. A single target allows for obtaining 5DoF (3D position + 2 angles). When constrained on planar (ground) motions, the precision can be further improved



ArduCo Basic
AruCo Markers:

AruCo Markers are, as similar to QR codes which have a unique identity. AruCo marker consists of 7 by 7 binary grids. But the pattern is considered only inside 5 by 5 grids. Black represents 0, and white represents 1. In Aruco Markers 1st,3rd and 5th column represents parity bits and 2nd and 4th column represents dt bits as shown in figure yellow represents parity bits and light blue represents a data bit.


So maximum number marker can be encoded is 

A sample of AruCO
                            2^`10 =1024

Figure 1 AruCo Sample

So, we can create 1024 unique IDs

 


 

 



 References

1.       A Practical Multirobot Localization System” , T. Krajník, M. Nitsche, J. Faigl, P. Vaněk, M. Saska, L. Přeučil, T. Duckett, and M. Mejail, ,” Journal of Intelligent & Robotic Systems, 2014.

2.       External localization system for mobile robotics” , T. Krajnik, M. Nitsche, J. Faigl, T. Duckett, M. Mejail, and L. Preucil, ,” in Advanced Robotics (ICAR), 2013 16th International Conference on, 2013

3.       https://www.youtube.com/watch?v=6OH-wOsVVjg

 

About Me

  • Navid A MullaMaster / Robotic Engineer