SITL autopilot doesn't pilot

Hi,

I’m trying to make the SITL work and I have some issue. I followed those tutorials (and the linux one), it worked fine. I run the following command :

in the ardupilot/Tools/autotest folder (since the sim_vehicle.sh is there now), I then have the alert message : “APM: PreArm: RC not calibrated” which I “solve” by running;

in the terminal. Then I load some waypoint by calling the toff-loop file ( wp load ArduPlane-Missions/CMAC-toff-loop.txt ), it does work. Finally I would like my simulated ArduCopter to go through all the check point so i turn it in auto mode ( which works cause i have the AUTO> prompt ) but then nothing happend. the Alt value stay at 0 so is the rest of value displayed by the GUI.
During the whole time I have the same message displayed ( in my terminal ) over and over :

[code]Traceback (most recent call last):
File “build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_map/mp_slipmap.py”, line 967, in on_mouse

File “build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_map/mp_slipmap.py”, line 825, in update_position

File “build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_map/mp_elevation.py”, line 44, in GetElevation
File “build/bdist.linux-x86_64/egg/MAVProxy/modules/mavproxy_map/srtm.py”, line 179, in getTile
IOError: [Errno 2] No such file or directory: ‘/home/samuel/.tilecache/SRTM/filelist_python’[/code]

So i searched a bit and found out that it’s a file generated (downloaded ?) by the srtm.py but it seems it does create (or download) the file properly (at least for me). (By the way the map doesn’t load aswell but the two thing are related).

Thanks in advance,
Sam

PS : if anyone has a better fix for the ARMIN_CHECK thing i’m taking it, i tryied to change it directly in the AP_Arming.cpp file by setting require at 0 :

I also set armed to true in the constructor ( armed(true) ) but i doesn’t seems to work.

hey I don’t know if it can help help anyone but since i’ve solved the issue a while ago i’m gonna post it.

so first of all to arm properly the throttle the command is pretty straight forward : “arm throttle”, then for some reason i can’t manage to make the arducopter take-off using waypoint. So I had to use a function I defined in mavproxy.py. You could also use this command to simulate a rc signal : “rc 3 1700”

The function I used is something I took from the autotest.py file.

[code]def cmd_takeoff(args):

alt_min = 20
if mpstate.vehicle_type == ‘copter’:
if not mpstate.master().motors_armed():
mpstate.master().arducopter_arm()
mpstate.master().motors_armed_wait()

  rc = mpstate.module("rc")
  if not rc == None : 
     rc.cmd_rc([3,1700])
     m = mpstate.master().recv_match(type='VFR_HUD', blocking=True)
     if m.alt < alt_min :
        wait_alt(alt_min, (alt_min+5))
     rc.cmd_rc([3,1370]) #1370 seems to hover the copter
     return True

return False

def wait_alt(alt_min, alt_max, timeout=30):
climb_rate = 0
previous_alt = 0
tstart = time.time()

print(“Waiting for altitude between %u and %u” % (alt_min, alt_max))
while time.time() < tstart + timeout:

  m = mpstate.master().recv_match(type='VFR_HUD', blocking=True)
  climb_rate =  m.alt - previous_alt
  previous_alt = m.alt
  print("Wait Altitude: Cur:%u, min_alt:%u, climb_rate: %u" % (m.alt, alt_min , climb_rate))
  if abs(climb_rate) > 0:
     tstart = time.time();
  if m.alt >= alt_min and m.alt <= alt_max:
     print("Altitude OK")
     return True

print(“Failed to attain altitude range”)
return False[/code]

then i added the cmd takeoff in the command list :

command_map = { 'script' : (cmd_script, 'run a script of MAVProxy commands'), 'setup' : (cmd_setup, 'go into setup mode'), 'reset' : (cmd_reset, 'reopen the connection to the MAVLink master'), 'status' : (cmd_status, 'show status'), 'set' : (cmd_set, 'mavproxy settings'), 'bat' : (cmd_bat, 'show battery levels'), 'alt' : (cmd_alt, 'show relative altitude'), 'link' : (cmd_link, 'show link status'), 'reboot' : (cmd_reboot, 'reboot the autopilot'), 'up' : (cmd_up, 'adjust TRIM_PITCH_CD up by 5 degrees'), 'watch' : (cmd_watch, 'watch a MAVLink pattern'), 'module' : (cmd_module, 'module commands'), 'alias' : (cmd_alias, 'command aliases'), 'time' : (cmd_time, 'Show autopilot time'), 'takeoff' : (cmd_takeoff, 'Drone Takes off'), #added }

well that’s it :slight_smile: I hope it could help someone.

Sam

Hi Sam, i’m new in this forum. I have the same problem, so i add the code you posted here. But i don’t understand where i have to call the takeoff function that i created. I can’t call it from the MAV terminal (the page where i put the arm and the wp command). Which command should i write there to call the takeoff command?

Thank you,

Enrico

Hi Sam, i didn’t rebuild and reinstall MAVProxy. From terminal i went to the MAVProxy folder and i ran this commands:

Now it is working,
Enrico

Hi,
Yes I forgot to say that after that you have to rebuild MAVProxy. I’m glad you solved your issue :slight_smile:

Sam

Hi,

I am using the sitl simulator, now it starts correctly and thanks to your function it takes off well, but it still have some trouble during the flight. It often hit the ground, and i don’t understand if it is a simulator’s problem or one my problem (i pass the wrong parameters or whatever else). I would like to solve this problem before i use the true quadcopter. Does your simulator have the same problem? Have you any ideas of what could it be?

Enrico

Hi,

Well to be honnest i don’t have those problems… but I know that the message displayed by the simulation : “Hit ground at X m/s” is written by the multicopter.py which is part of the component simulation. I don’t know if it can helps you :s

Sam

Hi,

I checked my MAVProxy folder and it didn’t have setup.py file but I had setup.py file in pvmavlink folder. Is it the same folder for running the commands ?

python setup.py build

python setup.py install

The error I am getting is:

MAV> STABILIZE> Received 511 parameters
Process Process-1:
Traceback (most recent call last):
File “/usr/lib/python2.7/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/usr/lib/python2.7/multiprocessing/process.py”, line 114, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python2.7/dist-packages/MAVProxy/modules/mavproxy_map/srtm.py”, line 128, in createFileListHTTP
conn.request(“GET”,self.directory)
File “/usr/lib/python2.7/httplib.py”, line 973, in request
self._send_request(method, url, body, headers)
File “/usr/lib/python2.7/httplib.py”, line 1007, in _send_request
self.endheaders(body)
File “/usr/lib/python2.7/httplib.py”, line 969, in endheaders
self._send_output(message_body)
File “/usr/lib/python2.7/httplib.py”, line 829, in _send_output
self.send(msg)
File “/usr/lib/python2.7/httplib.py”, line 791, in send
self.connect()
File “/usr/lib/python2.7/httplib.py”, line 772, in connect
self.timeout, self.source_address)
File “/usr/lib/python2.7/socket.py”, line 571, in create_connection
raise err
error: [Errno 110] Connection timed out
[Errno 2] No such file or directory: ‘/home/shiv/.tilecache/SRTM/filelist_python’
[Errno 2] No such file or directory: ‘/home/shiv/.tilecache/SRTM/filelist_python’

STABILIZE> [Errno 2] No such file or directory: ‘/home/shiv/.tilecache/SRTM/filelist_python’
[Errno 2] No such file or directory: ‘/home/shiv/.tilecache/SRTM/filelist_python’

Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 810, in __bootstrap_inner
self.run()
File “/usr/lib/python2.7/threading.py”, line 763, in run
self.__target(*self.__args, **self.__kwargs)
File “/usr/local/lib/python2.7/dist-packages/MAVProxy/modules/lib/wxconsole.py”, line 62, in watch_thread
msg = self.parent_pipe_recv.recv()
EOFError

shiv@shiv-VirtualBox:~/ardupilot/ArduCopter$

Please help me as I am new to ardupilot.