我有个问题,也许有人能帮我。 我想用ROS2做一个应用程序。我为publisher和subscriber编写了本教程https://index.ros.org/doc/ros2/Tutorials/Writing-A-Simple-Py-Publisher-And-Subscriber/ 我将Kivy用于GUI,并且必须将其导入Python文件。如果导入kivy,则会出现错误“ModuleNotFoundError:没有名为“kivy”的模块” 为什么ROS2不接受Kivy进口?有人能帮我吗?我找不到解决办法
这是我的Python文件:
from rclpy.node import Node
from std_msgs.msg import String
import kivy
class MinimalSubscriber(Node):
def __init__(self):
# TestApp().run
super().__init__('minimal_subscriber')
self.subscription = self.create_subscription(
String,
'topic',
self.listener_callback,
10)
self.subscription # prevent unused variable warning
def listener_callback(self, msg):
self.get_logger().info('I heard: "%s"' % msg.data)
def main(args=None):
# TestApp().run
rclpy.init(args=args)
print("HELLO")
minimal_subscriber = MinimalSubscriber()
rclpy.spin(minimal_subscriber)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_subscriber.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
这就是我的package.xml:
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>py_pubsub</name>
<version>0.0.0</version>
<description>Examples of minimal publisher/subscriber using rclpy</description>
<maintainer email="darius.schlese@yahoo.de">Darius</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_python</buildtool_depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<build_depend>kivy</build_depend>
<exec_depend>kivy</exec_depend>
<export>
<build_type>ament_python</build_type>
<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
</export>
</package>
谢谢你的帮助!:)
目前没有回答
相关问题 更多 >
编程相关推荐