fake_node.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # encoding=utf-8
3 # The MIT License (MIT)
4 #
5 # Copyright (c) 2018 Bluewhale Robot
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included in all
15 # copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 # SOFTWARE.
24 #
25 # Author: Xie fusheng
26 # Randoms
27 
28 
29 """
30 这是一个小强驱动包的假节点。这个节点发布以下几个topic
31 odom
32 status_flag
33 pose2d
34 power
35 位置数据全部为0, 电压数据12V
36 同时发布odom -> baselink 的 静态tf变换
37 """
38 
39 import rospy
40 from geometry_msgs.msg import Pose2D
41 from nav_msgs.msg import Odometry
42 from std_msgs.msg import Float64, Int32
43 
44 if __name__ == "__main__":
45  rospy.init_node("fake_xiaoqiang_driver", anonymous=True)
46  rate = rospy.Rate(50)
47  odom_pub = rospy.Publisher("odom", Odometry, queue_size=0)
48  status_flag_pub = rospy.Publisher("status_flag", Int32,
49  queue_size=0)
50  pose_pub = rospy.Publisher("pose2d", Pose2D, queue_size=0)
51  power_pub = rospy.Publisher("power", Float64, queue_size=0)
52  while not rospy.is_shutdown():
53  now = rospy.Time.now()
54  odom = Odometry()
55  odom.header.stamp = now
56  odom.header.frame_id = "odom"
57  odom.child_frame_id = "base_footprint"
58  odom.pose.pose.orientation.x = 0
59  odom.pose.pose.orientation.y = 0
60  odom.pose.pose.orientation.z = 0
61  odom.pose.pose.orientation.w = 1
62  odom_pub.publish(odom)
63  status = Int32()
64  status.data = 1
65  status_flag_pub.publish(status)
66  mPose = Pose2D()
67  pose_pub.publish(mPose)
68  power = Float64()
69  power.data = 12.0
70  power_pub.publish(power)
71  rate.sleep()


xiaoqiang_driver
Author(s): Xie fusheng
autogenerated on Mon Jun 10 2019 15:53:12