Giter Club home page Giter Club logo

capra_web_ui's Introduction

capra_web_ui

This is a UI application for manually controlling ROS-based robots in real-time. While it is designed for the use case of club capra, we try to make it as robot agnostic as possible. As long as your robots has the required dependencies it should be almost plug and play.

Installation

We provide installers for Windows and Ubuntu that can be found in the release page. If a release is marked as pre-release it means the features haven't been tested with an actual robot. https://github.com/clubcapra/capra_web_ui/releases

npm setup

While you can install node/npm manually, it's easier to use a version manager. This let's you have multiple node version installed without any issues.

For Linux

We recommend using https://github.com/nvm-sh/nvm

For Windows

We recommend using https://github.com/coreybutler/nvm-windows

Building

capra_web_ui is made with web technologies this means you need node.js installed on your machine to build it. We assume the latest version of nodejs is installed.

  • Download and install all required dependencies to build or develop the app.
npm i
  • Bundle the typescript in src/main and src/renderer in /build and use those to build the electron app installer. The final executable will be found in /dist
npm run build
  • Start the application in development mode with hot module reloading. This means you can make changes in your editor and they will be instantly visible in the app.
npm run start

ROS dependencies

You need to have a small web server running in the folder containing the robot_description.

For example, for our markhor robot:

cd catkin_ws/src/markhor
python3 -m http.server 88 # launch a server with python on port 88

Note: the port for the robot_description is currently hardcoded to 88. It will be configurable in the future.

After that you need to rosrun a robot_description

rosrun tf2_web_republisher tf2_web_republisher
roslaunch web_video_server web_video_server.launch
roslaunch rosbridge_server rosbridge_websocket.launch

System dependencies

To view RTSP streams your system requires FFmpeg to be installed.

On Windows

With Chocolatey:

choco install ffmpeg

On Linux (Debian)

sudo apt install ffmpeg

On Mac

With homebrew:

brew install ffmpeg

Audio

Currently, the audio IO is handled by the capra_audio node. The UI will simply launch the node as a child process. This only works on linux. Windows support should work with wsl but is not currently implemented. For audio to work, you also need to make sure that the capra_audio launch files are sourced in the terminal you are using to launch the UI.

Global state - redux and xstate

For global state handle we use a mix of redux and xstate. While it's technically possible to use xstate context for the entirety of the global state. It's much easier to store global state in redux and only use xstate when the state is an actual state machine and not just pure data.

Code Formatting

Our code formatting is handled by Prettier and ESLint. The configuration files for both are located in the root of the project. We recommend using the Prettier and ESLint extensions on VSCode to automatically detect style errors.

To automatically format the code every time you save, add the following to your settings.json in the .vscode folder:

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

If you do not have a settings.json file or a .vscode folder at the root of the project, you can manually create them.

Release

To create a new release, simply use npm version [major | minor | patch]. This will bump the version and create a git tag. You can then push the new commit and github actions will take care of everythin else. You can use git push --follow-tags to push the tags to github.

Just make sure to make the github release public once it's done.

Usage Guide

Reverse mode

Our markhor robot doesn't have a reverse mode. Instead we simply flip the input sent from the UI to the robot. To activate this revers mode, you can either press the back button of the gamepad or click the button identified either FORWARD or REVERSE to toggle the front direction. When changing the front direction it will also automatically update which camera is focused in the center of the screen. Essentially it will toggle between the camera at the bottom left and the one in the center. It is therefore recommended to configure those cameras with directly front facing and back facing view angles.

Connecting

To connect to a robot, if you know that the IP is already configured properly, you click on the Disconnected button in the statusbar and it will immediately try to connect. Otherwise, go to the config tab, specify an appropriate IP address and press the connect button.

Config

All configurations can be found in the config tab. It is separated in multiple sections.

  • General: Contains any general purpose configs
  • Camera: Configurations related to cameras. In this page you can add as many camera as you have. You can also modify things like the type of camera or the orientation. Every camera added here will be available in the dropdown of each feed.
  • Graph: This page is very similar to the camera page, but instead it's to add topics that constantly publish data to be shown in a graph. Like for the cameras, each graph added will be available in any feed.
  • Gamepad: Right now this only shows the current mapping of the gamepad. Eventually it will be possible to modify the bindings directly.

Logging

Since the UI is built on top of electron, there's a sandbox between the web part of the app and the node part of the app. The logs from both parts are configured to log to a file that changes daily.

Logs are written to the following locations:

  • Linux: ~/.config/capra_web_ui/logs/{DATE}/{process type}.log
  • Windows: %USERPROFILE%\AppData\Roaming\capra_web_ui\logs\{DATE}\{process type}.log

Testing ROS features locally

To test ROS features without connecting to a robot you simply need to specify localhost as the host to connect to while a rosbridge web_socket node is running.

To run the rosbridge server simply open a terminal and run the following command:

roslaunch rosbridge_server rosbridge_websocket.launch.

If the package is not installed you can install it:

sudo apt-get install ros-<rosdistro>-rosbridge-suite.

capra_web_ui's People

Contributors

amdeimos666 avatar balnian avatar benmalenfant avatar clubcapra-robot avatar dependabot[bot] avatar glduval avatar icesentry avatar leo-dan avatar leuchak avatar lvanasse avatar myriamlacroix avatar patates-cipsi418 avatar saxtot avatar simonr99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capra_web_ui's Issues

Auto detect robot IP address (web servers/services)

Description:

Add a UDP listener on a predetermined port to listen to a broadcast from a robot containing the robot's rosbridge and video server address.

Broadcast will come from a node on the robot.
The broadcast will contain a Robot Web Services ( RWS ) message which is a JSON structure giving:

  • Version of the protocol (1.0.0)
  • Robot's Name (Takin)
  • Web API provider address (Rosbridge)
  • Web Video Server address (Web_video_server)

This would be connected to a Combo Box in the UI to display a list of broadcast received to choose from and still allow to enter a manual address and have cached values.

Preliminary numbers:

  • Broadcast is every 0.5 seconds

  • Values stored expire after 1.5 seconds after last broadcast received (aka every broadcast reset the expiration timer)

Tasks:

  • UDP listener in electron
  • Combo box in UI
  • Backing store???

Embedded terminal

Add a terminal to the ui that will automatically connect the robot and makes it easier to configure things directly on the robot.

Some work has been done in the embedded_terminal branch. Unfortunately, since we switched to Snowpack to bundle the project this broke the ssh2 dependency. Essentially, snowpack can't read .node files. We need a workaround to either load these files or to modify the dependency so it doesn't need to load that file. The file seems to be used to do cpu detection, but since we are using known hardware we could probably hardcode the result.

Two-way audio communication

Right now, we simply spawn a ros_audio_common node process on the machine and just assume it works. See the audio_process branch.

We investigated using web rtc but the ros node uses an old version of the protocol and there were issue getting it to work. This is still a possible option.

The goal would be to have something that uses web apis and doesn't rely on the system spawning a ros node.

Picture in picture mode

A camera component that can show 1 big camera and 4 smaller ones in each corner

  • Main camera
  • Corner Cameras
  • Toggle main camera
  • Nice to have:
    • Drag smaller cameras
    • resize smaller cameras

Electron

  • Wrap the current ui with electron
  • If possible keep the ui working on the web too.

Custom keybinding

Figure out a way to allow for a custom keybinding for specific actions.

For example, we should be able to define a keybind for the e-stop and it should be able to activate from the spacemouse/gamepad/keyboard

Custom profiles

  • Serialize all configurations
  • Load serialized configurations
  • Save the configurations with a profile name
  • Load a specific profile
  • Add a way to see all the available profiles
  • Create a default profile with minimal configurations

The profiles should store any modified configuration. Both in the config page and for each feed in each tab.

For example, if someone decides that the Victim tab should have a thermal camera in the top left and a rgb camera in the middle and a co2 graph in the top right. This feature should save all of this.

Some of the state is already saved by serializing the redux store directly. This isn't done for any state stored in state machines. It also doesn't handle multiple profiles.

Launch ROS .launch file through the web UI

We want to be able to launch ROS launch file through the web UI so that we can set up the robot without login into it. So, through the web UI users will be able to launch as an example the base launch file to control the robot with the controller.

Gamepad config

  • show current buttons
  • show dynamic buttons based on configurable mappings
  • configurable mappings

This would mostly be resolved by #56 since the original issue was simply to make the gamepad configurable

A nice feature would be to then display the configured mapping in the Gamepad tab of the config page

Blocked on #56, but it would be possible to make the gamepad display more dynamic and prepare it to eventually support the dynamic input display.

Mission management

  • Start/Stop mission
  • Display mission timer
  • Load mission
  • Download mission file locally

Improve input handling

create a new input system

  • allow keyboard and gamepad bindings for the same action
  • enable/disable specific actions when necessary // You can change the current actionMap or stop an input system
  • support spacemouse
  • give a context object when an action is performed that contains things like the gamepadState that triggered the action
    - [ ] create a useInputAction() hook // out of scope

Victim Page

Should display:

  • Video stream of:
    • Motion
    • Thermal
    • Hazmat
    • Normal
  • CO2
  • Sound

Add a dropdown list for IP address selection

Add a dropdown list to select the robot name you'd like to connect to.

For example: takin -> 192.168.0.100:9090

Should also have an option to use a manual input IP and port

Could use a separator in the list to isolate the manual option.
dropdown_list

Arm Page

Should display:

  • Multiple streams
    • Arm view
    • Overhead view
  • 3D Model

Debug Page

  • subscribe to /rosout and print the output.
    • Try to remove any old output after a specified amount. For example, if there are 200 logs, remove the oldest 100 logs
  • filter /rosout
    • topic
    • msg_type
  • Save as txt (nice to have but not necessary)
  • Toggle visibility of tab in the config page since it isn't necessary in a competition
  • Keep a list of the topics that emitted an ERROR to simplify debugging

The way I see this, it could be in a new Debug tab that could be hidden through a settings in the config page. The implementation doesn't have to be fancy, we just want to see the content of /rosout while looking at this page. A good implementation should unsubscribe when leaving the tab to avoid wasting resources on this.

Investigate communication between main thread and render thread

We should look into communicating between the main thread and the render thread of electron using ipc. We will probably need to override the webpack config.

This feature isn't currently needed but supporting it right now will make it easier to work with electron in the future.

Status bar improvement tracking issue

Tracking issue for potential improvements to the status bar

  • Ping (network delay)
  • Temperature
    • Motor
    • Batteries
  • Time display
    • Current Time
    • Mission Timer
  • Battery level

Teleop Page

Should display:

  • Multiple Cameras
  • Minimap
  • Robot display 3D
  • Dashboard

adjust gamepad curve

Currently the gamepad throttle uses a linear curve which makes the input extremely sensitive. To fix this we should use a logarithmic curve to reduce how sensitive it is.

Electron CI

  • build the electron version on tagged commit to master
  • release to github

Port to react

We are considering porting to react for further development. We need to try it first.

  • Setup react
  • Setup PWA
  • Port basic layout
  • Port currently supported features

Switch forward direction

We want to be able to change the forward direction of the robot in the client side. The implementation should just be flipping the appropriate axis of the republished gamepad.

The forward direction could be a state added to the context of the control state machine.

Show battery level

Add a battery display to the status page

  • display battery indicator with dynamic level
  • subscribe to published battery level
  • add a popup that shows each battery separately

The display battery level part should be fairly easy for a first issue, subscribing to a battery level topic too, but currently there is no backend implementation of this, so it's not a particularly useful feature.

Gamepad

  • contextual menu (weapon wheel)
  • toggle front direction
  • estop
  • movement
  • switch tabs
  • change flipper position
  • toggle light
  • ptt

Picture in picture mode

  • Change layout to better support picture in picture mode
  • Setup keybind to toggle between cameras

System Page

Maybe include it in debug page as a sub page

  • launch node
  • Category
  • Kill all
  • status

Config page for input system

The new input system is configurable in code, but a user can't change the code.

  • Create input config page
  • Represent the current config
  • Modify the current config

Map Viewer Feed

  • 2D view
  • 3D point cloud

Some experiments have been done in the 2d_map_viewer_feed branch. Unfortunately, the ROS2D lib doesn't play well at all with modern tooling.

The code isn't actually that complicated so the current planned approach is to rewrite the parts that we need using modern tools. Once we have something stable we should consider publishing it since it could be useful to many other people in the ROS community.

EStop button should display robot state

  • Changes the text to "rearm" and change button color to yellow when the estop is activated on the robot
  • Show unavailable and grey out the button when not connected and when no data has been published for more than X seconds.

The node is technically implemented on the robot, but it hasn't been tested for a long time. The react code is also probably not up to date either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.