How to command directly to actuator from ground computer?


I’m a graduate student working on a project, and it is my first time to work with hardware. (I usually research with simulation)

What I want to make are as below:


  1. Pixhawk gets sensor data
  1. The sensor data are transmitted to ground computer via Wifi for indoor experiment or any other method for outdoor experiment
  • I have transmitted sensor data using ESP8266 module and QGroundControl.
  1. Python script gets the sensor data and runs the script. As a result, the script makes vehicle’s estimated values, desired position, desired attitude, or desired actuator output according to the script’s purpose.
  • In this step, I wonder 1) how to put the sensor data in the python script from QGC or pixhawk directly, 2) how to put the results made from the python script into the QGC or pixhawk directly (If I put the results into QGC, then can QGC transmit the results to pixhawk?)
  1. Pixhawk gets the results and puts the results into proper modules
  • If the python script’s purpose is estimating the vehicle’s position and attitude, then navigator, position controller, and attitude&rate controller should subscribe the results.
  • If the python script’s purpose is designing path which the vehicle should follow, position controller should subscribe the results.
  • If the python script’s purpose is to make desired actuator output, the mixer or actuator should subscribe the results.
    as picture below

What I wonder are
A. Is QGC essential or much easier to communicate between pixhawk and ground computer, even though the python script intervenes? (related 2 and 3)

B. How can pixhawk subscibe the results from ground computer?
When I made example module with reference to Writing your First Application · PX4 Developer Guide, I added publisher “actuator_controls”. In the SITL with gazebo, however, it seems that quadrotor does not receive the actuator_controls published from my example module even the subscribe in the example module is done well. The example module is as below. It print out vehicle’s attitude which is subscribe in the module well, while the actuator control seems not to pass on actuator.

#include <px4_platform_common/log.h>
#include <uORB/topics/sensor_combined.h>
#include <px4_platform_common/posix.h>
#include <uORB/topics/vehicle_attitude.h>
#include <string.h>
#include <uORB/topics/actuator_controls.h>
#include <uORB/topics/actuator_outputs.h>

__EXPORT int px4_tutorial_main(int argc, char *argv[]);

int px4_tutorial_main(int argc, char *argv[]) {
	PX4_INFO("Hello Sky!");

	struct vehicle_attitude_s att;
	memset(&att, 0, sizeof(att));
	orb_advert_t att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att);

	struct actuator_controls_s ctr;
	memset(&ctr, 0, sizeof(ctr));
	orb_advert_t ctr_pub = orb_advertise(ORB_ID(actuator_controls_0), &ctr);

	int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));

	orb_set_interval(sensor_sub_fd, 200);

	px4_pollfd_struct_t fds[] = {
		{ .fd = sensor_sub_fd,  .events = POLLIN},

	int error_counter = 0;

	for (int i = 0; i < 5; i++) {
		int poll_ret = px4_poll(fds, 1, 1000);
		if (poll_ret == 0) {
			PX4_ERR("Got no data within a second");
		} else if (poll_ret <0 ) {
			if (error_counter < 10 || error_counter % 50 == 0) {
				PX4_ERR("ERROR return value from poll(): %d", poll_ret);

		} else {
			if (fds[0].revents & POLLIN) {
				struct sensor_combined_s raw;
				orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);
					att.q[0] = 1;
					att.q[1] = 2;
					att.q[2] = 3;
					orb_publish(ORB_ID(vehicle_attitude), att_pub, &att);

	ctr.control[0] = 0;
	ctr.control[1] = 0;
	ctr.control[2] = 0;				
	ctr.control[3] = 1.0f;

	orb_publish(ORB_ID(actuator_controls_0), ctr_pub, &ctr);

	return 0;

Thanks for your regarding