Closed wangchong666 closed 3 weeks ago
this work well, very strange
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
from twvs_inf.msg import RadarMessage # CHANGE
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.publisher_ = self.create_publisher(RadarMessage, 'topic', 10)
timer_period = 0.5 # seconds
self.timer = self.create_timer(timer_period, self.timer_callback)
self.i = 0
def timer_callback(self):
msg = RadarMessage()
msg.radar_id = 1
msg.sx = 1.0
msg.sh = 1.0
msg.bx = 1.0
msg.bh = 1.0
msg.warming_distance = 1.0
msg.daoxian_height = 1.0
msg.danger_height = 2.0
print(msg)
self.publisher_.publish(msg)
self.i += 1
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
rclpy.spin(minimal_publisher)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_publisher.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
Finally, there was an extra comma
msg.radar_id = 1,
Bug report
Required Info:
Operating System:
Installation type:
Version or commit hash:
1186d494b6a3
Client library (if applicable):
Steps to reproduce issue
RadarMessage.msg
Node publisher_member_function.py
Expected behavior
Actual behavior
Additional information
---- radar_id became
(1,)
Feature request
Feature description
Implementation considerations