Hi @jplopezll,
I having some doubts and need help from everyone. I am building an obstacle avoidance system for F450 quadcopter by using hc-sr04 ultrasonic sensor. The arduino UNO TX is connect to RX telem2 pixhawk 2.4.8. It seem like there is no function to the pitch and roll. I was wondering there are some problem in my coding. Below are the code to connect arduino with MAVlink. Thanks.
void FHeartBeat() {
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
uint16_t len;
// System ID = 255 = GCS
mavlink_msg_heartbeat_pack(1, 0, &msg, MAV_TYPE_QUADROTOR, MAV_AUTOPILOT_GENERIC, 0, 1, 0);
// Copy the message to send buffer
len = mavlink_msg_to_send_buffer(buf, &msg);
// Send the message (.write sends as bytes)
Serial.write(buf, len);
//Serial.write("\n\rHeartBeat\n\r");
}
void RCOverride(mavlink_message_t *msg, uint16_t len, uint8_t *buf, uint16_t PitchOut, uint16_t RollOut) {
//Pack and send the calculated Pitch and Roll data. Only send if the data is new
mavlink_msg_rc_channels_override_pack(1, 0 , msg, 1, 0, RollOut, PitchOut, 0, 0, 0, 0, 0, 0);
len = mavlink_msg_to_send_buffer(buf, msg);
Serial.write(buf, len);
Serial.print("\n\rPitch: “);
Serial.print(PitchOut);
Serial.print(”,");
Serial.print(" Roll: ");
Serial.print(RollOut);
}