-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into horizontal-pilot-gui
- Loading branch information
Showing
19 changed files
with
341 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Flood Detection | ||
|
||
## Overview | ||
|
||
This package reads from the temperature sensor. | ||
|
||
## Installation | ||
|
||
|
||
## Usage | ||
|
||
```bash | ||
ros2 launch temp_sensor temp_sensor_launch.py | ||
``` | ||
|
||
## Launch files | ||
|
||
* **temp_sensor_launch.py:** Primary launch file for temp sensor. | ||
|
||
## Nodes | ||
|
||
### temp_sensor | ||
|
||
Reads and publishes temperature. | ||
|
||
#### Published Topics | ||
|
||
* **`/temperature`** ([rov_msgs/temperature]) | ||
|
||
Temperature readings as floats | ||
|
||
|
||
### test | ||
|
||
Tests flooding. | ||
|
||
[rov_msgs/temperature]: ../../rov_msgs/msg/Temperature.msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from launch.launch_description import LaunchDescription | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description() -> LaunchDescription: | ||
""" | ||
Generate LaunchDescription for temp_sensor. | ||
Returns | ||
------- | ||
LaunchDescription | ||
Launches temperature sensor node | ||
""" | ||
temp_sensor = Node( | ||
package='temp_sensor', | ||
executable='temp_sensor', | ||
emulate_tty=True, | ||
output='screen', | ||
remappings=[('/pi/temperature', '/tether/temperature')] | ||
) | ||
|
||
return LaunchDescription([ | ||
temp_sensor | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>temp_sensor</name> | ||
<version>0.0.3</version> | ||
<description>Measures temperature</description> | ||
<maintainer email="[email protected]">Benjamin Poulin</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<exec_depend>ros2launch</exec_depend> | ||
<exec_depend>python3-smbus</exec_depend> | ||
|
||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>ament_mypy</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/temp_sensor | ||
[install] | ||
install_scripts=$base/lib/temp_sensor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from setuptools import setup | ||
from glob import glob | ||
import os | ||
|
||
package_name = 'temp_sensor' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.3', | ||
packages=[package_name], | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
# Include all launch files. | ||
(os.path.join('share', package_name, 'launch'), | ||
glob('launch/*launch.[pxy][yma]*')) | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='Benjamin Poulin', | ||
maintainer_email='[email protected]', | ||
description='Temperature sensor', | ||
license='Apache License 2.0', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'temp_sensor = temp_sensor.temp_sensor:main', | ||
'dry_run = temp_sensor.temp_sensor_dry_run:main' | ||
], | ||
}, | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from rclpy.qos import QoSPresetProfiles | ||
import tsys01 | ||
|
||
from rov_msgs.msg import Temperature | ||
|
||
READING_TIMER_PERIOD = 0.5 # Seconds | ||
|
||
|
||
class TempSensor(Node): | ||
|
||
def __init__(self) -> None: | ||
super().__init__('temp_sensor', parameter_overrides=[]) | ||
self.publisher = self.create_publisher(Temperature, 'temperature', | ||
QoSPresetProfiles.DEFAULT.value) | ||
self.sensor = tsys01.TSYS01() | ||
self.sensor.init() | ||
|
||
self.timer = self.create_timer(READING_TIMER_PERIOD, self.timer_callback) | ||
|
||
def timer_callback(self) -> None: | ||
try: | ||
self.sensor.read() | ||
temp_reading = self.sensor.temperature() | ||
|
||
# If any of the sensors detect water, send true to /tether/flooding | ||
self.publisher.publish(Temperature(reading=temp_reading)) | ||
except OSError: | ||
print('Failed to read temperature, skipping this read') | ||
|
||
|
||
def main(args: None = None) -> None: | ||
rclpy.init() | ||
temp_sensor = TempSensor() | ||
rclpy.spin(temp_sensor) | ||
temp_sensor.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from time import sleep | ||
|
||
import tsys01 # https://github.com/bluerobotics/tsys01-python | ||
|
||
|
||
def main() -> None: | ||
sensor = tsys01.TSYS01() # Use default I2C bus 1 | ||
|
||
sensor.init() | ||
|
||
while True: | ||
try: | ||
sensor.read() # Sometimes throws OSError: [Errno 121] Remote I/O error | ||
print( | ||
sensor.temperature(), # Get temperature in default units (Centigrade) | ||
'\t', | ||
sensor.temperature(tsys01.UNITS_Farenheit) | ||
) | ||
except OSError: | ||
print('Failed to read temperature, trying again') | ||
|
||
sleep(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2017 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_flake8.main import main_with_errors | ||
import pytest | ||
|
||
|
||
@pytest.mark.flake8 | ||
@pytest.mark.linter | ||
def test_flake8() -> None: | ||
rc, errors = main_with_errors(argv=[]) | ||
assert rc == 0, \ | ||
'Found %d code style errors / warnings:\n' % len(errors) + \ | ||
'\n'.join(errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Test mypy on this module.""" | ||
|
||
import os | ||
import pytest | ||
from ament_mypy.main import main | ||
|
||
|
||
@pytest.mark.mypy | ||
@pytest.mark.linter | ||
def test_mypy() -> None: | ||
"""Tests mypy on this module.""" | ||
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml") | ||
error_code = main(argv=["--config", path]) | ||
assert error_code == 0, 'Found code style errors / warnings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_pep257.main import main | ||
import pytest | ||
|
||
|
||
@pytest.mark.linter | ||
@pytest.mark.pep257 | ||
def test_pep257() -> None: | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found code style errors / warnings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
float64 reading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.