-
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.
- Loading branch information
Showing
15 changed files
with
183 additions
and
254 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
49 changes: 49 additions & 0 deletions
49
mission/internal_status/internal_status/power_sense_module_publisher.py
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,49 @@ | ||
import internal_status.power_sense_module_lib | ||
import rclpy | ||
from rclpy.node import Node | ||
from std_msgs.msg import Float32 | ||
|
||
|
||
class MinimalPublisher(Node): | ||
|
||
|
||
def __init__(self): | ||
super().__init__('PSM_publisher') | ||
self.PSM = internal_status.power_sense_module_lib.PowerSenseModule() | ||
self.publisher_current = self.create_publisher(Float32, '/asv/power_sense_module/current', 1) | ||
self.publisher_voltage = self.create_publisher(Float32, '/asv/power_sense_module/voltage', 1) | ||
timer_period = 0.5 | ||
self.timer = self.create_timer(timer_period, self.timer_callback) | ||
self.i = 0 | ||
|
||
def timer_callback(self): | ||
current = Float32() | ||
voltage = Float32() | ||
#call the two functions of the power_sense_module_lib to get the current and voltage values of the PSM | ||
current.data = self.PSM.get_current() | ||
voltage.data = self.PSM.get_voltage() | ||
self.publisher_current.publish(current) #publish current value to the "current topic" | ||
self.get_logger().info('Publishing PSM current: "%s"' % current.data) | ||
self.publisher_voltage.publish(voltage) #publish voltage value to the "voltge topic" | ||
self.get_logger().info('Publishing PSM voltage: "%s"' % voltage.data) | ||
self.i += 1 | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
minimal_publisher = MinimalPublisher() | ||
|
||
rclpy.spin(minimal_publisher) | ||
|
||
# Destroy the node explicitly | ||
# (optional - otherwise it will be done automatically | ||
# when the garbage collector destroys the node object) | ||
minimal_publisher.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,7 @@ | ||
import power_sense_module_lib | ||
|
||
bm = power_sense_module_lib.BatteryMonitor() | ||
|
||
|
||
print(bm.get_current()) | ||
print(bm.get_voltage()) |
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 |
---|---|---|
|
@@ -3,16 +3,23 @@ | |
<package format="3"> | ||
<name>internal_status</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">rose</maintainer> | ||
<license>TODO: License declaration</license> | ||
<description>Publisher of the PSM voltage and current data</description> | ||
<maintainer email="[email protected]">vortex</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
<exec_depend>rclpy</exec_depend> | ||
<exec_depend>std_msgs</exec_depend> | ||
<exec_depend>power_sense_module_lib</exec_depend> | ||
|
||
|
||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
<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/internal_status | ||
[install] | ||
install_scripts=$base/lib/internal_status |
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 setuptools import find_packages, setup | ||
|
||
package_name = 'internal_status' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=find_packages(exclude=['test']), | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='vortex', | ||
maintainer_email='[email protected]', | ||
description='Publisher of the PSM voltage and current data', | ||
license='Apache License 2.0', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'power_sense_module_publisher = internal_status.power_sense_module_publisher:main', | ||
], | ||
}, | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.