Introduction
-
Using ROS bridge server and a web page built with roslibjs on LAN to build a ros Interface.
-
Rosbridge server provides a websocket to connect the ros system and the web page.
-
Nginx, the local server, is used to host the web page locally.
-
The ports
There are two ports in this system, one is the port of rosbridge server, the other is the port of local server.
- The port of rosbridge server is set to 9090 by default. The setting is in the HTML file and the launch file of rosbridge server, we can change it, but remember to change the port in the HTML file and the launch file at the same time.
- The port of local server is set to 90 by default. The setting is in the nginx config file. This port is used to host the web page locally, and for the user to access the web page.
Setup
-
Install rosbridge server and nginx
-
Generate ssl certificate and key file using openssl (cd to the directory you want to store the files first)
-
Edit the nginx config in
/etc/nginx/nginx.conf
3.1. Change the default user name www-data to hoster user name (the first line of the file, see example 3.3.)
3.2. Add the server config session in the config file.
3.3. Here is an example of the config file
-
The example web page, using a virtual joystick to publish the cmd_vel topic.
Startup
On robot side
-
Start rosbridge server
-
After the user side is connected, check if the data is received.
On local server side
- Start local server
On user side
- Open the web page
Bug fixes
-
Error :
The web page shows 403 Forbidden
- Solution :
- Instruction - 解决Nginx出现403 forbidden
- check users
- Edit the user name in /etc/nginx/nginx.conf, default is www-data change to your user name
- Solution :
-
Error :
The web page shows ERR_SSL_PROTOCOL_ERROR
- Solution :
-
Add the ssl config session in /etc/nginx/nginx.conf
-
Restart nginx
- Solution :
Reference
Websocket
- Instruction - ROS package#1 ROS Bridge 跨平台溝通
- Github - roslibjs
- CSDN - ROS进阶——Websocket
- 古月居 - 利用Websocket实现ROS与Web的交互
- Instruction - ROS web tutorial part 1 - rosbridge server and roslibjs
- Instruction - HTTPS站点使用WebSocket的错误及解决方案