Combine two working models for gz sim

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?