Lavizu: web-based visualisation for robots
Table of contents
- Lavizu: web-based visualisation for robots
Purpose
Lavizu is a graphical user interface for ROS-based systems. IT aims at letting you easily build custom user interface components for your own needs, using the many libraries and tools available for the web, such as D3 and SVG for visualisation.
Dependencies
- NodeJS (for compilation)
- NPM or YARN (for the dependency managment)
D3 integration with React
We experimented on how to make charts and diagrams that exploit the power of D3 but within the context of React. The challenge resides in both libraries wanting to modify the DOM (basically, the web page) at the same time.
As an illustration of this experiment, you can compare a pure D3 line chart and a version integrated in React. To do so, install the dependencies of this repository, open a terminal and change directory to this folder. Then, type npm start
(or yarn start
, if you have Yarn). This will open a web page containing a few "tabs" or widgets, among which a line chart. This is the React integrated version of the line chart. To view the pure D3 version, go to http://localhost:3000/LineChart.html.
Now, the main interest of these two versions, is to see how they are implemented. The code for the former is in the folder src/LineChart
, whereas for the latter it lies in public/LineChart.html
.
Create a new widget type
Lavizu has little value as a general purpose ROS tool, compared to the feature-rich [rqt][https://wiki.ros.org/rqt]. Actually, we do not intend to make a contender to rqt nor reinvent too many kinds of wheels. Conversely, Lavizu is meant to ease the creation of custom visualisation and user interface, thanks to the web technologies.
Run in test environment
We recorded a learning session so that the visualisation tool can be tested alone. To replay this learning session in a loop, run the following commend form this repository's folder:
rosbag play --clock --loop test-data/rd-dai-1.bag
Available Javascript Scripts
This project was bootstrapped with Create React App.
In the project directory, you can run:
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
npm test
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
npm run build
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
npm run eject
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
Reading material
Refreshing your memory on Javascript
A re-introduction to Javascript (Mozilla Developper Network)
Some reading on SVG
An SVG Primer for Today's Browsers
About D3 and React
- Silky smooth Piechart transitions with React and D3.js is key to the question of integration of D3 charts in React. It also mentions a $50 book that just discusses this matter
- How (and why) to use D3 with React is more generic, on how to use D3 and React. It also lists the D3 modules that want to affect the DOM (just 8/30).
- https://github.com/joelburget/d4 also copes with animations and goes further with the idea that React might as well do most of the job
Sizing of the Widgets
Some of the widgets might have a prefered size, in which case we should make Flex Layout aware of it. Documentation on prefered size.
Some other widgets might adapt to the available space and take it all. Determining the dimensiosn of elements.
Other links: