Hi Experts,

I'm a new comer, im now building a project (using VB.NET) , a Simple GCS to read the attitude (i need pitch, roll, yaw, altitude).

So far i'm exploring this forum, but not solving my problem :(

this is my coding (i have declarations inside a main class), the result then written on datagridview.

    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        SerialPort1.PortName = cmbPort.Text 'Set SerialPort1 to the selected COM port at startup
        SerialPort1.BaudRate = cmbBaud.Text 'Set Baud rate to the selected value on

        'Other Serial Port Property
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.DataBits = 8 'Open our serial port
        SerialPort1.Open()

        btnConnect.Enabled = False 'Disable Connect button
        btnDisconnect.Enabled = True 'and Enable Disconnect button

        Timer2.Start()
    End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        Try
          
            intVariable = SerialPort1.BytesToRead
            bufferByte = New Byte(intVariable - 1) {}
            SerialPort1.Read(bufferByte, 0, intVariable)

            For i As Integer = 0 To intVariable - 1
                  ccc = ccc & Convert.ToChar(bufferByte(i))
            Next

            DataGridView1.Rows(0).Cells(0).Value = ccc
         
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

but this only shows strange string i don't understand, like :

"þ3ýBeginning INS calibration; do not move plane"

so, could you please help :D

*i attach the screenshot

Views: 420

Attachments:

Reply to This

Replies to This Discussion

The scrambled data you are seeing is actually correct. The APM sends 2 data streams out at the same time on the same channel. (I wont go in to why it does this since I dont know exactly) The first stream is the console text and the second stream is binary data from the vehicle sent in Mavlink format.

http://qgroundcontrol.org/mavlink/start

There are standard routines around that parse the Mavlink data and which will ignore the text

Here is some code for parsing the data for an OSD, which is based on Sandro Benigno's original MinimOSD code.

https://github.com/kwikius/mavlink_to_frsky/blob/master/arduino/lib...

You can see what is being sent by looking at the mavlink code for the vehicle:

https://github.com/ArduPilot/ardupilot/blob/master/ArduPlane/GCS_Ma...

That is for ArduPlane but there are similarly named files functions in the other vehicle directories.

The code is mainly written in C and C++ as are the Mavlink libraries. I have no idea if there are any Mavlink libraries written in VB.net.

Thanks for reply dude,

Based on the link u give, i still dont understand about the channel (this parameter should be included inside the function)

void Plane::send_attitude(mavlink_channel_t chan)
{
const Vector3f &omega = ahrs.get_gyro();
mavlink_msg_attitude_send(
chan,
millis(),
ahrs.roll,
ahrs.pitch - radians(g.pitch_trim_cd*0.01f),
ahrs.yaw,
omega.x,
omega.y,
omega.z);

}

so, on what channel should i fill ? do u have any idea? please explain

You can be communicating via mavlink on several channels at the same time. Think different radio frequencies or different serial ports etc. You can set each channel up to send different data.
The channels are given names
https://github.com/mavlink/c_library_v1/blob/master/mavlink_types.h...
but these are enums which are really integers underneath MAVLINK_COMM_0 == 0, MAVLINK_COMM_1 == 1 etc.
Look up C enums for more about how that works.

If you are using  an APM2.x hardware then I think it only communicates on MAVLINK_COMM_0 so chan is set to 0
This also may explain why the console text comes through on the same channel. There are not enough uarts on the APM to put the console on a separate uart

im using APM 2 dude, and i think on this hardware the message ID's sent from it are varies.

im requesting the attitude but the message i receive are so many, there are attitude, altitude, battery, etc.

could you please show me the method to request data stream ??

no matter you use any syntax, C, C++, JAVA, VB, C# i understand those all

thanks

Reply to Discussion

RSS

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service