Commit 650b83b8 authored by Marian Begemann's avatar Marian Begemann
Browse files

Adjusted counter example to use given ROS value for counting

parent f1ec9d1d
......@@ -22,18 +22,6 @@
"type": "Events[Int]"
}],
"outputs": [{
"annotations": [{
"args": {
"value": {
"type": "String",
"value": "counter"
}
},
"name": "$name"
}],
"name": "$903",
"type": "Events[Int]"
}, {
"annotations": [{
"args": {
"name": {
......@@ -59,7 +47,7 @@
},
"name": "$name"
}],
"name": "reset$905",
"name": "reset$899",
"type": "Events[Bool]"
}]
}
\ No newline at end of file
......@@ -6,10 +6,13 @@ def @RosPublisher(name: String, ros_type: String, qos_profile: String)
@RosSubscription("/counter", "int64", "10")
in x: Events[Int]
def counter = count(x)
def reset = counter > 10
# Version 2 - if once reset true then forever
# def counter = count(x)
# def reset = counter > 10
# out counter
out counter
# Version 1 - every time reset if counter is bigger then 10
def reset = x > 10
@RosPublisher("/reset_counter", "bool", "10")
out reset
......
......@@ -52,7 +52,9 @@ class CounterWithReset(Node):
"""If event of type bool is true reset counter to zero, else do nothing."""
if msg.data:
self.counter = 0
self.get_logger().debug('Received on reset topic:"{}"'.format(msg.data))
self.get_logger().warn('Counter Node: Reset Counter to zero, after receiving on reset topic:"{}"'.
format(msg.data))
self.get_logger().debug('Counter Node: Received on reset topic:"{}"'.format(msg.data))
def main(args=None):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment