SMACC2
smacc2_performance_tools
performance_tests
sm_atomic_subscribers_performance_test
servers
basic_publisher.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
# Copyright 2021 RobosoftAI Inc.
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
17
import
rclpy
18
from
rclpy.node
import
Node
19
from
std_msgs.msg
import
Int16
20
import
random
21
22
23
class
TemperatureSensorNode
(Node):
24
def
__init__
(self):
25
super().
__init__
(
"temperature_sensor"
)
26
self.
temperature_publisher_
= self.create_publisher(Int16,
"temperature"
, 10)
27
self.
temperature_timer_
= self.create_timer(0.05, self.
publish_temperature
)
28
29
def
publish_temperature
(self):
30
temperature = random.randint(20, 30)
31
msg = Int16()
32
msg.data = temperature
33
self.
temperature_publisher_
.publish(msg)
34
35
36
def
main
(args=None):
37
rclpy.init(args=args)
38
node =
TemperatureSensorNode
()
39
rclpy.spin(node)
40
rclpy.shutdown()
41
42
43
if
__name__ ==
"__main__"
:
44
main
()
basic_publisher.TemperatureSensorNode
Definition:
basic_publisher.py:23
basic_publisher.TemperatureSensorNode.temperature_publisher_
temperature_publisher_
Definition:
basic_publisher.py:26
basic_publisher.TemperatureSensorNode.__init__
def __init__(self)
Definition:
basic_publisher.py:24
basic_publisher.TemperatureSensorNode.publish_temperature
def publish_temperature(self)
Definition:
basic_publisher.py:29
basic_publisher.TemperatureSensorNode.temperature_timer_
temperature_timer_
Definition:
basic_publisher.py:27
basic_publisher.main
def main(args=None)
Definition:
basic_publisher.py:36
Generated by
1.9.4