Skip to content

vex-76513/pros-grafana-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pros Grafana Lib

 

PROS Grafana CLI

Github top language

🚧 This library is still highly experimental 🚧


About   |   Features   |   Technologies   |   Requirements   |   Starting   |   Usage   |   Author


🎯 About

This project aims to improve the VEX Robotics development process by allowing statistics to easily be recorded by a V5 brain and in realtime be sent to a Grafana dashboard. The PROS Grafana Library consists of three parts:

  • The PROS C++ template
  • The PROS-Grafana CLI, adding a custom command for brain interaction (this repository)
  • (Unfinished) The optional Grafana plugin allowing for custom visualization of data such as absolute positioning

✨ Features

✔️ Easily track multiple objects at once
✔️ Easy chart and visualization creation
✔️ Wireless support

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, make sure you have already followed all of the steps in the PROS Grafana Library repository.

🏁 Starting

You can install the PROS Grafana CLI using the following steps:

# Clone the project to the current directory
$ git clone https://github.com/BWHS-Robotics/pros-grafana-cli

# Access
$ cd pros-grafana-cli

# Install the CLI as a pip package 
$ pip install -e . 

Whenever you want to begin recording information, use the following command before you start the program:

$ prosgrafana

The command will also act like a PROS terminal, and will display whatever readings it receives from the brain.

📝 Sending it to Grafana

When you use the command prosgrafana, any data received by the brain will automatically be written to a file labelled guidata.sqlite. Grafana will need to know where this is located on your computer in order to display the information.


Ensure you have already setup a Grafana server by following the steps here. Once installed, the dashboard should be able to be opened by visiting http://localhost:3000, where both the username and password are by default admin:

image

⚙️ Configuring Grafana

As Grafana does not natively support SQLite as a data source, we'll be using the frser-sqlite-datasource plugin. Follow the instructions below to install it:

  • Hover over the Gear icon on the left side of the dashboard and click Plugins
  • In the Search Grafana plugins box, search for SQLite
  • Click on the Install button for the plugin
Settings Navigation

Now that the plugin is installed, go back to the Settings menu and instead select the Data Sources tab. You should see a large blue button labelled Add data source.

image

After pressing it, find SQLite and click the Select button. For the Path input box, enter the absolute path to where your guidata.sqlite file is located. Hitting the Save & test button should result in a green checkbox and the text "Data source is working." An image for reference can be seen here:

Settings Navigation

Grafana should now be ready to read any data from the program and display it in whatever visualization desired.

➕ Creating dashboards

Now that you can access the robot data, you can create a new dashboard by navigating to the following option: image

This should lead you to a new page, where you can add as many panels as you want. In this example, we'll be creating a chart displaying the velocity readings of the chassis.

  • Select the Add an empty panel option
  • In te top right, make sure the type of panel is a Time series
  • In the Query tab, change the Data source to SQLite

Your page should now look something like this:image

We can now move onto the final segment: querying the SQLite file for data.

📝 Writing queries

As the file that stores information is .sqlite, queries will be using the SQL language in order to fetch data. A few examples can be seen below:

Fetching ALL statistics being tracked

SELECT * from data

Fetching a specific value requires knowing the names for variables you gave in the C++ library.

For example, if I named a motor Variable "Left Front Motor" and tracked "Actual Velocity", you would fetch it using this query:

SELECT time, "Left Front Motor Actual Velocity" from data

Notice how time also has to be included for Grafana to know when certain values occur. You can fetch as many variables as you want, however there must be a ',' character between each.

Once you're done, you can hit the "Apply" button and rearrange the chart in any fashion.

✨ Other features offered by Grafana

Charts are just a tiny portion of what Grafana can do with data. You can find a list of the available visualizations here.


Made with ❤️ by Ryder

 

Back to top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%