Skip to main content

A library to make coding AUVs easier

Project description

ezauv

ezauv is a Python library to make AUVs, or autonomous underwater vehicles, easy. This library was created for BVR AUV, Beaver Country Day School's RoboSub team.

Why?

In the yearly RoboSub competition, teams build autonomous submarines. Much of the code of these submarine can be abstracted into a few basic concepts: tasks, like travelling a vector or circling a buoy; subtasks, like holding heading or depth; and sensors, such as IMUs and depth sensors. ezauv provides an easy interface for all of these pieces of code to simplify their creation. More importantly, ezauv solves the motors needed to travel a specific vector and rotation under the hood, regardless of the thrust vectors or locations of the motors and the sub's overall dimensions. This allows the code for one hardware surface to be ported to another with almost no change to the code.

ezauv also provides interfaces for logging data to file, building the inertia tensor of your sub from a set of geometries, and some simple tasks and subtasks such as accelerating in a direction or using a PID on rotation.

Installation

  • Make sure pip is installed and working
  • Check your Python version; ezauv is built for Python 3.11, but will likely work on most versions >3
  • Run the following command with pip:
pip install ezauv

For developer information, read the wiki.

Example Program

This example creates a simulation with a square hovercraft, moves it forward, moves it backwards, and then spins it.

import numpy as np
from ezauv.auv import AUV
from ezauv.hardware import MotorController, Motor, SensorInterface
from ezauv.utils.inertia import InertiaBuilder, Cuboid
from ezauv.mission.tasks.main import AccelerateVector
from ezauv.mission.tasks.subtasks import HeadingPID, Simulate
from ezauv.mission import Path
from ezauv.simulation.core import Simulation

motor_locations = [
	np.array([-1., -1., 0.]),
	np.array([-1., 1., 0.]),
	np.array([1., 1., 0.]),
	np.array([1., -1., 0.])
] # first, we'll write down the locations of the motors

motor_directions = [
	np.array([1., -1., 0.]),
	np.array([1., 1., 0.]),
	np.array([1., -1., 0.]),
	np.array([1., 1., 0.])
] # next, we'll write down their thrust vectors

# this debug motor configuration is the same as bvr auv's hovercraft

bounds = [[-1, 1]] * 4 # motors can't go outside of (-100%, 100%)...

deadzone = [[-0.1, 0.1]] * 4 # or inside (-10%, 10%), unless they equal 0 exactly

sim = Simulation(motor_locations, motor_directions, 1/6, bounds, deadzone)

sim_anchovy = AUV( # anchovy is the name of bvr auv's sub
	motor_controller = MotorController(
		inertia = InertiaBuilder(
			Cuboid(
				mass=1,
				width=1,
				height=1,
				depth=0.1,
				center=np.array([0,0,0])
			) # just a square hovercraft
		).moment_of_inertia(),

		motors = [
			Motor(
				direction,
				loc,
				sim.set_motor(i),
				lambda: 0,
				Motor.Range(bounds[i][0], bounds[i][1]),
				Motor.Range(-deadzone[i][0], deadzone[i][1])
			)
			for i, (loc, direction) in enumerate(zip(motor_locations, motor_directions))
			# this creates a motor object for each of the motor speed and location combos
		]
	),
	sensors = SensorInterface( # create a sensor interface from the simulation's sensors
		imu=sim.imu(0.05),
		depth=sim.depth(0.)
	)
)

sim_anchovy.register_subtask(Simulate(sim)) # gotta make sure it knows to simulate the sub

sim_anchovy.register_subtask(HeadingPID(0, 0.03, 0.0, 0.01)) # this will keep it facing straight

mission = Path(
AccelerateVector(np.array([1., 0., 0., 0., 0., 0.]), 2), # start by going forward
AccelerateVector(np.array([-1, 0., 0., 0., 0., 0.]), 2), # slow down...
AccelerateVector(np.array([0., 0., 0., 0., 0., 100.]), 10) # spin as fast as you can!
) 

sim_anchovy.travel_path(mission)
sim.render() # this generates a video of the simulation using pygame in animations/animation.mp4

Important Note

  • Currently, the library uses Gurobi. It installs a free license using gurobipy, but eventually it expires and either an academic or (very expensive) commerical license must be used. Eventually, this will be replaced with an open-source solver.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezauv-0.1.8.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezauv-0.1.8-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file ezauv-0.1.8.tar.gz.

File metadata

  • Download URL: ezauv-0.1.8.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for ezauv-0.1.8.tar.gz
Algorithm Hash digest
SHA256 6a10ace3c87b9884b5c038e580383dd83bae71269cb2b8bc9e0f97d90799e7fb
MD5 10dbcb887c2b2f5ec6ee87cedb136ce4
BLAKE2b-256 4afb26dbb7086e634cd9bff686ec2b1581c18afcedc016c48421ea0d2090ea5b

See more details on using hashes here.

File details

Details for the file ezauv-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: ezauv-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for ezauv-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba3d87a60b5e25c4e7a3ddc8212b7765caa5137d9f913acf15877ad2a5b84a0
MD5 1a66ce3f59a687cfeddb0bc38615f9eb
BLAKE2b-256 b61dfb9a520e043624aee5c8159bc573cd3edc1dd53f4fdbfec5cf3e47a86c6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page