HITL simulation using a custom controller


So I’ve built a flight controller and uploaded it to the pixhawk. I want to test this with a HITL simulation before I run it on my drone. The project I am working on is an autonomous quadcopter. I have successfully tested some autonomous flights with the standard PX4 PID. When i did this the HITL simulation worked well with gazebo.

Now I have uploaded my own controller that i made on the PX4 hardware support package (embedded coder). When I launch the HITL simulation there is a connection to the gazebo model (i think at least since qground control connects) but i do not have control of the quad. Anouther thing to note is that the actual Pixhawk is controling the sensors, so when i rotate the board the sensor view in qground responds accordingly when it should only respond to the simulated drone. I assume the pixhawk is not actually booting to HITL mode here.

When trying to arm the quad or take off qground throws up an error saying the vehicle didnt respond to the command. I have been using the same set up as for the standard PID as i was hoping only the controller would be replaced and everything else would work the same.

I know there is a HITL mode in the PX4 support package but i cant use this as its only jmav simulator. This is a problem for me as i have a lot of ROS nodes that control the navigation and sensors on my drone.

Any help or advice would be appritiated here i’ve been trying for weeks. Has anyone had this issue?

Edit: so I enabled commander in the start up script which has fixed the issue where the vehicle doesn’t respond to qground control but the pixhawk is still not connected to HITL i.e. the sensors still respond to the actual hardware rather than the simulated model
Could be to do with my MAVLink settings?