Issue integrating Jetson TX1 with Pixhawk

Hello, I am currently a new builder in drones. I am working on an autonomous drone with machine vision capabilities using OpenCV however I have problems communicating my Jetson TX1 with the Pixhawk flight controller. The connection is via USB.

I am just starting to test the motors with MAVLink protocol but I’m not quite getting the right outputs.
Here’s how the code basically looks like:

int main(int argc, char *argv[]){

cout << "Test 1 Started \n" << endl;

usleep(500000);	

Command_Stabilize();

usleep(1000000);

Command_Heartbeat();
Command_Arm();

usleep(1000000);

Command_Heartbeat();
Command_Throttle(1100);
cout << "Throttle increased \n" << endl;

usleep(2000000);

Command_Heartbeat();
Command_Throttle(0);
cout << "Throttle stopped \n" << endl;

usleep(2000000);

Command_Heartbeat();
Command_Disarm();

cout << "Operation stopped. \n" << endl;  
return 0;

}

Please bare with me here because I have no previous experience with drones or MAVLink protocol. Basically the test starts off with stabilizing the drone then arming, starting the motors for 2 seconds, turning them off then disarming.

The Pixhawk gave off a beep to indicate that the arming and disarming was successful however the motors do not move at all when increasing the throttle.

Here’s the function:

void Command_Throttle(int throttle){

mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];

mavlink_msg_rc_channels_override_pack(	system_id,
					component_id,
					&msg,
					target_system,
					target_component,
					UINT16_MAX,
					UINT16_MAX,
					throttle,
					0, 0, 0, 0, 0);

uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

int serial = -1;
int written = 0;
serial = OpenSerialPort();
if(serial != -1){
	written = write(serial, buf, len);
	if(written < 0){
		cout << "Failed tp wrote to port \n" << endl;
	}
	else{
		cout << "Adjusting Throttle" << endl;
	}
}
}

It successfully output to indicate that the serial was written.

Any thoughts about this? Other than MAVLink is there a better way to communicate TX1 with Pixhawk?

Hi, I would recommend starting with either Dronekit or Mavros - probably mavros as it is better maintained and has inherent integration with opencv through ROS, and C++ library through ROS. These take care of a lot of the basics for you, so you can get on with doing what you want.