Using SITL without ROS

Is it possible to use SITL without mavros / ROS? I am working on an application for a companion computer that will not use mavros and I’d like to be able to switch between connecting it to SITL and the real vehicle pretty seamlessly. Plan is to connect through telem 2, so for SITL may need to use something like socat to make the connection. Has anyone tried this or have pointers on how to about this?
Thanks

Yes, I think that all the SITL simulators integrated into the Firmware don’t have any ROS dependencies. In our lab, we use the Gazebo simulator (http://dev.px4.io/simulation-gazebo.html) without ROS/mavros. Instead, we have controllers that directly receive/transmit MAVLink messages. I think there is pymavlink (http://qgroundcontrol.org/mavlink/pymavlink) for Python and c_library_v1 for interfacing with C/C++. The default SITL configurations transmit messages to udp port 14550 and listen on something like 14556, so if you can setup a UDP connection or use a MAVLink library for it, then it should be easy to use the SITL like a plain vehicle.

Hmmm…didn’t know that you could use Gazebo without ROS. I’ll look into that. I think I’m still missing part of the picture on how the the setup should work. In my mind, my app (in c++) on the offboard computer will send mavlink messages over the serial port so I’m thinking it would be nice if instead of it connecting to /dev/ttyACM0 or /dev/ttyUSB0 it would connect to /dev/ptsXXX or a pseudo serial port that would send the packets to the simulator. I’m not sure if socat can change serial to udp.

So I’ve figured out if you install socat and issue this command:

sudo socat -d -d PTY,link=/dev/pixhawk,raw,b115200,mode=777 tcp:localhost:5760

then you can connect the SITL to tcp port 5760 and whatever is trying to connect to the pixhawk for offboard control can connect to /dev/pixhawk just like it was a serial port. One gap I’m trying to close is how to get a GCS connected as well (without using mavproxy). I’m basically trying to get the simulator to be able to test all the connections as well and to be as close to flying with real hardware as possible. HITL is probably the better answer if I can figure how to get it working.

i haven’t tried hooking up socat with udp. I’m sure it’s possible and probably not that hard, but I haven’t had a chance to do it.

I think we are working on sorting out similar setups. Just to share …

I have managed to get an offboard pi 3 attached to telem2 to function in HITL sim as described in documentation WITH one difference. I do NOT have to start QGC - though I can. The sim appearsto function properly, but net yet thoroughly tested. RC works, too.

When attaching to QGC, I have had no additional issues. Just start it up last, with host port attached px4 flight controller (pixracer) micro-usb port. Only issue for me in doing this is that attaching the usb cable powers up drone - so have to sort out grounds and power on the telem2/pi 3 connection.

Do I understand that what you are doing above is to use socat to mimic the connection to telem2, and run the offboard software as a separate process on host machine, using mavlink and the /dev entries as normal? Is that right?

Finally, I can still get a px4 console by connecting the droneprobe serial pins to a pseudo-ftdi to usb connector, and just screen to the /dev/ttyUSBx that is created.