-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
ipc-robot@ipcrobot-Precision-Tower-3420:~/ros2_ws$ ros2 run example_service_rclpy service_client_02
[INFO] [1722589543.093786297] [service_client_02]: 节点已启动:service_client_02!
Traceback (most recent call last):
File "/home/ipc-robot/ros2_ws/install/example_service_rclpy/lib/example_service_rclpy/service_client_02", line 33, in <module>
sys.exit(load_entry_point('example-service-rclpy==0.0.0', 'console_scripts', 'service_client_02')())
File "/home/ipc-robot/ros2_ws/install/example_service_rclpy/lib/python3.10/site-packages/example_service_rclpy/service_client_02.py", line 14, in main
node.send_request(3,4)
AttributeError: 'ServiceClient02' object has no attribute 'send_request'
[ros2run]: Process exited with failure 1
以下是client_02的代码:
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from example_interfaces.srv import AddTwoInts
class ServiceClient02(Node):
def __init__(self,name):
super().__init__(name)
self.get_logger().info("节点已启动:%s!" % name)
def main(args=None):
rclpy.init(args=args) # 初始化rclpy
node = ServiceClient02("service_client_02") # 新建一个节点
node.send_request(3,4)
rclpy.spin(node) # 保持节点运行,检测是否收到退出指令(Ctrl+C)
rclpy.shutdown() # 关闭rclpy
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels