For sure,
@rafael.lehmkuhl I indeed had the tab in focus, and I think some more details will help
Here’s the exact steps to reproduce the joystick issue:
- I start the autopilot firmware (in the autopilot firmware section)
- I open Cockpit and focus on it
- I start the following python script on the pi:
import json, requests, time
IP = '127.0.0.1'
def getMessage(vehicle,component,message):
response = requests.get(f"http://{IP}/mavlink2rest/v1/mavlink/vehicles/{vehicle}/components/{component}/messages/{message}").json()
return response
while True:
response = getMessage(255,240,"MANUAL_CONTROL")['message']
print(response)
time.sleep(1/25)
- I wiggle the joystick and see the values coming in as expected in the terminal output of the program
- I stop the autopilot firmware
- I refocus on Cockpit and wiggle the joystick, and the python output does indeed keep updating current values as expected (so yes, the MANUAL_CONTROL message does get sent when the vehicle is disconnected… but the next step is where things break down)
- I then reload Cockpit and make sure it’s in focus. This time, when I wiggle the joystick, the little joystick icon is lit which means the browser recognizes the joystick, but the python output is frozen (reporting the same outdated values at 25hz)
- I start autopilot again, then focus on the Cockpit. I wiggle the joystick, and program output is back to updating current values as expected.
There seem to be 4 states:
- If Autopilot is started before opening the cockpit tab, the MANUAL_CONTROL messages are sent regularly.
- If Autopilot is stopped while the tab is open, the messages are still sent regularly
- If the tab is closed and re-opened, or reloaded, the messages are not sent… despite the browser receiving the joystick inputs (this is the one that confuses me)
- If the cockpit tab is opened while the autopilot is stopped, and then autopilot is started, the messages begin sending immediately after starting autopilot.
For the heartbeat issue, here’s how to reproduce it:
- I stop the autopilot firmware
- I start this python script running on the pi. It sends a heartbeat message at 1hz.
import requests, time
IP = '127.0.0.1'
def sendHeartbeat():
body = {
'header': {
'system_id': 1,
'component_id': 1,
'sequence': 0
},
'message': {
'type': 'HEARTBEAT',
'custom_mode': 0,
'mavtype': {
'type': 'MAV_TYPE_SUBMARINE'
},
'autopilot': {
'type': 'MAV_AUTOPILOT_GENERIC'
},
'base_mode': {
'bits': 128
},
'system_status': {
'type': 'MAV_STATE_STANDBY'
},
'mavlink_version': 2
}
}
response = requests.post(f'http://{IP}/mavlink2rest/v1/mavlink', json=body)
return response
while True:
print(sendHeartbeat())
time.sleep(1)
- I see the heartbeat message is successfully received on the mavlink2rest page at 1hz for vehicle 1 component 1 (you’ll notice the other messages last updated 300+ seconds ago, because autopilot was updating those, and autopilot is stopped)
- I don’t see the message arriving in the mavlink inspector, and the heartbeat icon shows that it’s lost.
Also, if I try sending any other kind of message, like STATUSTEXT for example, nothing happens. It seems like the messages arn’t reaching BlueOS, despite being reportedly recieved in the figure under step 3.
I have a hunch that solving the heartbeat issue might solve the joystick issue, but I’m not sure.