-
SITL on port 5763 and QGroundControl. When I run this code nothing happens in the simulator.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, the only error i see in your code is that you are stopping the event queue for 5 seconds: // Wait for a few seconds to see the response
log.Println("Waiting for response...")
time.Sleep(5 * time.Second) This stops event processing, that might be related to the ability to send or receive messages. The right approach consists in always listening for incoming messages. The listen procedure is "blocking", not "non-blocking", therefore there's no need to wait, since the waiting is already performed by for evt := range dc.node.Events() {
if frm, ok := evt.(*gomavlib.EventFrame); ok {
log.Printf("Received: id=%d, %+v\n", frm.Message().GetID(), frm.Message())
}
} Even better if you perform the go func() {
for {
err = dc.SendTakeoff(altitude, targetSystem, targetComponent)
if err != nil {
log.Fatalf("Failed to send takeoff command: %v", err)
}
time.Sleep(1 * time.Second)
}
}()
for evt := range dc.node.Events() {
...
} Other than this, the procedure to perform the take off entirely depends on your SITL. My advice is to link QGroundcontrol and the SITL through mavp2p, use mavp2p to listen for the exact command (or sequence of commands) that QGroundControl is using to perform the take off (there's the --print option for that), and then replicate them in Go. |
Beta Was this translation helpful? Give feedback.
Hello, the only error i see in your code is that you are stopping the event queue for 5 seconds:
This stops event processing, that might be related to the ability to send or receive messages.
The right approach consists in always listening for incoming messages. The listen procedure is "blocking", not "non-blocking", therefore there's no need to wait, since the waiting is already performed by
dc.node.Events()
:Even…