Closed IkerZamora closed 8 years ago
I was unable to find the direct cause to this communication problem. But here are a few ideas to try to solve it:
Make sure the fdm_packet structure is identical on both sides: https://github.com/AurelienRoy/ardupilot/blob/wall_follow/libraries/SITL/SIM_Gazebo.h And https://github.com/AurelienRoy/ardupilot_sitl_gazebo_plugin/blob/master/ardupilot_sitl_gazebo_plugin/include/ardupilot_sitl_gazebo_plugin/ardupilot_sitl_gazebo_plugin.h
Make sure the connection adress / ports are identical.
Launch first Ardupilot. It initializes then waits for the RC link connection (mavros). Then launch ROS (the simulation plugin). The plugin main loop will wait until Ardupilot sends a message. Meanwhile mavros starts, connects to Ardupilot, which resumes Ardupilot. Once Ardupilot is connected to RC (mavros), it sends messages to the simulation plugin (the servos / fdm packets).
Add breakpoints or prints in Ardupilot to make sure its execution reaches the file SIM_Gazebo.cpp
Good luck!
I already checked those:
../Tools/autotest/sim_vehicle.sh -j 4 -f Gazebo --map --console
That opens a new console with the following output:
Started model Gazebo at -35.363261,149.165230,584,353 at speed 1.0
Starting sketch 'APMrover2'
Starting SITL input
bind port 5760 for 0
Serial port 0 on TCP port 5760
Waiting for connection ....
The problem, I guess, might be hidden somewhere in the code I had to add. Because removing the parachute methods as I did shouldn't affect the communication, right?
I might have fixed the communication issue. I'm not completely sure, thought. I changed the rover model format from .sdf to .urdf so I could insert all the plugins needed for the sensors (such as IMU, GPS, etc). By doing that it seems that the communication starts:
Started model Gazebo at -35.363261,149.165230,584,353 at speed 1.0
Starting sketch 'APMrover2'
Starting SITL input
bind port 5760 for 0
Serial port 0 on TCP port 5760
Waiting for connection ....
bind port 5762 for 2
Serial port 2 on TCP port 5762
bind port 5763 for 3
Serial port 3 on TCP port 5763
Opened Gazebo servos send socket
Opened Gazebo fdm receive socket
servo[4] modified into 1000
servo[5] modified into 1000
servo[6] modified into 1000
servo[7] modified into 1800
servo[8] modified into 1000
servo[9] modified into 1000
servo[10] modified into 1000
servo[11] modified into 1000
servo[12] modified into 1000
servo[13] modified into 1000
------------------------
But Gazebo gets stuck trying to insert the new urdf model, so simulation won't start. I guess this is due to errors in the model. I hope that fixing those the problem gets solved.
I'm trying to develop a modification of this plugin to simulate a Rover and I'm not able to make it work. I'm stuck in the communication side. Here is the repo what I have done so far. I don't fully understand how the communication works. For instance, how does it start? How is the first message sent? I'm able to open both sockets without any issue, but when trying to receive packets from APM I don't receive anything, all the messages are -1 size, instead of 64. Any clue?
Here is an execution example: