How to Print to SITL Console

[SOLVED, see edit below.]

Hi all,

I am very new to SITL and just got the simulator working on a Linux virtual machine. I have made some custom functionality for my UAV where it will perform actions before it reaches a waypoint. I was wondering if there is a way to print to the SITL console for debugging, just to see if my functions are being called properly. If not, what is the best practice for this?

I have tried using SITL_debug("FLAG"); in my function but nothing is printed.

Thanks for the help.

EDIT: As stated by OlivierB, the command hal.console->printf("What you want to print \n"); successfully prints to the SITL console.

@anthonyb Did you figure it out ? I am in the situation than you and I don’t get how to debug properly when working with SITL to analyse new code I did.

@anthonyb Did you figure it out ? I am in the situation than you and I don’t
get how to debug properly when working with SITL to analyse new code I did.

Which instructions are you following on how to use SITL?

Unfortunately I haven’t solved this yet. Let me know if you find any more information on this.

You can use hal.console, e.g. to print to the maxproxy console:
hal.console->printf("What you want to print \n");

2 Likes

Yes, thank you! I just read about this on the website with hal reference. I defintely need to try few examples from the “Codebase” description before to start anything.

@peterbarker
I’m working on Windows 10. I followed the instructions from here.

Hi @OlivierB

I am trying to use hal.console->printf("some text\n") to print some debug messages. But when I run SITL I dont see anything getting printed on the mavproxy console. I am working on linux (Ubuntu 18.04) and I am on Copter 4.1.5.

This is the command I am using:

sim_vehicle.py -v ArduCopter --console --map -m --streamrate=10

I am not able to figure out why this is not working. Have I misunderstood something?

Never mind. Seems like my sim_vehicle.py was calling the wrong build (from another fork).

So hal.console->printf("some text\n") is working fine.