Driving jetbot with gamepad and see the camera imge

Hi,

im new on this forum. I just started (3 weeks ago) with jetbot.

is it possible to see the image from camera (PC), while driving with gamepad?

In bottom code i only want to recieve data from gamepad but im not succesfull, program crashes on “code = outGamepad.get()”

My code for gamepad controlling the jetbot is in separate program.

I tryed using multiprocessing, also with threading no success.
Is it maybe any other way to get data, and also maybe how could i run the proces for gamepad only if some but is pressed? Probably the problem is in this infinite loop for gamepad.

from multiprocessing import Process, Queue
import cv2

from inputs import get_gamepad

dispW=640
dispH=480
flip=0


# Gstreamer code for improvded Raspberry Pi Camera Quality
camSet='nvarguscamerasrc wbmode=1 tnr-mode=2 tnr-strength=1 ee-mode=2 ee-strength=1 ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! videobalance contrast=2.0 brightness=-.1 saturation=1.5 ! appsink'

def get_frame(cap):
    cap.grab()  

    retval, frame = cap.read() 

    return frame

def gamepad(outGamepad):
    #while True:
    events = get_gamepad()
    for event in events:
        print(event.ev_type, event.code, event.state)
        data=event.code
        outGamepad.put(data)
        

outGamepad = Queue(1) 
cap = cv2.VideoCapture(camSet)

p1 = Process(target=gamepad, args=(outGamepad,))

p1.start()


while cap.isOpened():

    frame = get_frame(cap)     
    cv2.imshow('Cam',frame)
    cv2.moveWindow('Cam',0,0)


    if cv2.waitKey(1)==ord('q'):
        break


    code =  outGamepad.get()

p1.terminate()

cap.release()
cv2.destroyAllWindows()  

Thank you

Hi @jaby

Can you please share the crash logs that you are saying in order to better understand the problem, specifically when you use:

code = outGamepad.get()

Also, maybe you can try using using the following pipeline examples with RTP to stream over to the PC from the Jetson:

Thanks,

Best regards,
Roberto Gutierrez,
Embedded Software Engineer,

Hi, thanks for reply.

Maybe i should be more clear and say that i am using to see the camera along with all the desktop thrue the nomachine and not directly streaming the camera.
I am also using visual code to program the jetson.

Im not getting an error. The picture doesnt show (i just get a gray window, where the image should be) and the commands from gamepad doesnt print.