demo.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2020 Pilz GmbH & Co. KG
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Lesser General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import random
18 
19 import rospy
20 from numpy import arange
21 from prbt_hardware_support.msg import OperationModes
22 from std_msgs.msg import Bool, Float64
23 
24 from pilz_status_indicator_rqt.status_indicator import (TOPIC_STATE_HW,
25  TOPIC_STATE_ROS,
26  TOPIC_OPERATION_MODE,
27  TOPIC_SPEED_OVERRIDE)
28 
29 if __name__ == "__main__":
30  pubs = [
31  rospy.Publisher(TOPIC_STATE_HW, Bool, queue_size=1),
32  rospy.Publisher(TOPIC_STATE_ROS, Bool, queue_size=1),
33  rospy.Publisher(TOPIC_OPERATION_MODE, OperationModes, queue_size=1),
34  rospy.Publisher(TOPIC_SPEED_OVERRIDE, Float64, queue_size=1)
35  ]
36  states = [
37  [True, False],
38  [True, False],
39  [
40  OperationModes.AUTO,
41  OperationModes.T1,
42  OperationModes.T2
43  ],
44  list(arange(0, 1, .07))
45  ]
46  constructors = [
47  lambda x: Bool(x),
48  lambda x: Bool(x),
49  lambda x: OperationModes(time_stamp=None, value=x),
50  lambda x: Float64(x)
51  ]
52 
53  rospy.init_node("status_indicator_demo")
54  rate = rospy.Rate(3)
55  while not rospy.is_shutdown():
56  to_change = random.randint(0, len(states)-1)
57  pubs[to_change].publish(
58  constructors[to_change](random.choice(states[to_change]))
59  )
60  rate.sleep()


pilz_status_indicator_rqt
Author(s):
autogenerated on Tue Feb 2 2021 03:50:27