NCRL_11
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Robot Web GUI Guide ###### tags: `apriltag localization` [TOC] ## Recommended Tutorials :::warning A simple web interface for ROS can be fully practiced after the following tutorials. The rest of the content will be based on these tutorials and give instruction on how to construct this specific webpage for apriltag localization along with what can be improved and be done. ::: 1. [The Construct - Introduction to ROSBridge Server](https://www.theconstructsim.com/developing-web-interfaces-for-ros-robots-1-introduction-to-rosbridge-server/) 2. [The Construct - Designing Frontend Webpage](https://www.theconstructsim.com/developing-web-interfaces-for-ros-robots-2-adding-styles-to-the-ros-control-web-page/) 3. [The Construct - Streaming Video (Images) on Webpage](https://www.theconstructsim.com/developing-web-interfaces-for-ros-robots-4-streaming-robots-camera-on-the-web-page/) ## Overall System :::success The system's foundation is rosbridge_suite package. It provides a simple method to setup a server on the robot and perform communication through a predefined protocol with a web client under a local network. ::: ![](https://i.imgur.com/tKpqnRR.png) * Client: <div style="text-align: justify"> &emsp; A web interface written in HTML and JavaScript on which user can request data from the server and send command to the server via JSON format text file. In order to send and request ROS compatible message, an opensource library, roslibjs, is provided along with rosbridge_suite </div> Ref: [rosbridge_suite](http://wiki.ros.org/rosbridge_suite) * Server: <div style="text-align: justify"> &emsp; A server in our case is the UPboard on the UAV which will run ROS and localization application. It can process the received and sent data from JSON to ROS message and vice versa via rosbridge_library. In order to send and receive at the same time without waiting the client to request, a sebsocket server is considered instead of TCP/UDP. </div> * Client & Server Communication: <div style="text-align: justify"> &emsp; Briefly speaking, the communication can be thought of as a consistent action of writing, sending, and reading a JSON formatted text file between client and server. On the client end, we can assign a topic and message to send and receive through predefined classes in roslibjs. These information will be written to a JSON file following the protocol and be sent to server end. Then the server will process the JSON file to ROS message through rosbridge_library. </div> ## Client(Frontend Webpage) ### Web server * SimpleHTTPServer + Single Page Web + Usage: ```console= python -m SimpleHTTPServer ``` ### Web Design #### HTML Basic Tutorials ++**Head(Libraries):**++ roslibjs, mjpegcanvas, bootstrap, vue.js ```htmlembedded= <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Control Panel</title> <script type="text/javascript" src="http://static.robotwebtools.org/roslibjs/current/roslib.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/eventemitter2@5.0.1/lib/eventemitter2.min.js"></script> <script type="text/javascript" src="https://static.robotwebtools.org/mjpegcanvasjs/current/mjpegcanvas.min.js"></script> </head> ``` ++**Body:**++ 1. Navigation bar > <div style="text-align: justify">User can redirect to different pages with navigation bar. The link of the button can be set with href in attribute tag. Note that with SimpleHTTPServer, only a single page can be created. If multiple pages needed to be setup, you can use FLASK to setup multiple web ip addresses.</div> ```htmlembedded= <div> <nav class="navbar navbar-expand-lg navbar-dark bg-secondary text-white"> <a class="navbar-brand" href="#">NCRL</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a class="nav-link" href="http://127.0.0.1:5000/">Home<span class="sr-only">(current)</span></a> </div> </nav> </div> ``` 2. Block with background > jumbotron class can create a block with background, bg-(color) and text-(color) can change background and text color respectively. As for the supported color, you can check bootstrap4 tutorials on this [website](https://www.w3schools.com/bootstrap4/default.asp). ```htmlembedded= <div style="padding-top:55px; margin-bottom:20px; padding-bottom:35px;" class="jumbotron jumbotron-fluid bg-info text-white"> <h1 style="padding-bottom:20px;" class="text-center display-3"> NCRL Apriltag Localization </h1> <p class="text-center display-8">This is a web control interface for NCRL Apriltag Localization Project.</p> </div> ``` 3. Grid Layout > Layout can be created by setting rows and columns. The total number of columns in a single row is 12. ```htmlembedded= <div class="col-2 jumbotron" style="padding-bottom:2rem; padding-top:1rem; padding-right:1rem; padding-left:1rem; margin-right:1rem;"> <h3>Connection status</h3> <p class="text-muted" v-if="!connected && !failure">Not Connected</p> <p class="text-danger" v-if="failure">Error</p> <p class="text-success" v-if="connected">Connected</p> <label for="uav_server">UAV_server: </label><br/> <input id="uav_server" type="text" v-model="ws_address"/><br/> <button class="btn btn-danger" style="margin-top:10px; margin-bottom:10px;" @click="disconnect" v-if="connected">Disconnect</button> <button class="btn btn-success" style="margin-top:10px; margin-bottom:10px;" @click="connect" v-if="!connected">Connect</button> </div> ``` 4. Common attribute for Vue.js + v-if="[variable name]": > If the corresponding variable in javascriptis true, then the html line will be available. Otherwise, it'll be commented. + @click="[function name]": > When the button is pressed, then the function in method in javascript will be triggered. + v-model="[variable name]": > When a value is given to an input tag, the value will also be assigned to the corresponding variable in javascript. #### Web Functionality #### JAVASCRIPT Basic Tutorials 1. Load main.js in GUI.html's body ```htmlembedded= <script type="text/javascript" src="main.js"></script> ``` 2. Creat a vue object in main.js ```javascript= var app = new Vue({ el:'#[id]', data: { test_var: 'test', }, methods: { test: function(){ console.log(this.test_var) } }, updated(){ }, }) ``` > <div style="text-align: justify">El correspond to the id of the division you want the vue object to link to. In our case, it is linked to the 'control_gui' div. Data is the section where you can declare class variables. In methods, you can define functions that can be triggered from the html file. In updated, the lines will be executed once the html(webpage) has any modification. For instance, to implement the function of enabling a button when the input is given, the underlying code should be written in updated. There are other built-in for Vue.js to use beside el, data, methods and updated that you can find in tutorials. </div> * methods * updated 3. Streaming video ```javascript= showCamera: function(){ console.log('set camera method') this.cameraViewer = new MJPEGCANVAS.Viewer({ divID: 'mjpeg', host: '0.0.0.0', width: 640, height: 480, topic: '/iris1/camera_forward/color/image_raw', port: 8080, }) ``` 4. Publishing Topic ```javascript= // Create a control signal publisher: take off 1, return 2, stop 0 this.control_pub = new ROSLIB.Topic({ ros: this.ros, name: '/control_phase', messageType: 'std_msgs/Int8' }); this.control_signal = new ROSLIB.Message({ data: 0 }) this.control_pub.publish(this.control_signal) ``` 6. Subscribing Topic ```javascript= this.location_sub = new ROSLIB.Topic({ ros: this.ros, name: '/location', messageType: 'std_msgs/Int8' }) this.location_sub.subscribe(function(message){ document.getElementById("uav_location").innerHTML = message.data; }) ``` ==Function in subscribe cannot modify class variable in Vue??== ## Server (UAV) 1. Install rosbridge server ```console= sudo apt-get install ros-melodic-rosbridge-server ``` 2. Install web video server ```console= sudo apt-get install ros-melodic-web-video-server ``` 3. Configure launch file ```xml= <launch> <include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch"> <arg name="port" value="9090"/> </include> <node name="web_video_server1" pkg="web_video_server" type="web_video_server"> <param name="port" type="int" value="8080" /> <param name="address" type="string" value="0.0.0.0" /> <param name="server_threads" type="int" value="1" /> <param name="ros_threads" type="string" value="2" /> <param name="width" type="int" value="1080" /> <param name="height" type="int" value="720" /> <param name="quality" type="int" value="90" /> </node> </launch> ``` ## Topic List ### Publisher - [X] /control_phase * messageType: std_msgs/Int8 `take off: 1, return: 2, stop: 0` - [X] /flight_destination * messageType: std_msgs/Int8 `Tag ID` - [X] /flight_height * messageType: std_msgs/Int8 ### Subscriber - [X] /id - [X] /status - [X] /location - [X] /flight_height ## Implementation Problem 1. Cannot access http server from other device * Note that permission in FireWall might affect the accessability * Use ifconfig to check the device's public ip, that is running the http server. Make sure that the address on other address is the server's device's public ip ## Demo ![](https://i.imgur.com/6XEPBXB.png) [Github](https://github.com/Andreew9504089/AprilTag_Localization/tree/master/src/single_page_gui) ### How to Use * Launch 1. roslaunch robot_gui_bridge websocket.launch on terminal 1 2. cd single_page_gui & python -m SimpleHTTPServer on terminal 2 3. check ip using ifconfig (inet), check websocket_port on terminal 1 and http_port on terminal 2 4. on other device, go to ip:http_port 5. choose GUI.html * Connection 1. In web gui, enter uav port as websocket_port and uav ip as ip https://drive.google.com/file/d/1k9Bsl7ri-q1ngy1nkoERPu9QAObmdXtr/view?usp=sharing ![](https://i.imgur.com/X7xfeIz.jpg =200x) * Control Panel ![](https://i.imgur.com/3nfAd6e.png) 1. Unlock &emsp; After connecting to uav's websocket server and launching web_control, unlock the control panel. + status: 'Standby' `Take off will be enabled` + status: 'Hovering' `Return & Land will be enabled` + status: 'Flying' `Kill will be enabled (not implemented yet)` 2. Take off `Land will be enabled` 3. Land `Take off will be enabled` 4. Cruise Height `Not implemented yet, NCRL controller doesn't support height command` 5. Turning direction `Not implemented yet` 6. Hovering Time `Not implemented yet` 7. Select Destination `Land & Return will be enabled` `Start will be enabled once the input destination is typed` 8. Indication light `Green: not in the middle of mission` `Red: In the middle of a mission (Not suggested to send command(control panel is not protected))` ### Feature of Adding OpenStreetMap using Leaflet #### [Tutorial](https://www.letswrite.tw/leaflet-osm-basic/) #### Demo ![](https://i.imgur.com/7oajqYI.png)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully