# Offboard control without ROS

**URL:** <https://discuss.px4.io/t/offboard-control-without-ros/2546>\
**Category:** Uncategorized\
**Created:** [February 21, 2017, 6:55pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546 "2017-02-21T18:55:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidullan](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vidullan](https://discuss.px4.io/u/vidullan)\
**Post date:** [February 21, 2017, 6:55pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/1 "2017-02-21T18:55:35Z")

</div>

I am trying to control the pixhawk through serial communication using MavLink. I am able to send and receive messages from the pixhawk but I do not receive x-y local position as there is no GPS in the indoor environment.

It also refuses to accept setpoints. Considering the quad stays stable when being flown by r/c in the same environment, surely it is possible to have offboard control. All the tutorials seem to use ROS and it very hard to find info on how to do this using C/C++.

Any tips on the steps that need to be taken would be greatly appreciated. As of now I can get it to arm, go into offboard mode, and that’s about it. How do I command it to move to a set x-y position? If that is not possible then even if i can send it commands to control attitude that would be fine as I would be able to move the craft? Something similar to what the r/c controller would send to command the pixhawk.

---

<div class="post-metadata">

**Author:** ![Joseph\_Garret\_Sulliv](https://discuss.px4.io/user_avatar/discuss.px4.io/joseph_garret_sulliv/32/365_2.png) [@Joseph\_Garret\_Sulliv](https://discuss.px4.io/u/Joseph_Garret_Sulliv)\
**Post date:** [February 21, 2017, 7:09pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/2 "2017-02-21T19:09:28Z")

</div>

The system will only accept position set points if it has local position estimates available, which means that you will need MOCAP data, spoofed GPS, or optical flow + range detection.

These alternate features have to be explicitly enabled in some of the state estimators (LPE, EKF2) by setting parameters, which can be done in QGroundControl.

---

<div class="post-metadata">

**Author:** ![vidullan](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vidullan](https://discuss.px4.io/u/vidullan)\
**Post date:** [February 21, 2017, 9:00pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/3 "2017-02-21T21:00:05Z")

</div>

Thanks for the reply!

So if it will not accept set points without local position, is it possible to control the attitude (roll,pitch,yaw,thrust) in some way?

Can I use the mavlink msg: RC\_CHANNELS\_OVERRIDE to spoof r/c control?

---

<div class="post-metadata">

**Author:** ![Joseph\_Garret\_Sulliv](https://discuss.px4.io/user_avatar/discuss.px4.io/joseph_garret_sulliv/32/365_2.png) [@Joseph\_Garret\_Sulliv](https://discuss.px4.io/u/Joseph_Garret_Sulliv)\
**Post date:** [February 21, 2017, 9:39pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/4 "2017-02-21T21:39:28Z")

</div>

I think it won’t accept _local position setpoints_ without local position estimates (can’t do closed loop position control without position estimates).

You could spoof the rc channels, but that seems a bit convoluted, since you will have to map attitude / accelleration to equivalent rc signals. This may require knowledge of the rc calibration to do the inverse mapping. Furthermore, if for some reason the vehicle switches control modes, i.e. from manual to attitude, then the interpretation of the rc channels will change.

It is my understanding that the attitude set point is used by the attitude controller to generate the control outputs. But you should have a look at the [software architecture](https://dev.px4.io/concept-architecture.html) in the docs, they are quite helpful.

Here is one way to get it working; have the GCS computer send attitude\_setpoint and offboard\_control\_mode messages to the pixhawk via a radio. Switch the control mode into offboard via a mode switch on your rc transmitter. Then the mavlink receiver should publish attitude\_setpoint messages that it receives, which will be used by the attitude controller.

For reference, here is some relevant code from the mc\_position\_control module:

```
indent preformatted text by 4 spaces    		
        /* publish attitude setpoint
	 * Do not publish if offboard is enabled but position/velocity/accel control is disabled,
	 * in this case the attitude setpoint is published by the mavlink app. Also do not publish
	 * if the vehicle is a VTOL and it's just doing a transition (the VTOL attitude control module will generate
	 * attitude setpoints for the transition).
	 */
	if (!(_control_mode.flag_control_offboard_enabled &&
	      !(_control_mode.flag_control_position_enabled ||
		_control_mode.flag_control_velocity_enabled ||
		_control_mode.flag_control_acceleration_enabled))) {

		if (_att_sp_pub != nullptr) {
			orb_publish(_attitude_setpoint_id, _att_sp_pub, &_att_sp);

		} else if (_attitude_setpoint_id) {
			_att_sp_pub = orb_advertise(_attitude_setpoint_id, &_att_sp);
		}
         }

```

From here you can see that the position control module will defer to the mavlink receiver for attitude setpoint messages. The other three flags for acceleration, velocity, and position, are related to to the position control mode (i.e. they require GPS / optical flow & range detection / motion capture to estimate vehicle translation).

---

<div class="post-metadata">

**Author:** ![vidullan](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vidullan](https://discuss.px4.io/u/vidullan)\
**Post date:** [March 16, 2017, 11:32pm UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/5 "2017-03-16T23:32:42Z")

</div>

Hey Joseph,

We got a px4flow module and now the systems has local position estimates but still won’t accept setpoints.

I am sending position set points once every 0.2 seconds and there is no change in the motor outputs.

Am i missing something?

---

<div class="post-metadata">

**Author:** ![clovett](https://discuss.px4.io/user_avatar/discuss.px4.io/clovett/32/3458_2.png) [@clovett](https://discuss.px4.io/u/clovett)\
**Post date:** [March 18, 2017, 9:24am UTC](https://discuss.px4.io/t/offboard-control-without-ros/2546/6 "2017-03-18T09:24:04Z")

</div>

are you sending MAV\_CMD\_NAV\_GUIDED\_ENABLE ?
