I am trying to manually send HIL_ACTUATOR_CONTROLS MAVLink messages directly to Gazebo through a Python script to control a drone. I am sending MAVLink messages through the pymavlink library.
When I start Gazebo, through ROS, it starts, and hangs with a black screen until I start a TCP MAVLink connection with
connection = mavutil.mavtcp("localhost:4560")'
At which point Gazebo will finish starting up, and run for 5 seconds, until it hangs again.
According to the simulation documentation, because Gazebo is running in Lockstep mode, Gazebo should be freewheeling HIL_SENSOR messages to me until it receives its first HIL_ACTUATOR_CONTROLS message. However, when I check the_connection.messages (as is suggested to check the messages received), the only messages that I see I’ve gotten are a ‘MAV’ message and a ‘HOME’ message, neither of which are valid messages. I have tried sending HIL_ACTUATOR_CONTROLS messages nonetheless, but Gazebo does not respond.
Note that I have been able to connect and control a drone in Microsoft AirSim this way (by connecting with connection.mavtcp(“localhost:4560”) and manually sending HIL_ACTUATOR_CONTROLS messages.)
To summarize, my questions are as follows:
- Why isn’t Gazebo sending me any HIL_SENSOR messages?
- Why isn’t Gazebo listening to my HIL_ACTUATOR_CONTROLS messages?
EDIT: I’ve found where the HIL_SENSOR messages are. Instead of calling
connection.messages, I need to call
connection.recv_msg(). Not sure why
connection.messages doesn’t work, though.