Scuba Simulator

Stuart Scuba DIving

Scuba Simulator Demo

The nerd gland never rests

 As a self-confessed and proud nerd, I cannot help but look at projects to work on.  The Scuba Simulator is one such project.  This exploration into modelling Scuba Divings effect on the human body brings together my experience as a former PADI scuba instructor, and my love for just seeing if something can be done.  Think of it as a sort of technological adventure.

The model can be seen in action on scubasim.stulast.co.uk and will be updated as I continue to develop this app, and add a nice front end to it.

Big Decisions

The first phase of developing the SCUBA simulator has been about finding the most appropriate languages and libraries to support the goal of providing a realistic simulation of the physical and biological effects of depth on the human body.

Given that the main goal is to provide a readily accessible demonstration, a web-based solution seemed most appropriate.  It means that I can get prototyping quickly, without the need to learn any new languages or IDE's, and can concentrate on understanding the intricacies of the model, rather than getting bogged down in code quandaries.

I have chosen to go with OOP javascript with a little jquery, eventually adding three.js for the visual aspects and simulation interface.  For now, though, the focus is on getting the model and the numbers right.  I have also decided to wrap this in a PHP backend, via CodeIgniter, to allow the application to hold and serve a range of scenarios.  This could also lead to the development of profiles for individual users, but that will be done as an optional extra to this project.

Putting together a toolbox

Aside from the actual modelling of the Scuba Simulator, I have had the chance to look deeper into how I set up my development toolkit and change management.  Yes - it's all al ittle nerdy, but this is what years of working in the industry have taught me, and it kind of becomes second nature now.

So here is the run down of my core development toolkit:

GIT Version Control

Without questions having a change management system is a lifesaver.  Being able to go forward and back through changes, to branch out and try something different is great.  I can experiment with an idea, safe in the knowledge that if I do balls it all up, I can just revert back, or switch to a different branch.

Bitbucket.  Github is great, but there is a limit on how many private projects you can have.  Bitbucket is just as great, but let's you have a hole load of private projects.  Not a functionality question, just a question of costs.

Vagrant Virtual Machine.

For many years I used WAMP/XAMPP virtual machines in my web development work.  Like many "preferences" it's down to what you first used and first became proficient with.  The industry changes and advances so quickly, though, that it behoves us to keep up to date and, in that process, we may be lucky to find a new technology or method that gives us greater flexibility and productivity.  I am looking at Docker as part of my foray into DevOps, but for most of my current projects, Vagrant is a simple to use and quick to configure.

Visual Studio Code

 Okay so I have steered clear of Visual Studio for the longest time, basically due to it's bulk.  I have tangled with Eclipse, and even made heavy use of Netbeans.  In the end though, a text editor designed for coding is a saviour to the modern coder.  There are many out there, including Notepad ++ and Sublime Text.  I had the opportunity to try out Visual Studio Code, the light-weight text/code editor and you know what,  I actually quite like it.  The plugins can be a little annoying but in it's raw and uncluttered download state, it's pretty useful.  It also has some handy windows for terminal, output and debugging, which cuts down on a lot of switching between application windows just to do a commit or spin up a vagrant box.

Node JS, SASS and Gulp.

  So the final piece of the jigsaw comes down to package management.  Node JS provides a great library for this in the form of NPM.  By throwing in SASS and scripting the build process in Gulp I have saved hours of work, built consistency in my finished code, and compressed everything for web usage.  I have to say this is my first real foray into creating Gulp scripts as opposed to just using them, but I have become a big fan.

The Model

So with a toolkit pulled together, the task of actually building a model is where the challenge actually lies, and is the main reason to use OOP. THere are so many interacting aspects of Scuba Diving that have an impact on the physiology of the human body. Air consumption increases with pressure, as does the nitrogen load which must be dispersed at a safe rate during the ascent at the end of the dive. The bouyancy of the body changes with depth, changing the rate of ascent of descent, which must be at a kept within safe levels. Even light and sound change once subermerged in water. Thus far, the model is capable of measuring descent/ascent rates and air consumption. Next on the hit list is the modelling of how Nitrogen, Oxygen and Helium affect the body. Both Nitrogen and Helium act as inert gasses and are necessary to dilute the oxygen, which can be toxic at pressure. So much so that some gas mixes used at depth are so rarified that they are unbreathable at the surface due to the lack of oxygen. Nitrogen itself can act as a narcotic, leading to some individuals reporting nitrogen narcosis; effectively being drunk at depth. Without doubt the model will build to be quite complex with many objects interacting and affecting the diver object. But if it was a simple bit of code, it just wouldn't be any fun. This post will be updated as the development progresses.