Combine two working models for gz sim

That we can do also. We have a nice wave simulation - if you have a CAD model for the boat I can set something up. I put together a model for a large research vessel for tridge when investigating the quadplane, the physics didn’t scale quite right for that vessel (70+m), but something intermediate may behave better.

Wow, impressive response! Thank you.

1 Like

I have ship motion data, can that be used in the simulation. I would just scale the existing tugboat model. Put the tugboat in waves and let me control the amplitude of the waves. And let the tugboat be driven by data in a file.

Could do, or we can use the wave simulation I developed where you can specify the wave amplitude via a parameter (and control wave direction relative to the wind). The boat motion is governed by non-linear hydrostatic restoring physics, so it’s fairly realistic. The advantage then is that you can command a mission for the boat and the boat motion takes care of itself.

@rhys Can you add 3 axis Gimbal, t3 v3, and two cameras, mounted beneath the iris

Updated in the branch given above:

  • Iris with 3-axis servo gimbal with 2 RGB cameras (different HFOV)

The following params enable the gimbal with direct RC control

MNT1_TYPE        1.000000 0.000000 # Servo (DEFAULT: None)
SERVO5_MIN       1000.000000 1100.000000
SERVO5_MAX       2000.000000 1900.000000
SERVO5_FUNCTION  8.000000 0.000000 # Mount1Roll (DEFAULT: Disabled)
SERVO6_MIN       1000.000000 1100.000000
SERVO6_MAX       2000.000000 1900.000000
SERVO6_FUNCTION  7.000000 0.000000 # Mount1Pitch (DEFAULT: Disabled)
SERVO7_MIN       1000.000000 1100.000000
SERVO7_MAX       2000.000000 1900.000000
SERVO7_FUNCTION  6.000000 0.000000 # Mount1Yaw (DEFAULT: Disabled)
RC6_OPTION       212.000000 0.000000 # Mount1 Roll (DEFAULT: Do Nothing)
RC7_OPTION       213.000000 0.000000 # Mount1 Pitch (DEFAULT: Do Nothing)
RC8_OPTION       214.000000 39.000000 # Mount1 Yaw (DEFAULT: PrecLoiter Enable)

Config details:

Update

You may also be interested in: Add camera zoom plugin by srmainwaring · Pull Request #57 · ArduPilot/ardupilot_gazebo · GitHub which just merged and provides a zoom capability to the simulated camera.

@rhys Now I can’t run simulation. The block

    <include>
      <uri>model://gimbal_small_3d</uri>
      <name>gimbal</name>
      <pose degrees="true">0 -0.01 0.070 90 0 90</pose>    
    </include>

generates error

[Err] [Server.cc:159] Error Code 14: [/sdf/world[@name=“truck_quad_landing”]/model[@name=“quad”]/include[1]/uri:/home/john/ardupilot/sitl/worlds/truck_quad_iris_landing.sdf:L1469]: Msg: Unable to find uri[model://gimbal_small_3d]

path is

/home/john/simulation/SITL_Models/Gazebo/models/gimbal_small_3d

Tried fixing with

export GAZEBO_MODEL_PATH=/home/john/simulation/SITL_Models/Gazebo/models

@rhys Never mind, wrong version of gazebo.

This path command works

export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:/home/john/simulation/SITL_Models/Gazebo/models

To add models and worlds to the resource path in Gazebo Garden use:

export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:/home/john/simulation/SITL_Models/Gazebo/models

GAZEBO_MODEL_PATH is for Gazebo 11 and earlier.

Beat me to it!

Too funny, lets just say great minds think alike :slight_smile:

@rhys I just go from one error to the next.
Now qGroundControl doesn’t connect
and mavyproxy gives the following error

$ cd ~/simulation && ./SITL_Models/Gazebo/launch/mavproxy-multi-vehicle.sh 3
Connect tcp:127.0.0.1:5760 source_system=255
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
Failed to connect to tcp:127.0.0.1:5760 : [Errno 111] Connection refused

Can we do a screen share?

@rhys, never mind again. I just killed it all and tried it again, and it worked. But, circle mode crashes.

@jvorwald - sorry missed the screen share - was late in my location (UK). In future, if you are on Discord you can find me in the simulation and ros channels and the screen share / video conf setup there works well.

Not sure why CIRCLE mode would be failing? By crash do you mean the simulation crashes, or does the vehicle crash? (if the later you may need to manually set rc 3 1500).

@rhys the iris crashes in circle mode and also in follow mode. In follow mode it appears to move towards the moving rover truck. I’ll evaluate the 1500 setting.

What I would like to do next is to write code for simulation that will be transitioned to the quadcopter vehicle companion computer. The code should (1) take off from moving vehicle, first a truck, later a ship; (2) go to various waypoints relative to the ship, I would prefer to use guided mode; (3) aim the camera at a GPS location from the moving truck/ship; (4) return to the GPS puck and search for the aruco marker; (5) land either on of aft of the aruco marker, on the moving truck/ship. Previous we have used python/ ros 1 / guided mode for controlling the aircraft. Now we have to control the gimbal also.

The copter LOITER and CIRCLE modes require throttle to be set to mid to set the climb rate to zero.

You can test this using the iris_runway.sdf example in the ardupilot_gazebo repo.

STABILIZE> LOITER
LOITER> arm throttle
LOITER> rc 3 1700
# climb to around 20m then hold position
LOITER> rc 3 1500
LOITER> CIRCLE
# reduce alt while circling
CIRCLE> rc 3 1200

The copter is set up to follow the truck trailer (this is the behaviour used in the quad-plane truck and quadplane-ship examples). See the additional params set up in the launch file (this from the quadplane, but similar for the iris):

# additional parameter file for the quadplane
cat <<EOF > sitl/quadplane/follower.param
SYSID_THISMAV 3
FOLL_ENABLE 1
FOLL_OFS_X -5
FOLL_OFS_Y 0
FOLL_OFS_Z 10
FOLL_OFS_TYPE 1
FOLL_SYSID 2
FOLL_DIST_MAX 1000
FOLL_YAW_BEHAVE 2
FOLL_ALT_TYPE 1
EOF

The idea is that the trailer (RTK) GPS is a beacon for the copter.

For your project I’d suggest the following approach:

1. take off from moving vehicle

Adapt the plane ship landing Lua script to for copters:

2. go to various waypoints relative to the ship

Switch to GUIDED, compute waypoints and use SET_POSITION_TARGET_LOCAL_NED either through mavlink or the new DDS interface which has support for external control.

3. aim the camera at a GPS location from the moving truck/ship

Not sure if the mission commands handle this in the case of the moving target?

5. land either on of aft of the aruco marker, on the moving truck/ship

Use the modified Lua script.

In summary, the takeoff and landing from the moving platform is handled on the flight controller using scripting. The camera control may need to be commanded off-board (I’m not an expert in the features available here, so would need to review options for that). Mavlink or ROS 2 / DDS in GUIDED for the external control portion.

@rhys I’m still having trouble with the quad crashing, running into the ground,after switching to follow mode. Here’s are record of the commands with comments, on a Ubuntu box

Setup: four terminals, 3 on top, one on bottom

Terminal 1:

cd ~/ardupilot && rm -rf sitl && ~/simulation/SITL_Models/Gazebo/launch/truck-quad_iris-landing.sh

Terminal 3:
.
~/Desktop/QGroundControl.AppImage

Terminal 4:

cd ~/simulation && ./SITL_Models/Gazebo/launch/mavproxy-multi-vehicle.sh 3

Need the following command to make position of all vehicles available

set fwdpos 1

Now start sim

Terminal 2: (Don’t run this time)

clear && cd ~/ardupilot/sitl/worlds/ && gz sim -r truck_quad_iris_landing.sdf

Setup: Arrange Movproxy Console, QGroundControl, Gazebo Sim, and 4 terminals

Gazebo Sim: Close top window, select quad – follow

QGroundControl: Select Multi-Vehicle

Terminal 4:

Load way points for vehicle 1

vehicle 1
wp load /home/john/ardupilot/Tools/autotest/Generic_Missions/CMAC-circuit.txt
wp set 2

Fly the quad in a circle before moving the truck

vehicle 3
mode guided
arm throttle
takeoff 100

Mavproxy Console and QGroundControl should indicate armed. Circle radius is in centimeters, circle rate is deg/s

param show CIR
param set CIRCLE_RADIUS 20000
param set CIRCLE_RATE 5
rc 3 1500
circle

Start the truck driving

vehicle 1
arm throttle
auto

Switch to follow

vehicle 3
param show FOL
param set FOLL_DIST_MAX 2000
param set FOLL_OFS_Z 100
follow

At this point the quad does follow the truck, but the quad descends

rc 3 1500
rc 3 1800

!!! Crash quad hits the ground

Looks like I’ve set the params incorrectly:

Need to set FOLL_OFS_Z negative if we want the following vehicle to be above the truck (NED frame used by ArduPilot has z-(D)own).

I missed NED too, @rhys. Thanks for catching that!

@jvorwald - I’ve run a quick check and FOLLOW is working with FOLL_OFS_Z -10.

There have been some upstream changes that may cause some issues with the gimbal in the branch I provided. I’ve merged a version of the 3d gimbal into ardupilot_gazebo and this will conflict with copy I placed in the truck-iris branch.

There are a couple of options:

  • Update the branch to use the merged upstream gimbal
  • Rename the gimbal in the branch to prevent the conflict.

The upstream gimbal only has one camera attached.

@rhys, Thanks, I should have followed up. I agree it is working! Using -10, and it does follow at prescribed x/y offset. Then I set y=0, x=-10, and then set z =+1. This forced collision with truck bed, and the quadcopter shut down, as expected. So, that brings up my next problem in this sequence. On ship, when they land, the vehicle doesn’t shut down due to the large motions of the ship. What I really want to do is to shut down in the air, and have it drop to the ship. So, can that be done?