Difference between revisions of "ECE434 Project - Vehicle Telemetry"

From eLinux.org
Jump to: navigation, search
(Installation Instructions)
m
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:ECE497 |PVehicle Telemetry]]
 
 
[[Category:ECE434Fall2022 |PVehicle Telemetry]]
 
[[Category:ECE434Fall2022 |PVehicle Telemetry]]
 
{{YoderHead}}
 
{{YoderHead}}
  
Team members: [[user:Sqz|Jason Su]] [[user:wuq|Harris Wu]]
+
Team members: [[user:Sqz|Jason Su]] [[user:harris|Harris Wu]]
  
 
== Grading Template ==
 
== Grading Template ==
Line 29: Line 28:
 
== Executive Summary ==
 
== Executive Summary ==
  
Use extended Kalman filter to integrate GPS and IMU data to achieve a decimeter level accuracy for the position and velocity of a vehicle. Combine with data logged from the CAN bus to build a server as a platform for implementing some apps, such as lap time, accel/brake time for analysis purpose.
+
This project uses a beaglebone with a cape to build a data logger for vehicles. It uses an extended Kalman filter to integrate GPS and IMU data to achieve a decimeter level accuracy for the position and velocity of a vehicle, and combine with data logged from the CAN bus to build a server. The server is able to real time visualize the data on a webpage. It can be used as a platform for implementing some apps, such as lap time, accel/brake time for analysis purpose.
  
'''Progress''':
+
== Packaging ==
 +
A beaglebone cape with IMU, GPS and CAN transceiver.
  
We have made a Kalman filter on MATLAB, and have it running on BeagleBone using simulated data.  
+
GPS breakout board: https://www.adafruit.com/product/746 
  
We have made the GPS sensor working on the BeagleBone, and read from it at a desire interval.  
+
IMU breakout board: https://www.amazon.com/HiLetgo-MPU-6050-Accelerometer-Gyroscope-Converter/dp/B078SS8NQV 
  
We have made a server using Flask to hold webpage for dynamic visualizing data on wsl.  
+
CAN transceiver: https://www.ti.com/product/SN65HVD230 
  
We have designed and ordered a PCB for BeagleBone with GPS, IMU and CAN transceivers.
+
 +
== Installation Instructions ==
 +
'''Hardware'''
  
We have OBDII working, and is able to log engine RPM of my car.
+
1. Connect GPS to UART
  
End with a two sentence conclusion.
+
2. Connect IMU to I2C2
  
The sentence count is approximate and only to give an idea of the expected length.
+
3. Connect CAN to CAN1
  
== Packaging ==
+
'''Software'''
A beaglebone cape with IMU, GPS and CAN transceiver.
 
 
== Installation Instructions ==
 
1. Install MPU6050 device tree: BB-I2C2-MPU6050
 
  
2. Set up MPU6050 on I2C2 at 0x68
+
1. Put BB-I2C2-MPU6050 into uEnv.txt and reboot.
  echo mpu6050 0x68 > new_device
 
  
3. Install gpsd:  
+
2. Get the project:
  sudo apt-get install gpsd
+
  $ git clone git@github.com:Sqzlnsy/ece434Project.git
   
 
4. Config CAN:  
 
  sudo config-pin p9.24 can // CAN1 RX
 
  sudo config-pin p9.26 can // CAN1 TX
 
  
5. Start gpsd:
+
3. Run ece434Project/install.sh and you can go to step 7
  sudo service gpsd start
 
  
6. Check the status gpsd:  
+
4. Set up MPU6050 on I2C2 at 0x68:
   cgps  //It may take a couple of minutes for the GPS to capture enough satellites depending on the weather and area.
+
   $ cd /sys/class/i2c-adapter/i2c-2
 +
  $ echo mpu6050 0x68 > new_device
  
7. Start CAN link:  
+
5. Install gpsd:  
   sudo ip link set can1 up type can bitrate 500000  // Usually CAN bus data rate on cars are 500kbit/s, but it may change depends on vehicle model.
+
   $ sudo apt-get install gpsd
  sudo ifconfig can1 up
 
  
  reference link: https://www.thomas-wedemeyer.de/de/electronic/arm/beaglebone/canbus-python/
+
6. Install python-can:
 +
  $ pip install python-can
  
Give step by step instructions on how to install your project.
+
7. Config gpsd:
 +
  $ nano /etc/default/gpsd
 +
You will see the config file and change DEVICES="/dev/ttyS0" to the port you use. (ttyS0 is uart1)
  
* Include your [https://github.com/ github] path as a link like this to the read-only git site:  [https://github.com/MarkAYoder/gitLearn https://github.com/MarkAYoder/gitLearn].
+
8. Run setup.sh
* Be sure your README.md is includes an up-to-date and clear description of your project so that someone who comes across you git repository can quickly learn what you did and how they can reproduce it.
+
 
* Include a Makefile for your code if using C.
+
git site:  https://github.com/Sqzlnsy/ece434Project
* Include any additional packages installed via '''apt'''.  Include '''install.sh''' and '''setup.sh''' files.
 
* Include kernel mods.
 
* If there is extra hardware needed, include links to where it can be obtained.
 
  
 
== User Instructions ==
 
== User Instructions ==
1. Run make to compile
+
1. Go to the project directory
 +
    $ cd ece434Project
 +
1. Run make to compile if needed
 +
    $ make 
 +
3. Check the status gpsd:
 +
  cgps  //It may take a couple of minutes for the GPS to capture enough satellites depending on the weather and area.
  
2. Run setup.sh to run the program
+
4. Connect to the OBDII port on your car.
  
3. Go to http://192.168.7.2:8081/ to see the real time visualized data
+
5. Check the connection of CAN bus:
 +
  candump can1
 +
 
 +
6. If you can see gps information using cpgs, and can messages using candump, you are ready to start the program.
 +
 
 +
7. Run run_background.sh (Terminate the program by run process_terminate.sh)
 +
 
 +
8. Go to http://192.168.7.2:8081/ to see the real-time visualized data
 
   
 
   
Once everything is installed, how do you use the program?  Give details here, so if you have a long user manual, link to it here.
 
  
Consider making it autostart for full credit.
+
== Highlights ==
 +
We are almost able to get all the data that OBD2 Interface provides. How OBD2 works is that it listens for request and if you send it a request it will return you a data.
  
== Highlights ==
+
We have both front end task (server.py) and backend task (futionT), front end uses canvas to plot the data which came from back end, it drags multiple lines from the datalog file (see data folder) and plot them all at a specific frequency (see server.sh and js file in the templates)
  
Here is where you brag about what your project can do.
+
The back end is the one that consumes the CPU Usage the most. Since this device is used to record the data in the vehicle, we want to ensure that it keeps updating at a certain frequency. The maximum frequency that IMU can sample is 160 Hz, but we noticed that it takes too much CPU usage (>=92%), we lowered this frequency to 100Hz. Another reason why we lowered the frequency is that for our non real time kernels, it is difficult to make the sampling rate exactly as expected.  
  
 
Include a [http://www.youtube.com/ YouTube] demo the audio description.
 
Include a [http://www.youtube.com/ YouTube] demo the audio description.
Line 103: Line 107:
 
== Theory of Operation ==
 
== Theory of Operation ==
  
Give a high level overview of the structure of your software. Are you using GStreamer?  Show a diagram of the pipeline. Are you running multiple tasks?  Show what they do and how they interact.
+
For gps, we used gpsd module to get the data from the peripheral. To be specific, we used gpsstream() to read the data from the device.
 +
For IMU, we used I2c to communicate with the device. What we did was simply adding the device tree to the kernel and constantly read the raw data from the device tree and process the data in our program. Save the processed raw data and send it to the Kalman filter.
 +
For CAN, we used python and a can transceiver to communicate with the vehicle. It is able to get the data after sending a request to the vehicle. See CAN_LOG.py
 +
Front End Task: We used canvas to plot the data in the localhost, the port is at 8082 so the website that you need to go to is http://192.168.7.2:8082/ after the server.py and fusionT both starts. In the website, multiple plots can be added to the page upon click on the options e.g. AccelerationX, Acceleration Y, RPM etc.
  
 
== Work Breakdown ==
 
== Work Breakdown ==
  
List the major tasks in your project and who did what.
+
{| class="wikitable"
 
+
|-
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.
+
! Tasks !! Person
 +
|-
 +
| Data log || Harris
 +
|-
 +
| Back End webserver || Harris
 +
|-
 +
| Extended Kalman filter || Jason
 +
|-
 +
| Web frontend || Jason
 +
|-
 +
| OBDII || Jason
 +
|}
  
 
== Future Work ==
 
== Future Work ==
  
Suggest addition things that could be done with this project.
+
The extended Kalman filter still needs more work to provide higher accuracy. It would be better to have the beaglebone connect to the car wirelessly through a wireless adaptor. Some applications can be developed based on this platform, such as lap time, 0-60mph, a quarter mile and so on.
  
 
== Conclusions ==
 
== Conclusions ==
  
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.
+
In this project, we used many modules including but not limited to : GPSD, CANBUS, I2C, Device tree, flask,canvas, server, uart and kalman filter.
 +
 
 +
The code part can still be improved since the CPU usage can be decreased by code optimization. Also, the sampling can be more accurate by using real time kernel.
 +
 
 +
We didn't expect the 1GHz processor not able to handling 160 Hz IMU well, so if possible, we'd like to try to optimize our program or have it run on a more power processor.  
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Latest revision as of 14:20, 27 November 2023

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Jason Su Harris Wu

Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

Add Extras

09 Executive Summary
09 Packaging
09 Installation Instructions 
09 User Instructions
09 Highlights
09 Theory of Operation
09 Work Breakdown
09 Future Work/Conclusions
09 Hackster.io
09 Demo/Poster
00 Not Late

Score:  90/100

Executive Summary

This project uses a beaglebone with a cape to build a data logger for vehicles. It uses an extended Kalman filter to integrate GPS and IMU data to achieve a decimeter level accuracy for the position and velocity of a vehicle, and combine with data logged from the CAN bus to build a server. The server is able to real time visualize the data on a webpage. It can be used as a platform for implementing some apps, such as lap time, accel/brake time for analysis purpose.

Packaging

A beaglebone cape with IMU, GPS and CAN transceiver.

GPS breakout board: https://www.adafruit.com/product/746

IMU breakout board: https://www.amazon.com/HiLetgo-MPU-6050-Accelerometer-Gyroscope-Converter/dp/B078SS8NQV

CAN transceiver: https://www.ti.com/product/SN65HVD230


Installation Instructions

Hardware

1. Connect GPS to UART

2. Connect IMU to I2C2

3. Connect CAN to CAN1

Software

1. Put BB-I2C2-MPU6050 into uEnv.txt and reboot.

2. Get the project:

$ git clone git@github.com:Sqzlnsy/ece434Project.git

3. Run ece434Project/install.sh and you can go to step 7

4. Set up MPU6050 on I2C2 at 0x68:

  $ cd /sys/class/i2c-adapter/i2c-2
  $ echo mpu6050 0x68 > new_device

5. Install gpsd:

  $ sudo apt-get install gpsd

6. Install python-can:

  $ pip install python-can

7. Config gpsd:

  $ nano /etc/default/gpsd

You will see the config file and change DEVICES="/dev/ttyS0" to the port you use. (ttyS0 is uart1)

8. Run setup.sh

git site: https://github.com/Sqzlnsy/ece434Project

User Instructions

1. Go to the project directory

   $ cd ece434Project

1. Run make to compile if needed

   $ make   

3. Check the status gpsd:

  cgps  //It may take a couple of minutes for the GPS to capture enough satellites depending on the weather and area. 

4. Connect to the OBDII port on your car.

5. Check the connection of CAN bus:

  candump can1

6. If you can see gps information using cpgs, and can messages using candump, you are ready to start the program.

7. Run run_background.sh (Terminate the program by run process_terminate.sh)

8. Go to http://192.168.7.2:8081/ to see the real-time visualized data


Highlights

We are almost able to get all the data that OBD2 Interface provides. How OBD2 works is that it listens for request and if you send it a request it will return you a data.

We have both front end task (server.py) and backend task (futionT), front end uses canvas to plot the data which came from back end, it drags multiple lines from the datalog file (see data folder) and plot them all at a specific frequency (see server.sh and js file in the templates)

The back end is the one that consumes the CPU Usage the most. Since this device is used to record the data in the vehicle, we want to ensure that it keeps updating at a certain frequency. The maximum frequency that IMU can sample is 160 Hz, but we noticed that it takes too much CPU usage (>=92%), we lowered this frequency to 100Hz. Another reason why we lowered the frequency is that for our non real time kernels, it is difficult to make the sampling rate exactly as expected.

Include a YouTube demo the audio description.

Theory of Operation

For gps, we used gpsd module to get the data from the peripheral. To be specific, we used gpsstream() to read the data from the device. For IMU, we used I2c to communicate with the device. What we did was simply adding the device tree to the kernel and constantly read the raw data from the device tree and process the data in our program. Save the processed raw data and send it to the Kalman filter. For CAN, we used python and a can transceiver to communicate with the vehicle. It is able to get the data after sending a request to the vehicle. See CAN_LOG.py Front End Task: We used canvas to plot the data in the localhost, the port is at 8082 so the website that you need to go to is http://192.168.7.2:8082/ after the server.py and fusionT both starts. In the website, multiple plots can be added to the page upon click on the options e.g. AccelerationX, Acceleration Y, RPM etc.

Work Breakdown

Tasks Person
Data log Harris
Back End webserver Harris
Extended Kalman filter Jason
Web frontend Jason
OBDII Jason

Future Work

The extended Kalman filter still needs more work to provide higher accuracy. It would be better to have the beaglebone connect to the car wirelessly through a wireless adaptor. Some applications can be developed based on this platform, such as lap time, 0-60mph, a quarter mile and so on.

Conclusions

In this project, we used many modules including but not limited to : GPSD, CANBUS, I2C, Device tree, flask,canvas, server, uart and kalman filter.

The code part can still be improved since the CPU usage can be decreased by code optimization. Also, the sampling can be more accurate by using real time kernel.

We didn't expect the 1GHz processor not able to handling 160 Hz IMU well, so if possible, we'd like to try to optimize our program or have it run on a more power processor.




thumb‎ Embedded Linux Class by Mark A. Yoder