Connect Demo for mav_server
elinxer opened this issue · 5 comments
elinxer commented
i try to connect mav_server on 127.0.0.1:50051 tcp,on the mavsdk is done, but this code is error:
// This example uses a TCP socket, however we may also use a UDP socket by injecting
// PipedInputStream/PipedOutputStream to MavlinkConnection, or even USB by using any
// implementation that will eventually yield an InputStream and an OutputStream.
try (Socket socket = new Socket("127.0.0.1", 50051)) {
// After establishing a connection, we proceed to building a MavlinkConnection instance.
MavlinkConnection connection = MavlinkConnection.create(
socket.getInputStream(),
socket.getOutputStream());
System.out.println(socket.toString());
int systemId = 255;
int componentId = 0;
Heartbeat heartbeat = Heartbeat.builder()
.type(MavType.MAV_TYPE_GCS)
.autopilot(MavAutopilot.MAV_AUTOPILOT_INVALID)
.systemStatus(MavState.MAV_STATE_UNINIT)
.mavlinkVersion(3)
.build();
// Write an unsigned heartbeat
connection.send2(systemId, componentId, heartbeat);
MavlinkMessage message;
while ((message = connection.next()) != null) {
Object p = message.getRawBytes();
System.out.println(p);
}
} catch (Exception e) {
e.printStackTrace();
}
Error:
:processResources UP-TO-DATE
:classes
:testMainTcpPx4.main()
Socket[addr=/127.0.0.1,port=50051,localport=61393]
java.io.EOFException: End of stream
at io.dronefleet.mavlink.protocol.MavlinkPacketReader.next(MavlinkPacketReader.java:47)
at io.dronefleet.mavlink.MavlinkConnection.next(MavlinkConnection.java:238)
at px4.testMainTcpPx4.main(testMainTcpPx4.java:49)
BUILD SUCCESSFUL
Total time: 9.917 secs
17:59:09: Task execution finished ':testMainTcpPx4.main()'.
i use px4 mav:
sudo docker run --rm -it jonasvautherin/px4-gazebo-headless 10.9.127.54 10.9.127.54
the 50051 port is nornal:
i need help or somebody can leave a demo for it.
elinxer commented
@benbarkay hello,can you help me or Just give me an idea,or just demo will okk
benbarkay commented
Hi,
It appears that the server is closing the connection as soon as you connect
or send the heartbeat to it.
The picture seems to include logs for a GCS that connected using UDP. Are
there any server logs relevant to the TCP connection that you're making?
Also, you don't seem to be mapping any ports in your docker command.
Perhaps you could try mapping the port by running it with:
`sudo docker run --rm -p 50051:50051 -it
jonasvautherin/px4-gazebo-headless 10.9.127.54 10.9.127.54`
…On Wed, Oct 13, 2021, 05:20 zhiteer ***@***.***> wrote:
@benbarkay <https://github.com/benbarkay> hello,can you help me or Just
give me an idea,or just demo will okk
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4DXUSHNCG5CDK65ZF7HR3UGTUHJANCNFSM5F2FMNTA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
elinxer commented
tks ben, but the docker container port is 14540,14550 etc, that is exisit and open. Is there a demo you can give me. 0.0
zeev-mindali commented
@elinxer did you able to connect?
zeev-mindali commented
@elinxer I figure the problem
I using mavproxy to check communication and heart beat.
you need to set in MAVprxy you need tcpIn : 127.0.0.1:14550, and connect to that, then you will able to see heartBeat