Skip to content

Hack self-driving dataset from Udacity & App from streamlit

Notifications You must be signed in to change notification settings

slevin48/self-driving

Repository files navigation

self-driving πŸš—

Open in GitHub Codespaces

This project starts with 223GB of Driving Data open sourced by Udacity. The originial idea was to hack this driving dataset, the associated app and data hosted on AWS by Streamlit

Hybrid training of a self-driving car, based on both images from:

real driving data simulation data
drawing drawing

For more project on autonomous driving simulation:

Real driving data

Youtube - Neural Network driving a car

nvidia-car-hardware-setup

NVIDIA paper: End to End Learning for Self-Driving Cars

Dataset

First Download the Driving Datasets – Over 10 hours of driving data (LIDAR, camera frames and more)

aria2c Ch2_001.tar.gz-692ee7e0c63fb2212bfe4a62a39ce71ee9b16fb3.torrent

Read How to download torrents from the command-line on Linux

Untar

tar -xf Ch2_001.tar.gz

Build the docker

docker build -t udacity-reader .

Run the ROS bag reader

./run-bagdump.sh -i /data -o /output

MATLAB ROS toolbox

MATLAB rosbag Structure:

rosbag_workflow

work-with-rosbag-logfiles

>> bag = rosbag('CH03_002')

  BagSelection with properties:

           FilePath: 'C:\Users\slevin\Downloads\self-driving\CH3_002\CH03_002'
          StartTime: 1.4807e+09
            EndTime: 1.4807e+09
        NumMessages: 54456557
    AvailableTopics: [36Γ—3 table]
    AvailableFrames: {0Γ—1 cell}
        MessageList: [54456557Γ—4 table]

Available Topics:

/can_bus_dbw/can_rx                                 9376489 msgs    : dataspeed_can_msgs/CanMessageStamped 
/center_camera/camera_info                           264230 msgs    : sensor_msgs/CameraInfo               
/center_camera/image_color/compressed                264230 msgs    : sensor_msgs/CompressedImage          
/diagnostics                                          52540 msgs    : diagnostic_msgs/DiagnosticArray       (4 connections)
/ecef/                                              5287720 msgs    : geometry_msgs/PointStamped           
/fix                                                5287720 msgs    : sensor_msgs/NavSatFix                
/imu/data                                           5287726 msgs    : sensor_msgs/Imu                      
/left_camera/camera_info                             264276 msgs    : sensor_msgs/CameraInfo               
/left_camera/image_color/compressed                  264276 msgs    : sensor_msgs/CompressedImage          
/pressure                                            660965 msgs    : sensor_msgs/FluidPressure            
/right_camera/camera_info                            263840 msgs    : sensor_msgs/CameraInfo               
/right_camera/image_color/compressed                 263840 msgs    : sensor_msgs/CompressedImage          
/time_reference                                    16020574 msgs    : sensor_msgs/TimeReference            
/vehicle/brake_info_report                           660965 msgs    : dbw_mkz_msgs/BrakeInfoReport         
/vehicle/brake_report                                659917 msgs    : dbw_mkz_msgs/BrakeReport             
/vehicle/dbw_enabled                                      1 msg     : std_msgs/Bool                        
/vehicle/filtered_accel                              659858 msgs    : std_msgs/Float64                     
/vehicle/fuel_level_report                           132671 msgs    : dbw_mkz_msgs/FuelLevelReport         
/vehicle/gear_report                                 263943 msgs    : dbw_mkz_msgs/GearReport              
/vehicle/gps/fix                                      13219 msgs    : sensor_msgs/NavSatFix                
/vehicle/gps/time                                     13219 msgs    : sensor_msgs/TimeReference            
/vehicle/gps/vel                                      13219 msgs    : geometry_msgs/TwistStamped           
/vehicle/imu/data_raw                               1318634 msgs    : sensor_msgs/Imu                      
/vehicle/joint_states                               1981787 msgs    : sensor_msgs/JointState               
/vehicle/misc_1_report                               263944 msgs    : dbw_mkz_msgs/Misc1Report             
/vehicle/sonar_cloud                                  66768 msgs    : sensor_msgs/PointCloud2              
/vehicle/steering_report                             659858 msgs    : dbw_mkz_msgs/SteeringReport          
/vehicle/surround_report                              66768 msgs    : dbw_mkz_msgs/SurroundReport          
/vehicle/suspension_report                           661052 msgs    : dbw_mkz_msgs/SuspensionReport        
/vehicle/throttle_info_report                       1321946 msgs    : dbw_mkz_msgs/ThrottleInfoReport      
/vehicle/throttle_report                             659914 msgs    : dbw_mkz_msgs/ThrottleReport          
/vehicle/tire_pressure_report                         26438 msgs    : dbw_mkz_msgs/TirePressureReport      
/vehicle/twist_controller/parameter_descriptions          1 msg     : dynamic_reconfigure/ConfigDescription
/vehicle/twist_controller/parameter_updates               1 msg     : dynamic_reconfigure/Config           
/vehicle/wheel_speed_report                         1321929 msgs    : dbw_mkz_msgs/WheelSpeedReport        
/velodyne_packets                                    132079 msgs    : velodyne_msgs/VelodyneScan

GPS

bagGps = select(bag, 'Topic', '/vehicle/gps/fix');

GPS

Steering Angle

bagSteering = select(bag, 'Topic', '/vehicle/steering_report');
bagSteering.AvailableTopics

bagSteering_AvailableTopics

msgs = readMessages(bagSteering,'DataFormat','struct');
steering_angle = cellfun(@(m) m.SteeringWheelAngle,msgs);
Sec = cellfun(@(m) m.Header.Stamp.Sec,msgs);
Nsec = cellfun(@(m) m.Header.Stamp.Nsec,msgs);
time = datetime(Sec,"ConvertFrom","epochtime","Format","HH:mm:ss");
plot(time,steering_angle)
title("Steering Wheel Angle")

Steering

Retime: sub-sample to one point per second to sync with GPS

Sub-steering

Pressure

>> bagpressure = select(bag, 'Topic', '/pressure')
bagpressure = 

  BagSelection with properties:

           FilePath: 'C:\Users\slevin\Downloads\self-driving\CH3_002\CH03_002'
          StartTime: 1.4807e+09
            EndTime: 1.4807e+09
        NumMessages: 660965
    AvailableTopics: [1Γ—3 table]
    AvailableFrames: {0Γ—1 cell}
        MessageList: [660965Γ—4 table]

IMU (Inertial Measurement Unit)

>> bagselect1 = select(bag, 'Topic', '/imu/data')

bagselect1 = 

  BagSelection with properties:

           FilePath: 'C:\Users\slevin\Downloads\self-driving\CH3_002\CH03_002'
          StartTime: 1.4807e+09
            EndTime: 1.4807e+09
        NumMessages: 5287726
    AvailableTopics: [1Γ—3 table]
    AvailableFrames: {0Γ—1 cell}
        MessageList: [5287726Γ—4 table]

We have more than 5 million messages, so we will filter to get only the first 30 seconds:

>> start = bag.StartTime;
>> bagselect2 = select(bag, 'Time', [start start + 30], 'Topic', '/imu/data')

bagselect2 = 

  BagSelection with properties:

           FilePath: 'C:\Users\slevin\Downloads\self-driving\CH3_002\CH03_002'
          StartTime: 1.4807e+09
            EndTime: 1.4807e+09
        NumMessages: 12001
    AvailableTopics: [1Γ—3 table]
    AvailableFrames: {0Γ—1 cell}
        MessageList: [12001Γ—4 table]

Read selected message data

>> msgs = readMessages(bagselect2);
>> msgs{1}

ans = 

  ROS Imu message with properties:

                     MessageType: 'sensor_msgs/Imu'
                          Header: [1Γ—1 Header]
                     Orientation: [1Γ—1 Quaternion]
                 AngularVelocity: [1Γ—1 Vector3]
              LinearAcceleration: [1Γ—1 Vector3]
           OrientationCovariance: [9Γ—1 double]
       AngularVelocityCovariance: [9Γ—1 double]
    LinearAccelerationCovariance: [9Γ—1 double]

  Use showdetails to show the contents of the message

Read as timeseries

>> ts = timeseries(bagselect2)
  timeseries

  Common Properties:
            Name: '/imu/data Properties'
            Time: [12001x1 double]
        TimeInfo: [1x1 tsdata.timemetadata]
            Data: [12001x13 double]
        DataInfo: [1x1 tsdata.datametadata]

  More properties, Methods
figure
plot(ts, 'LineWidth', 3)

IMU

S3 hosting

Host the real driving dataset on AWS S3 bucket, and allow public access to the bucket

Access Photos from Python, by building a list (save list to CSV)

import os
import pandas as pd
list = os.listdir()
df = pd.DataFrame(list,columns=['photo'])
df.to_csv('photos.csv',index=False)

Display frames & steering angle with a streamlit app:

car_app.jpg

streamlit run car_app.py

Simulated driving data

self-driving-car-simulator

sim_app.jpg

streamlit run car_app.py

(Turn on wide mode in settings in the upper right of the app)

KITTI: precursor self-driving dataset

From the Karlsruhe Institute of Technology:

Resources:

self-driving-sim

About

Hack self-driving dataset from Udacity & App from streamlit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published