BlueRobotics’s Navigator Library
This library serves as the entry point for embedding applications using Python on Blue Robotics’s Navigator.
The Navigator board has the Raspberry Pi HAT form factor, which allows you to easily attach it to a Raspberry Pi 4 board. Then you can unleash the power of Navigator to develop new solutions or interact with your ROV hardware.
The board offers the following capabilities:
Control:
LEDs
PWM (Pulse Width Modulation) with 16 channels
Measurements:
ADC (Analog Digital Converter) entries
Magnetic field
Acceleration
Angular velocity
Temperature
Pressure
Currently, it supports armv7 and aarch64 architectures, which are the official defaults for BlueOS. However, despite using the embedded-hal concept, new ports can be added as long as the platform matches the hardware design and specifications.
For more information, including installation instructions, schematics, and hardware specifications, please check the navigator hardware setup guide.
- navigator.get_led(select)
Gets the selected navigator LED output state.
- Parameters:
select (
UserLed
) – A pin to be selected.- Returns:
The true state means the LED is on.
- Return type:
bool
Examples
>>> import navigator >>> from navigator import UserLed >>> navigator.get_led(UserLed.Led1)
- navigator.init()
Initialize the navigator module with default settings.
Examples
>>> import navigator >>> navigator.init()
- navigator.pwm_enable(state)
Sets the PWM IC to be enabled through firmware and OE_pin.
- Parameters:
state (bool) – The state of PWM output, it’s enabled with a true logic value.
Examples
Please check
set_pwm_channel_value()
>>> navigator.pwm_enable(True)
- navigator.read_accel()
Reads acceleration based on ICM20689 of Navigator.
- Returns:
Measurements in [m/s²]
- Return type:
AxisData
Examples
>>> import navigator >>> AxisData = navigator.read_accel().x >>> AxisData.x >>> AxisData.y >>> AxisData.z
- navigator.read_adc(channel)
Reads the ADC based on ADS1115 of Navigator.
- Parameters:
select (
AdcChannel
) – A pin to be selected.- Returns:
Measurements in [V].
- Return type:
float32
Examples
>>> import navigator >>> from navigator import AdcChannel >>> navigator.read_adc(AdcChannel.Ch1)
- navigator.read_adc_all()
Reads the ADC based on ADS1115 of Navigator.
Same as
read_adc()
, but it returns an array with all channel readings- Returns:
Measurements in [V].
- Return type:
ADCData
Examples
>>> import navigator >>> navigator.read_adc_all().channel
- navigator.read_gyro()
Reads angular velocity based on ICM20689 of Navigator.
- Returns:
Measurements in [rad/s]
- Return type:
AxisData
Examples
>>> import navigator >>> AxisData = navigator.read_gyro().x >>> AxisData.x >>> AxisData.y >>> AxisData.z
- navigator.read_mag()
Reads the magnetometer Ak09915 of Navigator.
- Returns:
Measurements in [µT]
- Return type:
AxisData
Examples
>>> import navigator >>> AxisData = navigator.read_mag() >>> AxisData.x >>> AxisData.y >>> AxisData.z
- navigator.read_pressure()
Reads the pressure based on BMP280 of Navigator.
- Returns:
Measurements in [kPa]
- Return type:
float32
Examples
>>> import navigator >>> navigator.read_pressure()
- navigator.read_temp()
Reads the temperature using BMP280 of Navigator.
- Returns:
Measurements in [˚C]
- Return type:
float32
Examples
>>> import navigator >>> navigator.read_temperature()
- navigator.self_test()
Runs some tests on available sensors, then returns the result.
- Returns:
The true state means the sensors are OK.
- Return type:
bool
Examples
>>> import navigator >>> navigator.self_test()
- navigator.set_led(select, state)
Sets the selected navigator LED output.
- Parameters:
select (
UserLed
) – A pin to be selected.state (bool) – The value of output, LED is on with a true logic value.
Examples
>>> import navigator >>> from navigator import UserLed >>> navigator.set_led(UserLed.Led1, True)
- navigator.set_led_all(state)
Set all LEDs on desired state ( Blue, Green and Red ).
- Parameters:
state (bool) – The value of output, LED is on with a true logic value.
Examples
>>> import navigator >>> from navigator import UserLed >>> navigator.set_led_all(True)
- navigator.set_led_toggle(select)
Toggle the output of selected LED.
- Parameters:
select (
UserLed
) – A pin to be selected.
Examples
>>> import navigator >>> from navigator import UserLed >>> navigator.set_led_toggle(UserLed.Led1)
- navigator.set_neopixel(rgb_array)
Set the values of the neopixel LED array.
- Parameters:
state ([[uint8, uint8, uint8]]) – A 2D array containing RGB values for each LED. Each inner value representing the Red, Green and Blue from a LED.
Examples
>>> import navigator >>> navigator.set_neopixel([[100,0,0]])
- navigator.set_pwm_channel_value(channel, value)
Sets the Duty Cycle (high value time) of selected channel.
On PCA9685, this function sets the OFF counter and uses ON value as 0.
- Parameters:
channel (
PwmChannel
) – The channel to be selected for PWM.value (u16) – Duty cycle value.
Examples
>>> import navigator >>> from navigator import PwmChannel >>> navigator.init() >>> navigator.set_pwm_freq_hz(1000) >>> navigator.set_pwm_channel_value(PwmChannel.Ch1, 2000) >>> navigator.pwm_enable(True)
- navigator.set_pwm_channels_value(channels, value)
Like
set_pwm_channel_value()
. This function sets the Duty Cycle for a list of multiple channels.- Parameters:
channels ([
PwmChannel
]) – An array of channels to be selected for PWM.value (u16) – The duty cycle value.
Examples
You can use this method like
set_pwm_channel_value()
.>>> navigator.set_pwm_channels_value([PwmChannel.Ch1, PwmChannel.Ch16], 1000)
- navigator.set_pwm_channels_values(channels, values)
Like
set_pwm_channel_value()
. This function sets the Duty Cycle for a list of multiple channels with multiple values.- Parameters:
channels ([
PwmChannel
]) – An array of channels to be selected for PWM.values ([u16]) – An array Duty cycle value.
Examples
You can use this method like
set_pwm_channel_value()
.>>> navigator.set_pwm_channels_values([PwmChannel.Ch1, PwmChannel.Ch5], [1000, 500])
- navigator.set_pwm_freq_hz(freq)
Sets the pwm frequency in Hertz of Navigator. Similar to
set_pwm_freq_prescale()
.Notes
The navigator module uses a crystal with a 24.5760 MHz clock.
- Parameters:
freq (float32) – The prescaler value (24..1526)[Hz].
Examples
>>> import navigator >>> navigator.set_pwm_freq_hz(60) >>> navigator.set_pwm_channel_value(PwmChannel.Ch1, 2000) >>> navigator.pwm_enable(True)
- navigator.set_pwm_freq_prescale(value)
Sets the PWM frequency of Navigator.
It changes the PRE_SCALE value on PCA9685.
The prescaler value can be calculated for an update rate using the formula:
prescale_value = round(clock_freq / (4096 * desired_freq)) - 1.
If you want to control a servo, set a prescaler value of 100. This will correspond to a frequency of about 60 Hz, which is the frequency at which servos work.
Notes
Re-run the set_pwm_channel_value() is required.
The minimum prescaler value is 3, which corresponds to 1526 Hz. The maximum prescaler value is 255, which corresponds to 24 Hz.
Internally, this function stops the oscillator and restarts it after setting the prescaler value if it was running.
- Parameters:
value (uint8) – The prescaler value (3..255).
Examples
>>> import navigator >>> navigator.set_pwm_freq_prescale(100) >>> navigator.set_pwm_channel_value(PwmChannel.Ch1, 2000) >>> navigator.pwm_enable(True)