Skip to content

Commit

Permalink
visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrLucas committed Apr 26, 2023
1 parent edcd735 commit 97044c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions com3528_examples/nodes/subscriber_cliff.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ def __init__(self):
self.lcliff = None
self.rcliff = None
topic_base_name = "/" + os.getenv("MIRO_ROBOT_NAME")
self.subscriber = rospy.Subscriber(topic_base_name + "/sensors/cliff", Float32MultiArray, self.callback)
self.subscriber = rospy.Subscriber(topic_base_name + "/sensors/cliff",
Float32MultiArray, self.callback)

# callback function used to update the object instances for this class
def callback(self, data):
self.lcliff = data.data[0]
self.rcliff = data.data[1]
self.left = data.data[0]
self.right = data.data[1]

if __name__ == '__main__':
cliff = CliffSubscriber()
Expand All @@ -27,6 +28,6 @@ def callback(self, data):
# Print the cliff sensors data
# Data ranges from 0 (cliff) to 1 (surface)
# Note that the sensor resolution is 1/15
toPrint = 'Left Cliff: {}; Right Cliff: {}'.format(cliff.lcliff, cliff.rcliff)
toPrint = 'Left Cliff: {}; Right Cliff: {}'.format(cliff.left, cliff.right)
print(toPrint)
rospy.sleep(0.5) # to slow down the printing

0 comments on commit 97044c4

Please sign in to comment.