ArduPilot / ardupilot_gazebo

Plugins and models for vehicle simulation in Gazebo Sim with ArduPilot SITL controllers
GNU Lesser General Public License v3.0
87 stars 83 forks source link

Add Gimbal #37

Closed srmainwaring closed 1 year ago

srmainwaring commented 1 year ago

Feature request

The original version of the project for Gazebo11 included a plugin for a small 2d gimbal. This request is to have the gimbal model updated to run in Gazebo Sim and for the plugin to be ported to work with the gz-sim7 libraries.

Desired outcome

Alternatives

The gimbal model is available for download from Gimbal Small 2D but has not been ported to Gazebo Sim / PBS shading:

Platform

[ ] All [ ] AntennaTracker [ x ] Copter [ x ] Plane [ x ] Rover [ x ] Submarine

Additional context

srmainwaring commented 1 year ago

Tracking development on https://github.com/srmainwaring/ardupilot_gazebo-1/tree/srmainwaring/garden/gimbal-plugin

Progress

Model, additional joint and camera sensor rendering correctly in Gazebo.

gimbal2d

Issues

  1. The gz::sim::systems::JointPositionControl plugin in Gazebo Garden does not seem to work with nested models. It's not clear why not, but it appear that the physics engine is not registering the components::JointPosition on nested models so queries for the joint entities component values fail (because the returned component is empty).

So for example this model can be controlled from the command line:

  <include>
    <uri>model://gimbal_small_2d</uri>
    <name>gimbal</name>
    <pose>0 0 0.11 -1.57 0 1.57</pose>
    <plugin
      filename="gz-sim-joint-position-controller-system"
      name="gz::sim::systems::JointPositionController">
      <joint_name>arm_joint</joint_name>
      <topic>arm_cmd</topic>
      <p_gain>2</p_gain>
      <i_gain>0.1</i_gain>
      <d_gain>0.01</d_gain>
      <i_max>1</i_max>
      <i_min>-1</i_min>
      <cmd_max>1000</cmd_max>
      <cmd_min>-1000</cmd_min>
    </plugin>
    <plugin
      filename="gz-sim-joint-position-controller-system"
      name="gz::sim::systems::JointPositionController">
      <joint_name>tilt_joint</joint_name>
      <topic>tilt_cmd</topic>
      <p_gain>2</p_gain>
      <i_gain>0.1</i_gain>
      <d_gain>0.01</d_gain>
      <i_max>1</i_max>
      <i_min>-1</i_min>
      <cmd_max>1000</cmd_max>
      <cmd_min>-1000</cmd_min>
    </plugin>
  </include>

with

# rotate the arm -1.0 radian
gz topic -t "/arm_cmd" -m gz.msgs.Double -p "data: -1.0"

# tilt the camera +2.0 radian
gz topic -t "/tilt_cmd" -m gz.msgs.Double -p "data: 2.0"

but the same model nested one level deeper does not work.

Issues logged with the Gazebo team: https://github.com/gazebosim/gz-sim/issues/1844

chngdickson commented 1 year ago

@srmainwaring How do we control said gimbal using ardupilot's plugin?

srmainwaring commented 1 year ago

How do we control said gimbal using ardupilot's plugin?

@chngdickson, the PR https://github.com/ArduPilot/ardupilot_gazebo/pull/43 includes a note on how to control the gimbal from MAVProxy using RC overrides. The example is set up as a standard servo gimbal so you should be able to follow the wiki guide https://ardupilot.org/copter/docs/common-camera-gimbal.html with the Gazebo version.

samiamlabs commented 9 months ago

Hi @srmainwaring!

I have been trying to control the camera tilt on a simulated bluerov2 using ardusub and the camera tilt RC input (https://www.ardusub.com/developers/rc-input-and-output.html).

I used this and #43 as a reference. Controlling it using the gz topic works now, but I seem to be getting only a static value on control channel 16 (<control channel="15">) from the ardupilot gazebo plugin. This is the output channel used for tilt on the physical bluerov2 https://bluerobotics.com/store/comm-control-power/control/navigator/.

Do you happen to know if it should be possible to control a simulated camera gimbal this way using ardusub? I'm guessing I may need to add something to my .param file, but am not sure what, or where to find more info about it.

srmainwaring commented 9 months ago

Hi @samiamlabs,

We should be able to sort something out. This issue is closed now, so it would be better to follow up on ArduPilot Discourse (https://discuss.ardupilot.org/). If you add a topic that includes gazebo, gimbal and tag me we can pick it up there. May also be good to add the BlueROV2 model to ArduPilot/SITL_Models so we can provide a standard configuration with a few variants for common payloads.