Making SITL easy to run on Windows & OS-X

893 views
Skip to first unread message

Kevin Hester

unread,
Jan 24, 2015, 12:04:46 PM1/24/15
to drones-discuss
Hi ya'll,

I recently used Tridge's linux-sitl instructions and Randy's windows-sitl instructions to make a close to 'one click' SITL image for Windows/OS-X/Linux.  (It isn't actually one click yet, but much easier - more like 30 keystrokes and 10 clicks ;-))

So if you've been wanting to use SITL to develop with but had problems on Windows you might want to give this a shot.

I used Vagrant, which is a tool that uses VMs for running standard containers on any OS.  The speed penalty vs 'native' should be small.

The instructions are here.

Any feedback would be appreciated.  This same image could be used to build AVR and PX4 based loads on Windows - probably much faster than from the windows gcc environment (because ccache is included).  However, I haven't tried this yet.  If I've missed required dependencies, please add them to the script used to init the VM (and send in a pull-request ;-)).


Craig Elder

unread,
Jan 24, 2015, 12:16:55 PM1/24/15
to drones-discuss

Thanks Kevin. This is great news!

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott S

unread,
Feb 3, 2015, 1:09:28 AM2/3/15
to drones-...@googlegroups.com
Kevin,

In my attempt to get this setup on my machine (Windows 7 64 bit) I ran into a problem at the vagrant ssh -c "sim_vehicle.sh -j 2" call. I was given the following error:

'ssh' executable not found in any directories in the %PATH% variable. Is an SSH client installed? Try installing Cygwin, MinGW or Git, all of which contain an SSH client. Or use your favorite SSH client with the following authentication information....

I was hesitant to add one of these packages because git is already being installed, so maybe the path to that directory just needs to be added. Also, I'm fairly new to this so it could just be an issue on my end. 

Hamish Willee

unread,
Feb 28, 2015, 12:49:30 AM2/28/15
to drones-...@googlegroups.com
Hi Kevin, Scott,

There is definitely a dependency on SSH, but fixing this does not allow the script to work. 

The error I first get is as below. If I set SSH in my path I get the same error (I set path to include SSH in git, and then tested this by running SSH in command prompt)


==> default: rm: cannot remove ???/home/vagrant/.screenrc???
==> default: : No such file or directory
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what

Once SSH is fixed, if I then run vagrant ssh -c "sim_vehicle.sh -j 2" I get the following errors:

C:\Users\hamis_000\Documents\gitrepos\ardupilot\Tools\vagrant>vagrant ssh -c "sim_vehicle.sh -j 2"
/vagrant/Tools/vagrant/shellinit.sh: line 2: $'\r': command not found
/vagrant/Tools/vagrant/shellinit.sh: line 5: $'\r': command not found
: No such file or directorylinit.sh: line 6: cd: /vagrant
/vagrant/Tools/vagrant/shellinit.sh: line 7: $'\r': command not found
Ardupilot environment ready.  Run 'sim_vehicle.sh' to start simulating an arducopter instance.
or run 'make sitl' to just do a test build.
NOTE: This vagrant build environment isn't currently intended for building PX4 loads, but if someone wants
to add that ability it wouldn't be too difficult.
bash: sim_vehicle.sh: command not found
Connection to 127.0.0.1 closed.

I guess there is a whole lot of setup stuff being done at https://github.com/diydrones/ardupilot/blob/master/Tools/vagrant/initvagrant.sh#L12 which simply isn't happening because this fails. 

I am still playing around to see if I can get this to work, but some real expertise would be appreciated! 

Would be good to know if ANYONE can get this to work.

Regards
H

Kevin Hester

unread,
Feb 28, 2015, 9:03:56 PM2/28/15
to drones-...@googlegroups.com
Hi Hamish,

Comments inline.  I've heard a fair number of success stories from OS-X and windows users (>3 but <10).  Comments inline...

On Fri, Feb 27, 2015 at 9:49 PM Hamish Willee <hamish...@gmail.com> wrote:
Hi Kevin, Scott,

There is definitely a dependency on SSH, but fixing this does not allow the script to work. 

The error I first get is as below. If I set SSH in my path I get the same error (I set path to include SSH in git, and then tested this by running SSH in command prompt)


==> default: rm: cannot remove ???/home/vagrant/.screenrc???

Hmm - is it possible you previously ran the script with sudo?
 
==> default: : No such file or directory
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what

Once SSH is fixed, if I then run vagrant ssh -c "sim_vehicle.sh -j 2" I get the following errors:

C:\Users\hamis_000\Documents\gitrepos\ardupilot\Tools\vagrant>vagrant ssh -c "sim_vehicle.sh -j 2" 
/vagrant/Tools/vagrant/shellinit.sh: line 2: $'\r': command not found

This is really interesting.  Is it possible you opened the shellinit.sh file and saved it from a Windows text editor?  The \r looks like what I'd expect a windows editor to insert into the file.
   

Hamish Willee

unread,
Mar 1, 2015, 5:02:40 AM3/1/15
to drones-discuss
HI Kevin,

I ran "git config --global core.autocrlf false" and this stopped git using the windows line endings - the windows text editor point a very useful hint! So even though I still get the "rm cannot remove ..." error I am able to run ssh -c "sim_vehicle.sh -j 2" and connect to the running simulator!  Thanks very much for your help!

I still got the same problem with:

==> default: rm: cannot remove ???/home/vagrant/.screenrc???
I have definitely not run the script with sudo. Basically this is a completely clean installation. My cmd.exe input looks like:
    git config --global core.autocrlf false
    //cd to vagrant directory, then
    vagrant up.

Is this code (and the bit after it that doesn't run) essential? While it would be good to have it running/know why it isn't, it is almost as good to be able to say "ignore this error". Any other ideas on how I might debug this?

Re the ssh dependency and requirement for line endings to be right, is there any way we could include tests for these in the script itself?

Thanks again

Regards
Hamis



--
You received this message because you are subscribed to a topic in the Google Groups "drones-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drones-discuss/PVadRaurYS8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drones-discus...@googlegroups.com.

Hamish Willee

unread,
Mar 1, 2015, 8:02:16 PM3/1/15
to drones-discuss
Hi Kevin

Further to that I have created a draft wiki article http://dev.ardupilot.com/wiki/simulation-2/setting-up-sitl-using-vagrant/ - I say draft because it won't be complete until I've answered the questions in the previous email. Once I'm done and everyone is happy I'll link  it into the other documents.


Below are the current questions, and a new set:
1. What is the impact if the the code after "rm: cannot remove ???/home/vagrant/.screenrc???" in the initialisation script does not run? If we can't debug this, can we at least move that option to the end of the script so that everything else gets done?


2. This just simulates arducopter by default, with two cores
vagrant ssh -c "sim_vehicle.sh -j 2"
- The assumption is your PC will always have at least 2 cores? 

3. To simulate another vehicle, this appears to work:
vagrant ssh -c "sim_vehicle.sh -j 2 -v ArduPlane"

Does that mean that the JSBSim stuff is also in the VM?

4. HOw would you update to latest SITL/Simulation or a specific version?
If you update the git tree doing git pull, will vagrant up or @vagrant ssh -c "sim_vehicle.sh -j 2"@ be smart enough to know that the sources need to be rebuilt? Or is the building done from sources gathered in some other way?
- The follow on question - can I use this same tree/vagrant VM instance for my own development or do I need to set something else up?


FYI, I have some other thoughts on SITL doc organisation, but I'll treat those as a separate problem.

Thanks!

H

Kevin Hester

unread,
Mar 2, 2015, 11:44:14 AM3/2/15
to drones-...@googlegroups.com
Hi Hamish,

Cool!  See below...

On Sun, Mar 1, 2015 at 5:02 PM Hamish Willee <hamish...@gmail.com> wrote:
Hi Kevin

Further to that I have created a draft wiki article http://dev.ardupilot.com/wiki/simulation-2/setting-up-sitl-using-vagrant/ - I say draft because it won't be complete until I've answered the questions in the previous email. Once I'm done and everyone is happy I'll link  it into the other documents.

Great idea.  Feel free to snarf anything you want from https://github.com/diydrones/ardupilot/blob/master/Tools/vagrant/README.md
 


Below are the current questions, and a new set:
1. What is the impact if the the code after "rm: cannot remove ???/home/vagrant/.screenrc???" in the initialisation script does not run? If we can't debug this, can we at least move that option to the end of the script so that everything else gets done?


Alas - I'm busy with some other stuff this week and probably won't have a  chance to investigate this until next weekend.
 

2. This just simulates arducopter by default, with two cores
vagrant ssh -c "sim_vehicle.sh -j 2"
- The assumption is your PC will always have at least 2 cores? 

Not exactly - even if your PC has less than two cores (very rare today ;-)) this should still work.  It is just using multiple threads.
 

3. To simulate another vehicle, this appears to work:
vagrant ssh -c "sim_vehicle.sh -j 2 -v ArduPlane"

Does that mean that the JSBSim stuff is also in the VM?

Yes.  I included the JSBSim stuff and it autobuilds it.  btw - normally sim_vehicle.sh tries to derive the type of vehicle to run based on the current directory.  That's why the vagrant stuff sets things up to cd into ArduCopter first.  If you had run sim_vehicle.sh from the ArduPlane directory it would have defaulted to simulating a plen.
 

4. HOw would you update to latest SITL/Simulation or a specific version?

Just update your git tree.
 
If you update the git tree doing git pull, will vagrant up or @vagrant ssh -c "sim_vehicle.sh -j 2"@ be smart enough to know that the sources need to be rebuilt? Or is the building done from sources gathered in some other way?

Yes.
 
- The follow on question - can I use this same tree/vagrant VM instance for my own development or do I need to set something else up?


Yes - you can share the tree between the vagrant image and the 'outside' OS.  That is actually the intent.  So you can edit code and the SITL will be running your dev tree code.

Kevin Hester

unread,
Mar 2, 2015, 7:12:34 PM3/2/15
to drones-...@googlegroups.com
Hi Hamish,

I just sent in a PR which should keep git from trying to stick in carriage returns into .sh files on windows:


To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "drones-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drones-discuss/PVadRaurYS8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drones-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsubscribe@googlegroups.com.

Hamish Willee

unread,
Mar 2, 2015, 7:21:34 PM3/2/15
to drones-discuss
Awesome!

Regarding:
Below are the current questions, and a new set:
1. What is the impact if the the code after "rm: cannot remove ???/home/vagrant/.screenrc???" in the initialisation script does not run? If we can't debug this, can we at least move that option to the end of the script so that everything else gets done?


>Alas - I'm busy with some other stuff this week and probably won't have a  chance to investigate this until next weekend.
 

I tried this out in initvagrant.sh. Basically the bit that gets missed when this fails is building JSB sim. This is not critical because the code gets built again anyway AFAIK if you select a plane target. 

echo "source /vagrant/Tools/vagrant/shellinit.sh" >>/home/vagrant/.profile
rm /home/vagrant/.screenrc
ln -s /vagrant/Tools/vagrant/screenrc /home/vagrant/.screenrc

But it is probably a good idea to move this bit to the end so that as much of the script completes as possible.

I am updating the docs with your information now!

Cheers
H


To unsubscribe from this group and all its topics, send an email to drones-discus...@googlegroups.com.

Kevin Hester

unread,
Mar 2, 2015, 8:03:38 PM3/2/15
to drones-discuss
oh - thanks for tracking that down.  I just updated the previous PR to also fix the problem with .screenrc being missing on virgin installs.

To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.

Hamish Willee

unread,
Mar 2, 2015, 8:22:10 PM3/2/15
to drones-discuss
Hi Kevin

Excellent. I have updated http://dev.ardupilot.com/wiki/simulation-2/setting-up-sitl-using-vagrant/ so that it no longer refers to the .screenrc issue. I've kept the line endings warning until the PR goes in. This is now live - plumbed into the TOCs. 

You will notice a warning up the top that a dedicated Linux box is required for serious development due to timing issues, and consequently that  VM usage of SITL is suitable for demos and learning how things work. This was a fairly clear direction from Tridge. I have updated the SITL for windows document so that it shares these warnings.

I think we're pretty much done  (though there are other more general SITL docs improvements I want to make).

Once again, thank you for this article and solution. It is MUCH easier and more reliable than the manual approach :-)

Cheers
H

Reply all
Reply to author
Forward
0 new messages