Flag to check when PX4 start-up is finished and ready

Hi everyone!

I’m trying to change some PX4 parameters from a launch file. I did a script (inside a ROS pkg) which I can execute from the launch file, and it works fine. It’s something like this:

rosparam load config.yml /mavros/param/
rosservice call /mavros/param/push

As I said, it works fine but not always. The problem is that if I execute this script before PX4 is ready, I get the following error: Unknown rosparam: XXXXXX.
I fixed this by adding at the top of the script sleep 15.0, what is more or less the time needed for PX4 to start-up.

My question is about how to improve this and make it more robust. It will probably take longer (or less) on a different computer than mine.
So, is there any flag to check when PX4 is ready? It would be great if I can check it through a ROS topic or similar.

Thanks in advance,
Pedro.

You can check wether it is ready or not using mavros - sys_status from its MAV_STATE. Another way is to wait using while loop until the service exists

Hi @haritsahm,

Thanks for you replay! I’ve tried using sys_status but it didn’t work. Neither waiting for the existence of the services.

From my own guessing, I think that the EKF GPS fusion must finish before any change in the parameters. This fusion happens after what you proposed. Any idea on how to check when GPS fusion finishes?

Thanks again,
Pedro.

I use SITL mode via Gazebo and haven’t tried it on real hardware yet. Have you checked the services using rosservice and inspect them manually via terminal? I’m not sure how to check if the fusion is ready or not

Yes, I have checked the services manually. I’m also using SITL and Gazebo.

Anyway, thanks for your response

Hope someone else can help you!