How to Control a Robot using WebRTC

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial we will use webrtc to control a robot for example we can control the robot to create a map and then we can do autonomous navigation based on the created map it is also possible to establish video and voice communication using webrtc webrtc could be very helpful in various robotics applications [Music] so what is webrtc webrtc stands for web real-time communication webrtc provides software API is written in JavaScript which can be used to create peer-to-peer communication between internet web browsers and other applications with webrtc data transfer is done without custom interfaces extra plugins or special software for browser integration webrtc connects users by transferring data from device to device using peer-to-peer communication signaling server provides a mechanism to coordinate communication between peers and to send control messages if users are on different IP networks that have Network address translation firewalls that prevent real-time communication webrtc can be used in conjunction with session traversal utilities for net servers this enables a given IP address to be translated into a public internet address so peer connections can be established in case Sun server cannot be used to translate IP addresses traversal using relays around that server is used This Server relays traffic between users enabling them to connect the interactive connectivity establishment protocol is used to find the best connection in this tutorial we will use raspberry pi as an operation system we will use Ubuntu desktop 2264-bit version to write this image in the Raspberry Pi imager push the choose OS button then select other general purpose OS select Ubuntu and finally select Ubuntu desktop 22042 LTS 64-bit to operate the robot we need user interface of course we can create it from scratch but in this tutorial we will use an existing service we will use Robo portal this page provides an application to do peer-to-peer remote robotics control we will get back to this application later but for now create an account to use Robo portal we will set up bot box is a client application for robo portal firstly update the app and install required packages here is an explanation of some packages lib VPX is a free software video Codec library from Google and the alliance for open media lib sodium is a library for encryption decryption signatures password hashing Libs emq3 is just a wrapper for the xero mq library program which we will use is written with co-programming language so we have to install go language we will install it in a simpler way than described here we will do it using snap Snaps are a secure and scalable way to embed applications on Linux devices with snaps applications run fully isolated in their own sandbox thus minimizing security risks the classic confinement allows a snap to have the same level of access to the system as classic packages like those managed by EBT now a little bit about go language go language is an open source compiled language written to build concurrent and scalable software the language was invented at Google after installation completes execute Go version command we can see that we have installed go language successfully now execute this line and clone the bot box Repository move to the bot box directory and execute the go build command we have an error if this error occurs it means that you don't have required package to build the source code install build essential build essential is a meta package it is a link to several other packages that will be installed as dependencies it includes GCC G plus plus make and other packages required to compile programs now let's build our program one more time this time we have successfully built it before executing the bot box program we have to create a robot in Robo portal go to the robo portal and open the list of available robots page we already have a robot which we will use but I will show you an example of how to create a new robot firstly click on the create new robot button enter the new robot's name into the text box we will call our robot web robot in the widgets window we can select what data we want to receive or send to a robot in this tutorial we will only operate the robot so leave it as it is click on the save button here click the setup controls button in the control setup window click on forward press up key on your keyboard interaction name into the key text box then click the assign control button repeat this operation four times for each robot move after setup of the controls go back to the robot list page we can see that our robot has been created successfully to access our robot we need to know public key in secret key access to this page from your robot and copy these keys before executing bot box we have to create an end file all configuration of Bot box is stored in the end file we can use end example file as a starting point here we replace public key in secret key with those we have created in these lines set your web camera configuration as in output mode we will use IPC IPC stands for inter-process communication IPC is a mechanism provided by an operation system for processes to share data among them usually applications can use IPC categorized as clients and servers where client requests data and server responds to client requests we will use this feature later these are all modifications we have to do now connect your camera to Raspberry Pi now we are going to execute our program open a new terminal and move to the bot box directory execute bot box now move to the computer from which you will operate the robot open the robo portal page make sure that status of your robot is connected click on your robot click the start button we can see that the image from the web camera connected to the robot has been successfully received in the client side now let's see the code to operate a robot in this tutorial as an example I used four-wheel steering robot which I made previously but any robot can be used with nearly the same code this program consists of two threads in the first thread operation mode of the robot is decided based on the received data from the client in the second thread based on the operation mode Servo moving angle or velocity is decided and sent to servos async IO run is used to run a co-routine in an event Loop a co-routine is a function or routine that can be suspended and resume this function creates an event Loop runs the core routine in the event Loop and finally closes the event Loop when the core routine is complete the async io8 function runs an iterable of awaitable objects and blocks until a specified condition receive function is defined with prefix async the async def expression defines a co-routine here communication with the client is established in this line the data from the client is received note that by using a weight statement the current Co routine is suspended until data is received in these lines the received data is converted to dictionary format in a value associated with controls key is extracted here robot operation mode is decided in the robot Control Function if the robot is not moving and a new command is received we set new Servo values according to the operation mode after the robot moves for a certain amount of time we initialize the robot state now let's operate the robot open two new terminals in the first terminal run the bot box in the second terminal run webrtc script Pi script on the second computer open Robo portal and move to the robot control page turn on controls enabled switch now you can operate the robot by clicking on arrows or by using your keyboard
Info
Channel: robot mania
Views: 2,258
Rating: undefined out of 5
Keywords: robotics, ROS, python, remote control
Id: U1lfiY2k7R0
Channel Id: undefined
Length: 12min 59sec (779 seconds)
Published: Mon Jul 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.