Skip to content

Commit

Permalink
reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
chrehall68 committed Nov 23, 2024
1 parent d7779de commit 881a471
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/compass/compass/compass_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from constants import COMPASS_TOPIC, QOS



class CompassListener(Node):
def __init__(self):
super().__init__("compass_listener")
Expand Down
22 changes: 12 additions & 10 deletions src/compass/compass/quaternion_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@
from constants import COMPASS_TOPIC, QOS
import math


class QuaternionPublisher(Node):
def __init__(self):
super().__init__('quaternion_publisher')
super().__init__("quaternion_publisher")

self.create_subscription(Float64, COMPASS_TOPIC, self.float_callback, 10)
self.publisher_ = self.create_publisher(Quaternion, 'quaternion_topic', 10)

self.publisher_ = self.create_publisher(Quaternion, "quaternion_topic", 10)
self.timer = self.create_timer(1.0, self.timer_callback)

def float_callback(self, msg):
#convert the float to a quaternion
# convert the float to a quaternion
quaternion = self.convert_float_to_quaternion(msg.data)

self.publisher_.publish(quaternion)

self.get_logger().info(f'Publishing Quaternion: "{quaternion}"')

def convert_float_to_quaternion(self, angle):
angle = math.radians(angle)
q = Quaternion()
q.x = 0.0
q.y = 0.0
q.z = math.sin(angle/2.0)
q.w = 1-(q.z*q.z)
q.z = math.sin(angle / 2.0)
q.w = 1 - (q.z * q.z)
return q



def main(args=None):
rclpy.init(args=args)
try:
rclpy.spin(QuaternionPublisher())
except KeyboardInterrupt:
print("Shutting down")
print("Shutting down")
1 change: 0 additions & 1 deletion src/compass/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"console_scripts": [
"compass = compass.main:main",
"compass_listener = compass.compass_listener:main",

"quaternion_publisher = compass.quaternion_publisher:main",
],
},
Expand Down
8 changes: 6 additions & 2 deletions src/urc_intelsys_2024/launch/sensor_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def generate_launch_description(): # all launch files need a function with this
# can't use the value in the parameter until we return the launch description.
# thus, the lists, allow us to say "substitute `compass_type` with the actual value at runtime"
compass_node = Node(package="compass", executable="compass", parameters=[config])
quaternion_compass_node = Node(package="compass", executable="quaternion_compass", parameters=[config])
quaternion_compass_node = Node(
package="compass", executable="quaternion_compass", parameters=[config]
)
gps_node = Node(package="gps", executable="gps", parameters=[config])

# create launch description for the luxonis depthai ros driver
Expand All @@ -24,4 +26,6 @@ def generate_launch_description(): # all launch files need a function with this
),
)

return LaunchDescription([gps_node, compass_node, quaternion_compass_node, camera_launch])
return LaunchDescription(
[gps_node, compass_node, quaternion_compass_node, camera_launch]
)

0 comments on commit 881a471

Please sign in to comment.