Coder Social home page Coder Social logo

kmzbrnoi / automatic-calibration Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 811 KB

Automatic Calibration desktop SW

Home Page: https://wsm.kmz-brno.cz/auto-calib

License: Apache License 2.0

Shell 0.05% QMake 1.59% C++ 98.36%
qt desktop xnpressnet calibration hc05 wsm

automatic-calibration's Introduction

Automatic Calibration SW

Automatic Calibration SW is a desktop application which allows you to automatically calibrate your model train vehicle. It requires a Wireless Speedometer and XpressNET command station connected to PC via LI and (virtual) serial port.

Calibrating = assigning power to each of 28 speed steps so specific speed steps fit specific real speed. E. g. step 15 = 40 km/h, step 17 = 50 km/h etc. This assignment is defined by user and this application loads it from file 'speed.csv'. The main aim of this application is to do this 'assignment' automatically.

How does it work? Application assigns power to each speed step of the DCC decoder in the train and then measures real speed of the train. It repeats this process until the correct speed is assigned to the speed step. And the again for different speed step and different real speed...

This application is developed in QT v5 or v6.

Resources

Building & toolkit

This SW was developed in vim using qmake & make. Downloads are available in Releases section. It is suggested to use clang as a compiler, because then you may use clang-tools during development process (see below).

Prerequisities

  • Qt 5/6
  • Qt's serialport
  • Qt's charts
  • Optional: clang build tools (see below)
  • Optional for clang: Bear

Example: toolchain setup on Debian 12 Bookworm

$ apt install qt6-base-dev qt6-charts-dev qt6-serialport-dev
$ apt install clang clang-tools clang-tidy clang-format
$ apt install bear

Build

Clone this repository (including submodules!):

$ git clone --recurse-submodules https://github.com/kmzbrnoI/automatic-calibration

And then build:

$ mkdir build
$ cd build
$ qmake6 -spec linux-clang ..
$ bear -- make

To make debug binary, run:

$ qmake6 -spec linux-clang CONFIG+=debug ..
$ make

You may use this script to debug segfaults.

Connecting to WSM

  • Windows: pair it with HC-05 module, serial port should be added automatically

  • Linux: pair it with HC-05 module and map it to new serial device:

    $ rfcomm connect /dev/rfcomm0 hc-05-hw-address 2

Project description

This project consists of several C++ classes defined in header files and its implementations defined in .cpp files. All classes are described in diagram below:

Class diagram

Squares are classes (in this project singletons), the arrow represents relationship owns. Red classes are Window classes, MainWindow basically owns everything, yellow classes are libraries, blue classes are managers and green classes are helpers.

Basically all the managers use all the libraries and helpers. Helpers are connected to GUI to visualize its states. Libs and helpers are passed to managers as references.

CalibMan manages whole process of calibration divided into two phases (CalibOverview, CalibStep), see calib-man.h for more information.

All visualized classes inherit from QObject and usually communicate with outer world by receiving function calls and calling Qt's signals.

Each header file contains a docstring, so see it for more information.

Configuration

The binary loads general configuration from config.ini file located in the directory where the binary is executed from. This file is created once the application is run for the first time. Inspect it and configure the app according to your requirements. Configuration cannot be done from GUI, it is done just through the config file. Config could be reloaded at runtime.

Loco-specific configuration could be loaded from & saved to xml file according to the format of loco of JMRI.

Speed table is loaded from speed.csv file, where each line is of format step;speed:

6;10
15;40
17;50
...

Style checking

$ clang-tidy -p build src/*.cpp
$ clang-format *.cpp *.h

Authors

License

This application is released under the Apache License v2.0 .

automatic-calibration's People

Contributors

horacekj avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

automatic-calibration's Issues

Přidat relativní měření odchylky rychlosti

Správné rychlosti je dosaženo když:

  • diffusion je dostatečně malá
  • rychlost je očekávaná rychlost +- x % (zadat jako parametr) nebo v toleranci lepší než než 0.5 km/h odchylka

calib-* review

calib-step.h

  • I don't think that "diffusion" is the right word for instability in speed
  • names starting with an userscore followed by an uppercase letter (or another underscore) are reserved for library implementation and must not be used in user code; it does not matter if they are local/static or constexpr (one of the reason is to allow the library to safely use macro names starting with these characters)
  • what is OSC (as in _OSC_MAX_COUNT)?
  • some of the names of private functions/slots are unclear

calib-step.cpp

  • line 82: constructor cast might be more readable (but this is also OK), but definitely needs spaces around -
  • I guess the two disconnects are the same in both occurrences, maybe factor them out? Maybe even put the connects to a function for symmetry (but that might make orientation in control flow harder :-/)
  • please use spaces around operator - (l 62); it is seriously unreadable without it (and you use spaces around other operators, so it is also inconsistent)
  • "manually" increasing step when is too small should also be in a separate function (which, if well named, would also eliminate the need for the comment)
  • the end of wsm_lt_read seems the same as the end of calibrate
  • what is the reason to work with even and odd indices separately in is_oscilating?

Readme & build suggestion

  • information about dependencies is missing from README
  • README mentions releases, but not how to install from a release, only from git
  • it would be nice to have a script (or top-level Makefile) which fully automates the build process

Při zapisování stupňů zapsat i oba sousední stupně

Zimo MX i MS berou v potaz i sousední stupně – asi problém přepočtu 28 stupňů do interní reprezentace.

Zapsat oba sousední stupně:

  • Při finální kalibraci (nějak interpolovat?)
  • Při iniciálním zjišťování rychlosti (nastavit na stejnou rychlost)

Build: Unknown module(s) in QT: serialport charts

$ git clone https://github.com/kmzbrnoI/automatic-calibration
$ cd automatic-calibration
$ git submodule update -i
$ mkdir _build
$ cd _build
$ qmake ..
Project ERROR: Unknown module(s) in QT: serialport charts

Maybe missing dependencies?

Notifikace

  • Zvukové když je třeba obsluha
  • Výrazně zobrazit stav: probíhá, chyba, hotovo.

Zdůraznit chybu.

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.