AC.motion

June 22, 2008

Operating the ship

New thought today: The navigational software and the "operating system" (OS) of the ship are two different and distinct things.

The OS handles receiving and transmitting messages, executes commands, reads sensor information, and activates actuators. The navigator uses the OS as a base for implementation on a higher abstraction level.

Navigator Level 1 "Direct Control"

The controller and the navigator act like a normal remote control. Joystick input is transmitted "as is" to specific actuators. In example, pushing the joystick forward increases engine power; moving it from side to side will turn the rudder. The ship follows blindly the commands sent by the controller.

A couple of nice features can be implemented even on this level. In example, the ship could be steered by keyboard, mouse, joystick, joypad, or a combination of those. Imagine using two joysticks: the left one for thrust, and the right one for the rudder. The joystick can be twisted? We could use that for the thrusters to turn the ship.

Input might be integrated. Instead of directly translating joystick position into a thrust setting, the joystick position might be translated into increasing or decreasing the thrust setting at a rate proportional to the position. Leaving it in the middle maintains the current setting.

How about different modes? When you press a joystick button the control mode is changed. Instead of turning the rudder, a side-to-side movement of the stick might use the bow and stern thrusted in parallel to move the ship sideways. Another button click, and the same movement uses the thrusters in opposite directions, turning the ship on the spot.

Endless cool possibilities to do things a normal remote control just can't do!

Navigator Level 2 "Immediate Goal Control"

The controller transmits goals such as "set speed to 10km/h" or "turn to 215°". The navigator uses sensors, goals, and a strategy to achieve these goals to influence actuators. In example, when the ship is standing still the engine power is increased to full until the desired speed is reached, and then throttled, guided by sensor input and maybe helped by predicted performance, to what is needed to maintain speed.

Similarly the command to follow a specific heading will be interpreted by taking into account the current heading, and setting the rudder accordingly.

At this stage the navigator already should possess enough brains to not do "silly things". It might be not a good idea to give full rudder at full speed (might make the ship keel over), and setting the rudder to anything when the ship is not moving will not make the ship turn (use the thrusters instead, or get the ship movings slowly).

Level 2 enables modes such as "stick to the stick": The ship follows the stick movement forward/ backward, sideways left/ right. Point the stick in any direction: the ship will move in that direction; move the stick back to zero: the ship stops.

Navigator Level 3 "Advanced Goal Control"

The controller transmits goals such as "go to position", possibly with a list of waypoints. Or, the navigator knows the "lay of the land" (like, shape of the lake, shallow areas, piers, bridge pillars) and avoids areas where the ship better not go.

Adding sensors such as ultrasound distance measuring provides additional safety against obstacles that are not on the map. Such a feature may be added even at Level 1: The ship might cut thrust or even reverse shortly at full power to avoid slamming into something hard.

Simulating the environment

My current thoughts on the subject.

The simulated ship has a definite
  • position
  • heading
  • velocity vector (speed and direction, which might not be along the heading!)
The environment acts on these parameters:
  • Inertia (linear and rotational). When you turn an engine or thruster on or off, the ship won't start or stop moving/ rotating at once.
  • Resistance (linear and rotational). Velocity and form (it makes a difference to push the ship forward or sideways) creates drag which slows down movement.
  • Wind. Wind might push the ship through the water. The speed of the water moving could be measured.
  • Current. Currents take the ship along though the speed relative to the water may even be zero. Can be measured only by GPS.
  • Waves. Waves probably cause effects similar to wind and current: they push the ship around a bit.
There may be other influences such as hitting an immobile obstacle, pushing around floating objects, or pulling a snagged line.

Sensors such as a compass and GPS are mounted on the ship. In an ideal world the compass gives us the heading of the ship, and the GPS the location. In reality, sensors produce jittery data since measurements carry a certain error, and individual measurements will "jump around" even if nothing changes. GPS for civil use even has a built-in inaccuracy as demanded by the US military.

A compass might provide false readings due to electromagnetic interference. The GPS position sometimes jumps around erratically, shows movement when stopped of the other way round, or provides no data at all due to bad reception. The ship will have to make sense of all that.

The simulators for compass and GPS will take the heading and position of the simulated ship and introduce typical errors by configuration or on request.

On the other side there are actuators such as the engine of the ship, the rudder, and the bow and stern thrusters. In an ideal world the effects of actuator settings leads to a certain behavior of the ship (accelerate, turn). In the real world there are small waves and turbulences which influence the actual performance.

The simulated acceleration and speed of linear and rotational movement will be slightly "uneven". More massive problems can be simulated as well, such as obstruction of movement (the ship is immobilized by external influences), loss of actuator power or control (stuck rudder, lost or stuck propeller, power controller not working at all, "misbehaving", or "stuck" in a specific position).

The simulated actuators act on the simulated ship.

In example, if the engine is producing a certain thrust the ship will accelerate depending of the force provided, mass of the ship, and resistance of the water. The movement will change the position of the simulated ship which in turn will change the position delivered by the simulated GPS.

As another example, the rudder or thruster setting will turn the ship depeding on force provided, rotational inertia of the ship, and resitance of the water. The rotation will change the heading of the simulated ship which in turn will change the heading delivered by the simulated compass.

Once the ship has been built actual performance data such as acceleration and speed for certain power and rudder/ thruster settings can be measured, and likewise sensor behavior.

Back to the start

Three years ago this project had started, to linger for a long time after some furious action at the beginning. I'm currently looking at the software that I wrote mostly about two years ago. As usual, some concepts look foreign, some aspects don't sit quite right, and it's time for a redesign.

What I want to do next is design/ write the software that steers the ship at the same time as the simulation environment. The ship software will not know if it is attached to a real GPS, compass, rudder, engine, and thrusters or the simulated items. This hopefully will improve the odds the boat won't get "lost at sea (lake)", or worse even run into something hard. I'll keep the updates posted!

What about the ship? I still have to get resin and fiberglass on! "What kept you?" Well, there are a couple of spots where I just don't know how to laminate best. There is the rather sharp bow, and I would not like the fibers to lift and make a hollow bulge. At the stern I have the opposite situation: how to I prevent the fibers to lift out from the hollow?

I simply did not want to run into problems that might force me to redo the body into which I put quite a number of hours so far. Meanwhile the resin has expired and I'm thinking about building a replica of the critical spots, and trying out laminating with the old resin and the replica to get a feeling for the real thing.