Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

469 task rewrite thruster interface #492

Merged
merged 57 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f317a45
extracts 3rd approx polynomials from csv data, saved in coeffs.txt
albertomors Sep 27, 2024
a939cec
rewrited interface in python - we'll move to cpp now
albertomors Oct 6, 2024
37d50c6
small change
albertomors Oct 6, 2024
5b270e1
Develop
kluge7 Oct 11, 2024
d8c5562
updated files with almost all pre-commit fixed
albertomors Oct 11, 2024
1d4dcda
not working but anders want me to push before leaving the lab
albertomors Oct 20, 2024
f2e98d4
refactor: make code build
Andeshog Oct 20, 2024
f753f5f
fixed some gpt-shit and numerically comparing it to python works prop…
albertomors Oct 22, 2024
e0446c6
fixed constructor and offset pwm
albertomors Oct 22, 2024
eba1387
removed debugging prints
albertomors Oct 23, 2024
070913c
refactor(workflows): removed old ci workflows and added updated ci wo…
kluge7 Oct 25, 2024
0a33453
refactor(config): updated pre commit hooks and removed unused config …
kluge7 Oct 25, 2024
0b4e696
refactor(formatting): applied formatting changes
kluge7 Oct 25, 2024
c2ce10f
refactor(docs): applied formatting changes to docstrings
kluge7 Oct 25, 2024
52bca93
refactor(docs): applied formatting changes to docstrings
kluge7 Oct 25, 2024
de3433f
refactor(formatting): applied formatting and style changes
kluge7 Oct 25, 2024
05b6eac
refactor(pre-commit): replaced all python hooks with ruff
kluge7 Oct 25, 2024
ec43ebd
refactor(workflow): updated source build to not run on push
kluge7 Oct 25, 2024
b3a4993
Merge branch 'develop' into 469-task-rewrite-thruster-interface
kluge7 Oct 25, 2024
bbd67f3
refactor(submodules): removed submodules
kluge7 Oct 25, 2024
4fdeccb
started the odissey in fixing things
albertomors Oct 27, 2024
609edf0
try to pass the test
albertomors Oct 27, 2024
2b5e252
refactor(clang-format): updated config file to use ibium
kluge7 Oct 27, 2024
4ad2385
refactor(motion): applied updated clang format
kluge7 Oct 27, 2024
ba09998
fixed more
albertomors Oct 27, 2024
0c853df
feat(ruff): added config file and set pydocstyle convention and quote…
kluge7 Oct 28, 2024
adc08a0
refactor(pre-commit): updated linting rules
kluge7 Oct 28, 2024
5bdb138
refactor(motion): applied formatting changes to docstring
kluge7 Oct 28, 2024
7308627
refactor(mission): applied formatting changes to docstring
kluge7 Oct 28, 2024
be7f07f
refactor(acoustics): applied formatting changes to docstring
kluge7 Oct 28, 2024
f54e024
refactor(auv_setup): applied formatting changes to docstring
kluge7 Oct 28, 2024
f567689
fixed fixed
albertomors Nov 1, 2024
711bf9d
sub and publisher passed from .yaml
albertomors Nov 3, 2024
89204fa
lowercased member variables
albertomors Nov 3, 2024
b21588a
fixed contructor with make_unique
albertomors Nov 3, 2024
f0ce55b
try except
albertomors Nov 3, 2024
daec7c1
added exceptions
albertomors Nov 3, 2024
bef931d
args passed by struct
albertomors Nov 8, 2024
5a3dae1
separate init function that extracts yaml
albertomors Nov 8, 2024
8981c0f
cleaned a bitttt
albertomors Nov 8, 2024
926bebc
merge develop
kluge7 Nov 8, 2024
02d5e30
changed structure
albertomors Nov 8, 2024
160212c
removed prints
albertomors Nov 8, 2024
19e4377
refactor(thruster_interface_auv): removed outdated python implementation
kluge7 Nov 9, 2024
e9aacb3
document
albertomors Nov 10, 2024
4b4113d
debug flag for publisher
albertomors Nov 10, 2024
2a6262a
added param event callback for debug flag
jorgenfj Nov 10, 2024
2bce3de
precommitfix
albertomors Nov 10, 2024
a826463
param-handler
albertomors Nov 10, 2024
a5b1d56
kill debug pub when flag turned off
jorgenfj Nov 10, 2024
6a1a7ed
not working
albertomors Nov 10, 2024
fdd6d69
fixed paramhandler
albertomors Nov 10, 2024
28a6755
cleaned up a bit
albertomors Nov 15, 2024
10d54c7
minor changes
albertomors Nov 17, 2024
03efc1d
a
albertomors Nov 17, 2024
f34357d
fckg starting byte
albertomors Nov 17, 2024
4a7cd2b
xmas push
albertomors Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ repos:
"--select=D",
"--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D401",
"--fix",
"--unsafe-fixes"
]
stages: [pre-commit]
pass_filenames: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ def log_data_to_csv_file(
tdoa: list[float] = [0.0],
position: list[float] = [0.0],
) -> None:
"""Logs the provided data to a CSV file.

Parameters:
self (object): The instance of the class.
hydrophone1 (list, optional): Data from hydrophone 1. Defaults to [0].
hydrophone2 (list, optional): Data from hydrophone 2. Defaults to [0].
hydrophone3 (list, optional): Data from hydrophone 3. Defaults to [0].
hydrophone4 (list, optional): Data from hydrophone 4. Defaults to [0].
hydrophone5 (list, optional): Data from hydrophone 5. Defaults to [0].
filter_response (list, optional): Filter response data. Defaults to [0].
fft (list, optional): FFT data. Defaults to [0].
peaks (list, optional): Peaks data. Defaults to [0].
tdoa (list, optional): Time Difference of Arrival data. Defaults to [0.0].
position (list, optional): Position data. Defaults to [0.0].

Writes the current time and provided data to a CSV file located at self.data_file_location.
"""
# Get current time in hours, minutes, seconds and milliseconds
current_time = datetime.now().strftime("%H:%M:%S.%f")[:-3]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def hydrophone1_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing hydrophone1 data.

"""
self.hydrophone1_data = msg.data

Expand All @@ -145,6 +146,7 @@ def hydrophone2_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing hydrophone2 data.

"""
self.hydrophone2_data = msg.data

Expand All @@ -153,6 +155,7 @@ def hydrophone3_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing hydrophone3 data.

"""
self.hydrophone3_data = msg.data

Expand All @@ -161,6 +164,7 @@ def hydrophone4_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing hydrophone4 data.

"""
self.hydrophone4_data = msg.data

Expand All @@ -169,6 +173,7 @@ def hydrophone5_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing hydrophone5 data.

"""
self.hydrophone5_data = msg.data

Expand All @@ -177,6 +182,7 @@ def filter_response_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing filter response data.

"""
self.filter_response_data = msg.data

Expand All @@ -185,6 +191,7 @@ def fft_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing FFT data.

"""
self.fft_data = msg.data

Expand All @@ -193,6 +200,7 @@ def peaks_callback(self, msg: Int32MultiArray) -> None:

Args:
msg (Int32MultiArray): Message containing peaks data.

"""
self.peaks_data = msg.data

Expand All @@ -201,6 +209,7 @@ def tdoa_callback(self, msg: Float32MultiArray) -> None:

Args:
msg (Float32MultiArray): Message containing TDOA data.

"""
self.tdoa_data = msg.data

Expand All @@ -209,6 +218,7 @@ def position_callback(self, msg: Float32MultiArray) -> None:

Args:
msg (Float32MultiArray): Message containing position data.

"""
self.position_data = msg.data

Expand Down Expand Up @@ -244,6 +254,7 @@ def main() -> None:

Returns:
None

"""
# Initialize ROS2
rclpy.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def generate_launch_description() -> LaunchDescription:
Returns:
LaunchDescription: A launch description containing the node configuration
for acoustics_data_record.

"""
# Path to the YAML file
yaml_file_path = os.path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,43 +68,25 @@
ACOUSTICS_CSV_FILE_DIR = PACKAGE_DIR + "/acoustics_data"

# List of all the acoustic files
acoustics_csv_files = csv_files = glob.glob(
acoustics_csv_file = csv_files = glob.glob(
ACOUSTICS_CSV_FILE_DIR + "/acoustics_data_" + "*.csv"
)

# Get the latest csv file name for acoustics data
acoustics_csv_file = max(acoustics_csv_files, key=os.path.getctime)
acoustics_csv_file = max(acoustics_csv_file, key=os.path.getctime)


def convert_pandas_object_to_int_array(pandas_object: pd.Series) -> list:
"""Convert a pandas object containing a string representation of an integer array to a list of integers.

Args:
pandas_object (pandas.Series): A pandas Series object containing a string representation of an integer array.

Returns:
list: A list of integers extracted from the pandas object.
"""
pandas_string = pandas_object.iloc[0].replace("array('i', ", "").replace(")", "")
pandas_string = pandas_object.iloc[0].removeprefix("array('i', ").removesuffix(")")
pandas_int_array = [int(x.strip()) for x in pandas_string.strip("[]").split(",")]

return pandas_int_array


def convert_pandas_object_to_float_array(pandas_object: pd.Series) -> list:
"""Convert a pandas object containing a string representation of a float array to a list of floats.

Args:
pandas_object (pandas.Series): A pandas Series object containing a string representation of a float array.

Returns:
list: A list of floats extracted from the pandas object.
"""
pandas_string = pandas_object.iloc[0].replace("array('f', ", "").replace(")", "")
pandas_string = pandas_object.iloc[0].removeprefix("array('f', ").removesuffix(")")
pandas_float_array = [
float(x.strip()) for x in pandas_string.strip("[]").split(",")
]

return pandas_float_array


Expand Down Expand Up @@ -133,6 +115,7 @@ def get_acoustics_data() -> list:

Raises:
Exception: If there is an error reading the acoustics data or processing the DSP data.

"""
# Variables that will be filled with latest acoustics data ----------
hydrophone1 = [0] * HYDROPHONE_DATA_SIZE
Expand Down Expand Up @@ -265,6 +248,7 @@ def display_live_data() -> None:
Note:
This function assumes that `getAcousticsData`, `hydrophoneAxis`, `filterAxis`, `FFTAxis`,
`colorSoftBlue`, `colorSoftGreen`, and `colorSoftPurple` are defined elsewhere in the code.

"""
# Get latest acoustics data
acoustics_data = get_acoustics_data()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@


class TeensyCommunicationUDP:
"""This class is responsible for the RPI side of teensy-RPI UDP communication.

It is implemented with a singleton pattern for convenience.
"""Class is responsible for the RPI side of teensy-RPI UDP communication.

It isimplemented with a singleton pattern for convenience.
Note: Private members are denoted by _member_name

Attributes:
-----------
----------
_TEENSY_IP (string): self-explanatory
_TEENSY_PORT (int): teensy's data port
_MY_PORT (int): the device's data port
Expand All @@ -25,7 +24,7 @@ class TeensyCommunicationUDP:
acoustics_data (dict[str, list[int]]): container for data from teensy

Methods:
--------
-------
init_communication(frequenciesOfInterest: list[tuple[int, int]]) -> None:
Sets up socket for communication with teensy and waits for handshake
fetch_data() -> None:
Expand Down Expand Up @@ -75,11 +74,6 @@ class TeensyCommunicationUDP:

@classmethod
def init_communication(cls, frequencies_of_interest: list[tuple[int, int]]) -> None:
"""Sets up communication with teensy.

Parameters:
frequenciesOfInterest (list[tuple[int, int]]): List of frequencies to look for
"""
assert (
len(frequencies_of_interest) == 10
), "Frequency list has to have exactly 10 entries"
Expand Down Expand Up @@ -157,6 +151,7 @@ def _get_raw_data(cls) -> str | None:

Returns:
The message in the UDP buffer if there is one

"""
try:
rec_data, _ = cls._client_socket.recvfrom(cls._MAX_PACKAGE_SIZE_RECEIVED)
Expand All @@ -170,14 +165,6 @@ def _get_raw_data(cls) -> str | None:

@classmethod
def _parse_data_string(cls, is_float: bool) -> list[float] | list[int] | None:
"""Converts _data_string to a list.

Parameters:
is_float (bool): whether _data_string should be seen as a list of floats or ints

Returns:
The converted list
"""
if cls._data_string == "":
return

Expand Down Expand Up @@ -254,11 +241,6 @@ def _check_if_available(cls) -> None:
def _send_frequencies_of_interest(
cls, frequencies_of_interest: list[tuple[float, float]]
) -> None:
"""Sends the list of frequencies with variance to teensy.

Parameters:
frequenciesOfInterest (list[tuple[float, float]]): The list of frequencies w/ variance
"""
try:
# Format (CSV): xxx,x,xx,x...,x (frequency list comes first, then variances)
assert (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class AcousticsInterfaceNode(Node):
calls fetch_data() from acoustics_interface
data_publisher(self) -> None:
publishes data to ROS2 topics

"""

def __init__(self) -> None:
Expand Down Expand Up @@ -154,6 +155,7 @@ def main(args: list = None) -> None:

Args:
args (list, optional): Command line arguments passed to the ROS 2 client library. Defaults to None.

"""
rclpy.init(args=args)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def generate_launch_description() -> LaunchDescription:
Returns:
LaunchDescription: A launch description object that includes the
acoustics_interface node with the specified parameters.

"""
# Path to the YAML file
yaml_file_path = os.path.join(
Expand Down
1 change: 1 addition & 0 deletions auv_setup/launch/orca.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def generate_launch_description() -> LaunchDescription:
LaunchDescription: A launch description containing the environment variable
setting and the included launch descriptions for the thruster allocator and
thruster interface.

"""
# Set environment variable
set_env_var = SetEnvironmentVariable(
Expand Down
1 change: 1 addition & 0 deletions auv_setup/launch/topside.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def generate_launch_description() -> LaunchDescription:
Returns:
LaunchDescription: The launch description containing the environment
variable setting, joystick node, and joystick interface launch.

"""
# Set environment variable
set_env_var = SetEnvironmentVariable(
Expand Down
1 change: 1 addition & 0 deletions mission/LCD/sources/ip_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_ip(self) -> str:

Returns:
str: The IP address as a string.

"""
try:
# Run the command without shell=True
Expand Down
1 change: 1 addition & 0 deletions mission/LCD/sources/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def format_line(value: str, unit: str) -> str:

Returns:
str: A formatted string that fits within a 16-character limit, with the unit appended.

"""
spaces_available = 16
value_length = len(value)
Expand Down
2 changes: 2 additions & 0 deletions mission/LCD/sources/lcd_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def write_to_screen(self, line1: str = "", line2: str = "") -> None:
Defaults to an empty string.
line2 (str): The text to display on the second line of the LCD screen.
Defaults to an empty string.

"""
self._lcd.clear()

Expand Down Expand Up @@ -62,6 +63,7 @@ def fancy_animation(self, animation_speed: float = 0.4) -> None:
- Ghost

The animation is displayed in two rows of the LCD screen.

"""
# Calculate the appropriate animation speed
animation_speed = 1 / animation_speed
Expand Down
2 changes: 2 additions & 0 deletions mission/LCD/sources/power_sense_module_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_voltage(self) -> float:

Returns:
float: The system voltage if successfully read and converted, otherwise 0.0.

"""
# Sometimes an I/O timeout or error happens, it will run again when the error disappears
try:
Expand All @@ -66,6 +67,7 @@ def get_current(self) -> float:

Raises:
Exception: If there is an error in reading or converting the current.

"""
try:
system_current = (
Expand Down
1 change: 1 addition & 0 deletions mission/LCD/sources/pressure_sensor_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def get_pressure(self) -> float:

Returns:
float: The current pressure value. Returns 0.0 if an error occurs.

"""
try:
pressure = self.channel_pressure.pressure
Expand Down
9 changes: 5 additions & 4 deletions mission/LCD/sources/temperature_sensor_lib.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python3
"""! NOTE.
"""NOTE: Internal temperature measurement approach.

! For now we don't have a external sensor to measure internal temperature
! Instead we just use Internal Computer temperature sensor to gaugue temperature of the environment approximately
! In the future someone should implement a external temperature sensor for measuting a more accurate state of the temperatuer on the inside of the AUV.
For now, we don't have an external sensor to measure the internal temperature.
Instead, we use the internal computer's temperature sensor to approximate the environmental temperature.
Future improvement: Implement an external temperature sensor for a more accurate measurement of the internal temperature of the AUV.
"""

# Python Libraries
Expand All @@ -23,6 +23,7 @@ def get_temperature(self) -> float:

Raises:
Exception: If there is an error reading the temperature sensor file.

"""
try:
# Read internal temperature on the computer
Expand Down
Loading