Gimbal detects as a FC or FC detects as a gimbal in console and Getting parameters 26 endlessly. Plugin MP

gimbal linked to the orange cube with uart. This is what you mean ? I’m sorry i don’t understand

this is not a problem with ardupilot, its your code not sending the data in the correct way.

1 Like

but where is the problem ? I’m coding byte by byte to send Mavlink message. I put value in all bytes and then i’m sending it like a packet. Like this :

void heartbeat(void)
{
mav_message msg;

mav_initMessage(&msg, 26, 154, 0, 0);
mav_setMessageId(&msg, 0);
msg.crcExtra=50;
msg.len=9;
msg.compat_flags=0;
msg.incompat_flags=0;
msg.seq=seq+1;

msg.payload[0] = 0;
msg.payload[1] = 0;
msg.payload[2] = 0;
msg.payload[3] = 0;
msg.payload[4] = 26; // TYPE : GIMBAL
msg.payload[5] = 8; // MAV_AUTOPILOT_INVALID
msg.payload[6] = 0;
msg.payload[7] = 3;
msg.payload[8] = 3; //MAVLINK VERSION

msg.checksum = mav_calculateChecksum(&msg,msg.crcExtra);
//HLog_Text("Send");HLog_NL();HLog_NL();HLog_NL();
mav_sendMessage(send,&msg);

}

Are you saying that the data is send like a FC ? and so MP identifies the gimbal like a FC ?
You’re saying not in the correct way but i can easily communicate with all my stuffs, and even received data from FC. What does it mean

Thanks for helping me

You don’t send gimbal data in a heartbeat

But you saw the content of my heartbeat, it was with the gimbal type, with the autopilot mode INVALID.

In my plugin, i have this :

MAVLinkMessage mavHB = Host.comPort.getHeartBeat();

if (mavHB.msgid == (byte)MAVLINK_MSG_ID.HEARTBEAT)
{
mavlink_heartbeat_t hb = mavHB.ToStructure<mavlink_heartbeat_t>();

   if ((hb.type == (byte)MAV_TYPE.GIMBAL) && (connection_allowed_gimbal))
   {
       // if we have front = 0, mean that the option display virtual button has been choosen in the toolstrip menu
       if (front == 0)  // we do it like this to avoid problem linked to popup in background/frontground
       {
           front = 1;
           value_slider = slider.Value;
           StartFormThread();
       }
       if (state == 0)
       {
           CustomMessageBox.Show("Gimbal Heartbeat Detected ");
           StartButtonThread();
           StartFormThread();
           virtualorreal = 0;
           state = 1;
       }
       MAVLink.MAVLinkMessage mavMes = Host.comPort.readPacket();
       iStart = Environment.TickCount;
   }
   if ((Environment.TickCount - iStart > 20000) && (state == 1))
   {
       state = 0;
       if (("" + Host.comPort).Contains("MAV 1")) // Mavlink still Connected
       {
           CustomMessageBox.Show("Gimbal Heartbeat not detected anymore");
       }
   }

}

and i enter in all of this. So MP detects my gimbal heartbeat. So i don’t understand what you are saying

You send 2 packets, one with a heartbeat at 1hz and one with your gimbal data, how are you packing the gimbal message?

1 Like

I’m sending a heartbeat message at 1Hz. But i’m not sending another heartbeat. The gimbal is just requesting data from the FC (with a command long and set_message_interval) and is receiving data from my plugin in MP. So there is no message other message than heartbeat send by the gimbal to the GCS. And for the command long send to the orange cube, this is how it is packed :

void Request_Rc_Channels(void)
{
float32 parameters[7] = {65, 500000, 0, 0, 0 , 0, 0 };
mav_message msg;

mav_initMessage(&msg, 26, 154, 0, 0);
mav_setMessageId(&msg, 76);
msg.crcExtra=152;
msg.len=33;
mav_setCmd(&msg, 1, 1, 511, 0, parameters); // msg, sysid, compid, msgid of the cmd, confirmation and parameters for the command long
msg.checksum = mav_calculateChecksum(&msg,msg.crcExtra);

mav_sendMessage(send,&msg);
HLog_Text("Send"); HLog_NL();

}

The only 2 heartbeat messages i can see is from the FC which is sending heartbeat with component 0 and 1 (i don’t understand why, but it’s like this since the beginning).

I hope you understand. I’m sorry if i don’t understand everything you want to tell me.
Thank you

I don’t think your flight controller is component 0. Does it still show component 0 sending data after you unplug the gimbal?

Why are you requesting RC channels?? That’s not how mavlink works. You request the RC channels stream rate once then decode it.

this is all in arduino but you should get the idea,

first you request the data stream from the flight controller, the easiest way is just request everything. you only need to send this once, even then its optional since you can manually set the stream rate (SR*) parameters for the serial port manually.

void request_Mavlink() {
  //Request Data from Pixhawk
  uint8_t _system_id = 255;       // id of computer which is sending the command (ground control software has id of 255)
  uint8_t _component_id = 2;      // seems like it can be any # except the number of what Pixhawk sys_id is
  uint8_t _target_system = 1;     // Id # of Pixhawk (should be 1)
  uint8_t _target_component = 0;  // Target component, 0 = all (seems to work with 0 or 1
  uint8_t _req_stream_id = MAV_DATA_STREAM_ALL;
  uint16_t _req_message_rate = 0xA;  //number of times per second to request the data in hex
  uint8_t _start_stop = 1;           //1 = start, 0 = stop
  mavlink_message_t msg;
  uint8_t buf[MAVLINK_MAX_PACKET_LEN];

  // Pack the message
  mavlink_msg_request_data_stream_pack(_system_id, _component_id, &msg, _target_system, _target_component, _req_stream_id, _req_message_rate, _start_stop);
  uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);  // Send the message (.write sends as bytes)

  Serial2.write(buf, len);  //Write data to serial port
}

Then i can listen for the RC packets arriving, I dont need to send any data to the flight controller. the rc channels will be streamed at the rates set, I just need to listen for them.

void MavLink_receive()
{
  mavlink_message_t msg;
  mavlink_status_t status;

  while (Serial2.available())
  {
    uint8_t c = Serial2.read();

    //Get new message
    if (mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status))
    {
      //Handle new message from autopilot
      switch (msg.msgid)
      {

          
                  case MAVLINK_MSG_ID_RC_CHANNELS_RAW:  // #35
                    {
                      mavlink_rc_channels_raw_t chs;
                      mavlink_msg_rc_channels_raw_decode(&msg, &chs);
                      Serial.print("Chanel 6 (3-Kanal Schalter): ");
                      Serial.println(chs.chan6_raw);
                    }

          break;

Hello, thank you for your responses.

I’m already doing this. I’m requesting this message only one time because i’m using the command set interval. The arduino code you sent is almost the same than me, even if i’m not using arduino.

I’m trying everything but nothing worked.

[EDIT] I just found out something:
When in MP I select this one : image
I have the FC and the gimbal detect as FC :

but when i select the gimbal in MP : image
I have the FC and the gimbal detect as gimbal :

I don’t understand why, but i’m searching.
Is it because i’m doing some communications directly to the gimbal in my plugin ? like this for exemple :

or is it because i’m broadcasting my gimbal heartbeat (even if the type in the gimbal is GIMBAL) ?

@Michael_Oborne @geofrancis

Keep related information in the same topic. I have closed the duplicates.

3 Likes

what mavlink packet are you trying to send from mission planner? I think the packet your sending is being detected as device 0.

I want to send some mavlink packets from MP because i created a GUI with buttons, sliders on it and i want to send their values to the gimbal.
For example i’m sending this :

Host.comPort.generatePacket(MAVLINK_MSG_ID.BUTTON_CHANGE, new MAVLink.mavlink_button_change_t(0, 0, (byte)(buttonIndex)), 26, 154, true, false);

Host.comPort.generatePacket(MAVLINK_MSG_ID.STATUSTEXT, new MAVLink.mavlink_statustext_t(6, arraybyte, 0, 0), 26, 154, true, false);

It’s weird because even if the orange cube is the only one plug to Mission planner (no gimbal, no plugin activated, nothing more), the comp 0 is still there.
I thought it was a firmware problem (arducopter latest) because when i flashed a firmware from QGC and not MP, the comp 0 disappear.

this is the only mention i can find of it. it mentions the GCS sending the packet, does it show with your script disabled?

compid 0 on a cubeorange is the adsb chip. and is real.

Thank you for your response.

I’m going back into my initial question, @Michael_Oborne do you know why my gimbal is detected as a FC ? there is the problem :

I’m searching and, without my plugin activated, i have this when i’m connecting to Mavlink on MP (with my gimbal sending heartbeat) :


It looks like MP don’t know what to put for the gimbal.

I’m checking the source code and i found in MAVLinkInterfaces.cs this function :


So to determine its type, it is with the type within the heartbeat.
But inside my heartbeat, it is already type 26 : gimbal…

image

[EDIT] I just found that, in my plugin, i used Host.comPort.getHeartBeat(); to detect the gimbal. But when i replace the detection with Host.comPort.readPacket(); I don’t have all the flood problem in the console.

looks like it might just be a display issue. MAV. above will show the current selected item… but its storing the correct thing - i will fix

1 Like

I just found something. I have my home made gimbal linked to my orange cube with telem 2. But the SERIAL_PROTOCOL2 is 2 (Mavlink 2) and not 8 (Gimbal). When i put 8, my code in the gimbal isn’t working while when it is at 2, it’s working. Is the problem there ? and if yes, how do i do for my code to execute well in my gimbal ? (for example i’m sending heartbeat from my gimbal, but when i put SERIAL_PROTOCOL2 at 8 it’s not working).

I’m sorry if this is not so accurate. Thank you for helping me.

Protocol 8 is for Storm32 serial, so of course it stops responding. You’re using MAVlink. Set the protocol to 2.

2 Likes

Okay, thank you. I was wondering because it said ‘gimbal’ :
image

But thank you very much. I also updated the lines Mr. Oborne committed in the Mission Planner repository. Now everything is working perfectly. Thank you so much! (and sorry for my inacurate question, i just start discovering MP, mavlink 1 month ago)