-
Notifications
You must be signed in to change notification settings - Fork 0
How to: Use the API
Unlike with our previous sub Gilligan, Poseidon organizes the software so that the high-level control code doesn't have to worry about low-level subtleties. Developers in Ruby don't have to worry about drivers, motor controls, or whether the communication protocols are initialized. It's all abstracted away. Therefore, Ruby developers have straightforward and easy methods at their disposal. These are:
These methods are generally bug-free and should work as expected.
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
thrust = ThrustController.new | None | Constructor, creates ThrustController object, initializes the PWM drivers that control the motors. | Attempts to create two ThrustControllers results in an error. |
thrust.setForwardThrust | Float in [-1, 1] range | Sets the large forward thrusts to the given power. | Be aware that full power is very fast. |
thrust.setStrafeThrust | Float in [-1, 1] range | Sets the left/right thrusters to the given power. | Positive value will drift to the right. |
thrust.setDiveThrust | Float in [-1, 1] range | Sets the vertical thrusters to the given power. | Positive value will submerge the sub. |
thrust.setYawThrust | Float in [-1, 1] range | Powers the left/right thrusters in opposite directions to turn the sub on its plane. | Positive argument is clockwise. |
thrust.accelerateForward | Float in [-1, 1] range, integer in [1, ∞] range | Linearly accelerates the forward thrusters from 0 to the given thrust, in the given amount of seconds. | Second argument is optional, defaults to 2. |
thrust.accelerateStrafe | Float in [-1, 1] range, integer in [1, ∞] range | Linearly accelerates the left/right thrusters from 0 to the given thrust, in the given amount of seconds. | Second argument is optional, defaults to 2. |
thrust.accelerateDive | Float in [-1, 1] range, integer in [1, ∞] range | Linearly accelerates the vertical thrusters from 0 to the given thrust, in the given amount of seconds. | Second argument is optional, defaults to 2. |
thrust.accelerateYaw | Float in [-1, 1] range, integer in [1, ∞] range | Linearly accelerates yaw rotation, in the given amount of seconds. | Second argument is optional, defaults to 2. |
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
power = PowerController.new | None | Constructor, creates instance. | This is a singleton. |
power.turnOnESCs() | None | Enables ESCs, allowing the motor to work | ThrustController methods called before this will have no effect. |
power.turnOffESCs() | None | Disables ESCs, killing the motors | ThrustController methods called after this will have no effect. |
These methods are new and are under development. Use with caution.
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
dashboard = Sensors.new | None | Constructor, creates IMUSensor object, initializes the IMU chip components. | Attempts to create two Sensors results in an error. |
dashboard.temperatureA() | None | Returns interior air temperature. | |
dashboard.temperatureB() | None | Returns an integer representing temperature inside the sub. | |
dashboard.pressure() | None | Returns the pressure inside the sub. | |
dashboard.sealevel | altitudeMeters | Returns an estimation of water pressure. | |
dashboard.altitude | sealevelPressure | Returns a depth estimation. | sealevelPressure argument is optional. |
dashboard.compassX() | None | Returns compass X value. | |
dashboard.compassY() | None | Returns compass Y value. | |
dashboard.compassZ() | None | Returns compass Z value. | |
dashboard.accelX() | None | Returns acceleration X value. | |
dashboard.accelY() | None | Returns acceleration Y value. | |
dashboard.accelZ() | None | Returns acceleration Z value. | |
dashboard.gyroX() | None | Returns gyroscope X value. | |
dashboard.gyroY() | None | Returns gyroscope Y value. | |
dashboard.gyroZ() | None | Returns gyroscope Z value. | |
dashboard.pingerDirection() | None | Returns a theta value where theta=0 represents 'forward'. | |
dashboard.pingerMagnitude() | None | Returns a decimal value representing the proximity of the pinger. |
These methods are planned but are not in the API yet.
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
thrust.cutForwardEngines() | None | Stops the forward thrusters. | Equivalent to calling setForwardThrust(0) |
thrust.cutDiveEngines() | None | Stops the up/down thrusters | Equivalent to calling setDiveThrust(0) |
thrust.cutPanEngines() | None | Stops the left/right thrusters | Equivalent to calling setPanThrust(0) |
These class and some of these methods have not yet been implemented because we lack multiple sensors to integrate, specifically the DVL and the hydrophones. Others are waiting for the IMU drivers to be finalized.
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
sensors = Instruments.new | None | Creates an Instruments object, initializes all sensors | Instruments is also a singleton |
sensors.getTemperature() | None | Returns the air temperature inside the sub. | |
sensors.getPressure() | None | Returns the air pressure inside the sub. | |
sensors.getDepth() | None | Returns an estimation of depth. | |
sensors.getSealevel() | None | Returns the pressure at sea level. | |
sensors.getForwardAccel() | None | Return the acceleration in the forward direction. | |
sensors.getPanAccel() | None | Returns the left/right acceleration. | |
sensors.getDiveAccel() | None | Returns the up/down acceleration. | |
sensors.getForwardGyro() | None | Returns the forward gyroscope reading. | |
sensors.getPanGyro() | None | Returns the left/right gyroscope reading. | |
sensors.getDiveGyro() | None | Returns the vertical gyroscope reading. | |
sensors.getCompassForward() | None | Returns the forward component of the compass reading. | |
sensors.getCompassPan() | None | Returns the left/right component of the compass reading. | |
sensors.getCompassDive() | None | Returns the vertical component of the compass reading. | |
sensors.getPingDirection() | None | Uses the hydrophones to triangulate the direction of the pinger. | |
sensors.getPingMagnitude() | None | Returns the average loudness of the pinger. |
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
power.enableHeadlights() | None | Turns on the sub's forward lights | |
power.disableHeadlights() | None | Turns off the sub's forward lights | |
power.batteryPercent() | None | Returns the percentage of battery remaining. | |
power.reboot() | None | Reboots the entire sub's systems. | |
power.setLightTheme | Integer indicating the theme to use | Changes the LED pattern in the top hull. |
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
vision = Vision.new | None | Creates Vision object, initializes the cameras | Vision is a singleton. |
vision.getBallPosition | Three integers indicating the RGB color of the target ball. | Returns the position of the ball relative to the sub. | |
vision.getGatePosition() | None | Returns the position of the gate relative to the sub. | |
vision.getTrackPosition | Three integers indicating the RGB color of the track. | Returns the position of the submerged track relative to the sub. | |
vision.getTrackAngle | Three integers indicating the RGB color of the track. | Returns the angle of the submerged track relative to the sub's orientation. |
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
claw = ClawController.new | None | Creates ClawController object | ClawController is a singleton. |
claw.extendClaw() | None | Extends the claw. | |
claw.retractClaw() | None | Retracts the claw. | |
claw.grab() | None | Grabs with the claw. | |
claw.release() | None | Opens the claw, releasing objects. |
Ruby Code | Arguments | Function | Notes |
---|---|---|---|
armed = WeaponsController.new | None | Creates WeaponsController object | WeaponsController is a singleton. |
armed.fireTorpedo() | None | Fires the torpedo. |