Simple Program To Read Data From APM

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

GCS-Trial.jpg

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • 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

  • Developer

    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

    mavlink/c_library_v1
    MAVLink protocol C/C++ implementation auto-generated from latest protocol specs. - mavlink/c_library_v1
  • 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

  • Developer

    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.

This reply was deleted.

Activity

DIY Drones via Twitter
RT @chr1sa: My talk on PX4 and FAA certification is coming up at 1:45 PST today on the PX4 Dev Summit livestream. Includes some cool new st…
Tuesday
DIY Drones via Twitter
RT @seesharp: I'm tuned into the PX4 / Dronecode free live conference. Great stuff. Microsoft AirSim talk in 10 minutes. https://t.co/0zbZ2…
Jul 6
DIY Robocars via Twitter
RT @masato_ka: 距離センサを3つとESP32を付けたラジコンカーをDonkeyCarライクにNNで自動走行。3層FC極小モデルをTensorFlow Lite for microcontrollerで動かしてる。機体は借り物でRumiCarって言います。Tenso…
Jul 5
DIY Robocars via Twitter
RT @SmallpixelCar: My car was able to go all the way autonomously until the crosswalk. It was only 100 yards from the target. What should b…
Jul 4
Liam left a comment on Agricultural UAVs
"Hi
I'm Liam from T-MOTOR. I would like to reach out to see if there is any possibility for us to work together.
We are a propulsion system manufacturer who offers motors, propellers and ESCs for all kinds of drone applications which vary from secur…"
Jun 30
DIY Robocars via Twitter
RT @SmallpixelCar: Smart move. The car used the shadow to guide it through the bridge. This was never in the training samples. But it learn…
Jun 30
DIY Robocars via Twitter
RT @SmallpixelCar: Getting closer to the target. Single camera. Untrained road. https://t.co/Wsr7RwDamj
Jun 29
Richard Cox left a comment on Australia
"Anyone in the DIYDRONES Australian subgroup based in Alice Springs, NT?
I am experimenting with Ardupilot (standard Arduplane), Pixhawk 4 FC in a 4-ch
RC "AXN Floater Jet" foamy plane..."
Jun 29
Omar Sykes left a comment on Australia
"Hi everyone, I am looking for someone who is good at drone building, repair and software in Adelaide. Please give me a call on 0477 319 219."
Jun 29
DIY Robocars via Twitter
RT @RoboticMasters: #donkeycar https://t.co/czuLoVRcA4
Jun 29
DIY Robocars via Twitter
https://t.co/DKQbNTbz0g
Jun 29
DIY Robocars via Twitter
RT @RoboticMasters: Donkey car, car car car car car car; Donkey car, car car car car car car; Donkey Car. Anyone like our tiny tiny donkey…
Jun 29
DIY Robocars via Twitter
RT @SmallpixelCar: After improving DBSCAN speed, I can get 11 frame per second on @NVIDIAEmbedded Jerson Xavier MAXN mode and the autonomou…
Jun 26
DIY Robocars via Twitter
RT @Heavy02011: Join us at next Virtual Race League: ⁦@diyrobocars⁩ Race #4 - Parking Lot Nerds, August 1st https://t.co/5KUpu7VGaH
Jun 25
DIY Robocars via Twitter
RT @SmallpixelCar: #CUDA implementation should be easy, because most of the time is on distance calculations berween two points and if the…
Jun 25
DIY Robocars via Twitter
RT @SmallpixelCar: This is the view from the car. Even my lanenet inference is fast on @NVIDIAEmbedded Jerson Xavier, DBSCAN clustering tak…
Jun 25
More…