Jet Racer Game Pad Data Collection


I am trying to collect data from the manual control using the gamepad that came with the jet racer kit from Waveshare. What I would like to do is display what the throttle and steering values are live when using the gamepad but also save this data with a timestamp so I can use this with the recorded images dataset. Then what I would have is the image, steering and throttle data for any given time.

My python is a little rusty and I don’t seem to find a way to do this! I can record and save the images just not the data from the gamepad. Any help or pointer would be great.

Thanks in advance

Do you run the jetracer project listed in community projects?

If not, you may give it a try.

Which Ones ? I am using code from Waveshare plus my own. I am just needing a way of capturing the gamepad data for the throttle and steering probably a loop

Sadly I am sill not collecting data for the controller? Any advise and pointers would be appreciated

We have the sample:

The Waveshare looks to be from other contributors. May need other users to share experience/guidance.

All I am trying to do to data capture at the moment. Video plus throttle and steering. Having issues collecting the gamepad data !!


Thanks for reaching out.

One method would be to attach callback function to the joystick axes, or other attributes like the motor values.

These callbacks could use the python time library “time.monotonoc()” to get a monotonic timestamp. Inside these callbacks you could add these samples to say a running CSV or JSON file, depending on the format you desire.

This would save the samples asynchronously.

Please let me know if this helps or you have any questions.



Many thanks for the reply. It sort of help. Is there any example code you know of so I can look at what I am supposed to be looking doing? Many Thanks

Kind Regards


Say you wanted to record the left and right motor values, asynchronously. You could do the following

import time

def timestamp():
    return int(time.monotonic() * 1e9) # timestamp in nanoseconds

def write_sample(filename, t, value):
    # open with 'a' to append to file
    with open(filename, 'a') as f: 
        f.write("%d,%f\n" % (t, value))  # write timestamp,value CSV line

def handle_left_motor(change):
    # called when left motor value changes (see .observe below)
    value = change['new']
    write_sample("left_motor.csv", timestamp(), value)

def handle_right_motor(change):
    # called when right motor value changes (see .observe below)
    value = change['new']
    write_sample("right_motor.csv", timestamp(), value)

robot.left_motor.observe(handle_left_motor, names='value')
robot.right_motor.observe(handle_right_motor, names='value')

With this code, whenever the motor values change, the value will by dumped to a corresponding CSV file.

This may not be the ideal way to precisely log the values, but is simple and may work perfect depending on your purposes.

Please let me know if this helps or you run into issues. (as a disclaimer, I haven’t tested/executed the above code)


1 Like

Thanks for the reply, I will try this out as soon as I have figured out how to show the cam feed via opencv