diff --git a/car/car.py b/car/car.py index 1b5735a..2f0b0a8 100644 --- a/car/car.py +++ b/car/car.py @@ -31,11 +31,12 @@ print("GPS ERROR") sys.exit() -proc=subprocess.Popen(["./mavlink-routerd", "-c", "TF-GCS.conf"]) -time.sleep(5) -qgcproc=subprocess.Popen(["./QGroundControl.AppImage"]) +#proc=subprocess.Popen(["./mavlink-routerd", "-c", "TF-GCS.conf"]) +#time.sleep(5) +#subprocess.Popen(["./QGroundControl.AppImage"]) -connection = mavutil.mavlink_connection('tcp:127.0.0.1:5760',source_system=1,source_component=139) +#connection = mavutil.mavlink_connection('tcp:127.0.0.1:5760',source_system=1,source_component=139) +connection = mavutil.mavlink_connection('udpin:127.0.0.1:14445',source_system=1,source_component=139) connection.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_ONBOARD_CONTROLLER, mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0) @@ -73,8 +74,9 @@ msg = connection.recv_match(blocking=True,timeout=5) if msg: #update data and send to server - print("MSG:",msg.get_type()) + print("MSG:", msg.get_type(), msg) if msg.get_type() in messages: + k = msg.get_type() members=vars(msg) changetime=str(datetime.datetime.utcnow()) for m in messages[msg.get_type()]: @@ -83,10 +85,13 @@ sended=False if msg.get_type()=="GPS_RAW_INT": + #print(msg) + #print(type(msg)) + #print(msg.lat) state["lastPosUpdate"]=str(datetime.datetime.utcnow()) - state["latitude"]=float(msg["lat"])/10000000.0 - state["longitude"]=float(msg["lat"])/10000000.0 - state["altitude"]=float(msg["alt"])/1000.0 + state["latitude"]=float(msg.lat)/10000000.0 + state["longitude"]=float(msg.lon)/10000000.0 + state["altitude"]=float(msg.alt)/1000.0 print(state["lastPosUpdate"]," ",state["latitude"]," ",state["longitude"]," ",state["altitude"]) sended=False @@ -111,6 +116,7 @@ #try send try: print("Sending Data to CDP") + print(state) response = requests.post(f"{cdpAddres}{dataEndPoint}", json=state) print(response) @@ -120,7 +126,3 @@ except Exception as e: print("Error couldnt send Data to CDP",e) - - - -