# Not able to set actuator controls for fixed wing in SITL

**URL:** <https://discuss.px4.io/t/not-able-to-set-actuator-controls-for-fixed-wing-in-sitl/22824>\
**Category:** Uncategorized\
**Created:** [June 14, 2021, 12:44pm UTC](https://discuss.px4.io/t/not-able-to-set-actuator-controls-for-fixed-wing-in-sitl/22824 "2021-06-14T12:44:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghunandan\_V](https://discuss.px4.io/user_avatar/discuss.px4.io/raghunandan_v/32/7727_2.png) [@raghunandan\_V](https://discuss.px4.io/u/raghunandan_V)\
**Post date:** [June 14, 2021, 12:44pm UTC](https://discuss.px4.io/t/not-able-to-set-actuator-controls-for-fixed-wing-in-sitl/22824/1 "2021-06-14T12:44:34Z")

</div>

Hey,  
I am trying to send the actuator commands directly over `/mavros/actuator_control` in offboard mode but when I send the commands the Px4 is forced to switch back to position control mode and doesn’t come back to offboard mode and the plane doesnt fly.

These are the steps I followed:

1. disable lockstep simulation
2. started px4 sitl:

> make px4\_sitl gazebo\_plane

1. started mavros:

```auto
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"

```

1. ran this code:

```auto
#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <mavros_msgs/CommandBool.h>
#include <mavros_msgs/SetMode.h>
#include <mavros_msgs/State.h>
 #include <mavros_msgs/ActuatorControl.h>
 
mavros_msgs::State current_state;
void state_cb(const mavros_msgs::State::ConstPtr& msg){
    current_state = *msg;
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "offb_node");
    ros::NodeHandle nh;

    ros::Subscriber state_sub = nh.subscribe<mavros_msgs::State>
            ("mavros/state", 10, state_cb);
    // ros::Publisher local_pos_pub = nh.advertise<geometry_msgs::PoseStamped>
    // ("mavros/setpoint_position/local", 10);
    ros::Publisher act_pub = nh.advertise<mavros_msgs::ActuatorControl>
            ("mavros/actuator_control", 10);
    ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>
            ("mavros/cmd/arming");
    ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>
            ("mavros/set_mode");

    //the setpoint publishing rate MUST be faster than 2Hz
    ros::Rate rate(50.0);

    // wait for FCU connection
    while(ros::ok() && !current_state.connected){
        ros::spinOnce();
        rate.sleep();
    }

    geometry_msgs::PoseStamped pose;
    pose.pose.position.x = 0;
    pose.pose.position.y = 20;
    pose.pose.position.z = 20;

    mavros_msgs::ActuatorControl setpoint;
    setpoint.header.stamp = ros::Time::now();
    setpoint.group_mix = 0;
    setpoint.controls[0] = 0; 
    setpoint.controls[1] = 0; 
    setpoint.controls[2] = 0; 
    setpoint.controls[3] = 1;  
    setpoint.controls[4] = 0; 
    setpoint.controls[5] = 0;
    setpoint.controls[6] = 0; 
    setpoint.controls[7] = 0;

    //send a few setpoints before starting
    for(int i = 20; ros::ok() && i > 0; --i){
        // local_pos_pub.publish(pose);
        act_pub.publish(setpoint);
        ros::spinOnce();
        rate.sleep();
    }

    mavros_msgs::SetMode offb_set_mode;
    offb_set_mode.request.custom_mode = "OFFBOARD";

    mavros_msgs::CommandBool arm_cmd;
    arm_cmd.request.value = true;

    ros::Time last_request = ros::Time::now();
    ros::Time last_request_arm = ros::Time::now();

    while(ros::ok()){
        // act_pub.publish(setpoint);
        if( current_state.mode != "OFFBOARD" &&
            (ros::Time::now() - last_request > ros::Duration(0.5))){
            if( set_mode_client.call(offb_set_mode) &&
                offb_set_mode.response.mode_sent){
                ROS_INFO("Offboard enabled");
            }
            last_request = ros::Time::now();
        } 
        if( !current_state.armed &&
            (ros::Time::now() - last_request_arm > ros::Duration(1))){
            if( arming_client.call(arm_cmd) &&
                arm_cmd.response.success){
                ROS_INFO("Vehicle armed");
            }
            last_request_arm = ros::Time::now();
            }
        
        // local_pos_pub.publish(pose);
        act_pub.publish(setpoint);
        // local_pos_pub.publish(pose);
        ros::spinOnce();
        rate.sleep();
    }

    return 0;
}

```

Not sure what I am doing wrong. Any help will be appreciated.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [September 21, 2023, 11:26pm UTC](https://discuss.px4.io/t/not-able-to-set-actuator-controls-for-fixed-wing-in-sitl/22824/2 "2023-09-21T23:26:01Z")

</div>

I think PX4 doesn’t support actuator controls at the current version.

> <https://github.com/PX4/PX4-Autopilot/issues/21058>
>
> \## Describe the bug
> We are a team of researchers and need direct access to the …actuators when working with Rovers/Boats, but this feature does not seem to be working.
> 
> We are using Mavsdk to send values between -1 and 1 to the actuators.
> 
> I checked and can confirm that the values are being received in the vehicle and being correctly published to the topic with ORB\_ID = actuator\_controls\_0 (as well as actuator\_controls\_1).
> 
> !\[Screenshot from 2023-02-02 18-21-51\](https://user-images.githubusercontent.com/69345264/216415339-ac8ff1e4-ae02-4f82-a6c1-5d3fdd4aa022.png)
> 
> 
> Therefore values are being published but no response can be seen.
> 
> This is being handled by the following function:
> !\[void MavlinkReceiver::handle\_message\_set\_actuator\_control\_target(mavlink\_message\_t \*msg)\](https://github.com/PX4/PX4-Autopilot/blob/46a12a09bf11c8cbafc5ad905996645b4fe1a9df/src/modules/mavlink/mavlink\_receiver.cpp#L1259)
> 
> I don't mind correcting the error and creating a PR, but I would like to know what is the best way to fix this issue.
> I think that the problem is that 'actuator\_controls\_0' is not being used and has been replaced by 'vehicle\_thrust\_setpoint' and 'vehicle\_torque\_setpoint' as mentioned in issue #20981, but I might be wrong. I have also encountered some other interesting topics namely: 'ORB\_ID(actuator\_motors)' and 'ORB\_ID(actuator\_servos)' that might be key to solving this problem.
> 
> I would appreciate it if someone could help me understand the issue. And if I am correct in the above statement, what would be the mapping from control groups to 'some other' topic?
> 
> \## To Reproduce
> Steps to reproduce the behavior:
> 1. Start PX4 SITL Rover Gazebo Simulation (tested both v1.13.2 and v1.14.0-beta1) (lockstep must be disabled -\> check https://docs.px4.io/main/en/simulation/ where it shows how to disable it)
> 2. Open QGC and wait for connection
> 3. Test the following python script \[off\_board\_actuator.zip\](https://github.com/PX4/PX4-Autopilot/files/10572126/off\_board\_actuator.zip)
> 4. Check on console uORB topics actuator\_controls\_0 as well as actuator\_controls\_1 (using command: listener actuator\_controls\_0 in the terminal where px4\_sitl is running) where we can see that the correct values are being published.
> 5. No actuators move and we can see that nothing is being published to the actuators (check qgroundcontrol SERVO\_OUTPUT\_RAW, ... in the mavlink inspector)
> 
> !\[Screenshot from 2023-02-02 18-22-26\](https://user-images.githubusercontent.com/69345264/216415251-eec15947-6d7b-4d4d-9e71-8aa049a747b5.png)
> 
> 
> 
> 
> 
> \## Expected behavior
> We expect to be able to control the actuators directly.
> 
> \## Log File
> https://logs.px4.io/plot\_app?log=533206ce-1228-43f7-8797-027ade652ffa
> 
> Thank you for your help.
