This is part of the LiDAR Data Streaming Project developed at TiHAN, IIT-H
This is an alternative to using WebRTC; when either of the devices are behind Symmetric NAT (AKA Full-Cone NAT). The type of NAT can be checked here. Permissive NAT is a requirement for Peer-to-Peer (WebRTC) communication.
To learn more about NAT, go here.
NOTE: A TURN Server is often cheaper than this method, however, it only allows single subscriber of the data stream. In contrast, this method allows multiple subscribers.
ROS (preferably melodic version for Ubuntu 18.04) is required to be setup on both the sender (encoder) and the receiver (decoder).
ROS-Bridge server needs to be installed for roslibjs which was part of the project that this repository was intended for.
Installation: (Change melodic
to the required version)
sudo apt-get install ros-melodic-rosbridge-server
Starting Server:
roslaunch rosbridge_server rosbridge_websocket.launch
Node Package Manager (NPM) and Node.js are required to be installed (npm@6.14+
, node@14.17+
).
- Navigate to Firebase website
- Click on
Add project
- Enter project name (
lidar-fb
) - Click on
continue
- In the
Project Overview
page, click on</>
to create new web app - Register Web App with a nickname (
lidar-fb
), and clickcontinue
- Copy the Firebase Configuration code (
firebaseConfig
) - Paste it by overwriting the old values in
src/index.js
- Go to Realtime Database (RTDB) page, and click on
Create Database
- Choose
Singapore (asia-southeast1)
as the RTDB location (or whichever closest) - Choose to
Start in test mode
- Click in Rules tab and edit the json document with the following code and
Publish
changes:
{
"rules": {
".read": "true", // Can be read for forever, by anyone.
".write": "true" // Can be written in forever, by anyone.
}
}
- (Optional) To modify the
Rules
, read more about them here
Firebase is now setup and ready for use!
The source code is available here.
Run the following commands:
cd ~ #directory where the project is to be located
git clone https://github.com/bhaskar-anand-iith/lidar-fb
cd lidar-fb/ #root of project
npm i #installing dependencies
- Version Error: ensure
npm@6.14+
, andnode@14.17+
npm -v
node -v
For testing locally:
npm run dev #runs the "dev" srcipt defined in package.json
If changes are made to src/index.js
, then dist/bundle.js
has to be recompiled using the command:
npm run webpack
The Sender and receiver must be in the same room
. The room can be chosen from the URL (Address Bar). By default, an 8-digit random ID is assigned.
Sender/Sensor side: Once the webpage has loaded, the webpage automatically subscribes to /n2b_data
rostopic, and immediately starts publishing to the RTDB.
Receiver/Visualizer side: Once the webpage has loaded, the user must click on start
button to subscribe to the RTDB, and then starts publishing to /b2n_data
rostopic. When the stop
button is clicked, the RTDB is unsubscribed.
Subscribes to /n2b_data
rostopic (from native c++ code)
Publishes to /b2n_data
rostopic (from browser)
The app has been deployed on Heroku. It is connected with GitHub (through a webhook) and automatically deploys any changes that are made to the main
branch (by default) in the connected GitHub repository.
Requires a Heroku account
- Go to Heroku Dashboard
- Click on
New
-> Create new app - Enter App name, choose a region, and click
Create app
- In the
Deploy
tab, set the deployment method toGitHub
- Search for the repository name (
lidar-fb
) (you must be owner of repository on GitHub. Explore GitHub Teams for more features) Enable Automatic Deploys
andDeploy Branch
(main)
The webapp will take some time to be built and deployed. The webapp can be accessed at App-name
.herokuapp.com
For additional build information, access the Activity
tab and click on the build of choice.
- Not receiving any data from RTDB: check network status, firebase usage limits
- Receiving data but no visualization in RViz: check if roscore, ros-bridge server, and decoder are running.
- No data is being sent: check if roscore, ros-bridge server, and encoder are running, firebase usage limits.
- Latency is continuously increasing over time: bandwidth is insufficient, find a better network.