Adding a gimbal to 1030_plane model in gazebo

Hi, I am working with adding a gimbal to the plane model in gazebo simulation of px4. According to the example of typhoon_h480, I created a copy of 6011_typhoon.post named 1030_plane.post in /Firmware/ROMFS/px4fmu_common/init.d-posix. Then I added H480’s gimbal parts(cgo3’s links and plugins) to the plane’s sdf document. I can control the gimbal on H480 with ros message /mavros/mount_control/command but it doesn’t work on my own vehicle. Is there something I missed?

Hi, I can transplant typhoon’s gimbal to iris now, but it still doesn’t work with my custom fw model. After these steps, my gazebo simulation stucked because some unknown reasons. But after disabling the MNT_ MODE_IN parameter, my model works again.

I think maybe I found why my model stucked when start the gazebo simulation. I changed the parameter VEHICLE_TYPE from fw to mc and MAV_TYPE from 1 to 2(or other multicopter airframe). The gazebo simulation started normally without stucking. Although the motors didn’t work properly, the gimbal worked well. But I still don’t know what caused this problem. I am trying to find out the specific difference between fw and mc in px4 firmware’s source code about building px4_sitl_default.
Is there someone can tell me about where the code that may cause the stucking when launching gazebo simulation after enabling the MNT_MODE_IN parameter for my custom fixedwing models with typhoon’s gimbal part is?

One year has passed, I don’t know if you solved it. :sweat_smile:
You should modified the parameters of gazebo_mavlink_interface in you plane.sdf, and add the output channal for gimbal to the mixer.

@petertheprocess is right, you can employ that solution, to elaborate.
You should try to use the gazebo_gimbal_controller_plugin.cpp from px4, but what @petertheprocess would recommend is to use the control values, etc in mixer config R P Y T for FW, and map to the joint in the sdf.

1. Mixer

# mixer for the any given rotational axis
M: 1
O:      10000  10000   0 -10000  10000
S: 0 1  10000  10000    0 -10000  10000
# 0 Roll 1 Pitch 2 Yaw 3 Throttle

2. SDF

<plugin name='mavlink_interface' filename='libgazebo_mavlink_interface.so'>
...
<control_channels>
...
<channel name="rand_name">
          <input_index>"matching_index_to_mixer_output"</input_index>
          <input_offset>0</input_offset>
          <input_scaling>1</input_scaling>
          <zero_position_disarmed>0</zero_position_disarmed>
          <zero_position_armed>0</zero_position_armed>
          <joint_control_type>position_kinematic</joint_control_type>
          <joint_name>"name_of_joint"</joint_name>
</channel>
</control_channels>

Or you can attach your own gazebo plugin (I don’t know how you would do this, since you would try to tap on the mavlink message for gimbal) to convert the values from px4 publish to mavlink, then to gazebo message then to the plugin, to force a certain rotational value with scaling and dampening.

// Name of Joint, you use the sdf elements (GetElement) if you have been playing around with gazebo, you can set a default parameter
JointName = sdf->Get<std::string>("JointString");
// Check Existence, if not use search model joint
if (this->model->GetJoint(JointName))
      this->Joint = this->model->GetJoint(JointName);
// etc you can use rotation about axis
// 0 Roll 1 Pitch 2 Yaw 
#if GAZEBO_MAJOR_VERSION >= 9
        Direction = this->Joint->LocalAxis(0)[0] * ScaleFactor;
#else
        Direction = this->Joint->GetLocalAxis(0)[0] * ScaleFactor;

Long story short yes go with @petertheprocess

1 Like