我正在尝试编写一段控制无人机的Python代码。我通过rostopic从刚体接收位置信息,并希望在我的代码中使用这些数据。我该如何在Python代码中访问这些数据?
#!/usr/bin/env python
import numpy as np
from pycrazyswarm import *
Z = 1.0
if __name__ == "__main__":
swarm = Crazyswarm()
# get initial position for maneuver
swarm.allcfs.takeoff(targetHeight=Z, duration=1.0+Z)
swarm.timeHelper.sleep(1.5+Z)
print("press button to continue...")
swarm.input.waitUntilButtonPressed()
# After the button is pressed, I want, that the drone is aligned by a rigid body.
# Means if the rigid body moves 1m left the drone should follow
# finished following the rigid body. Get back landing
swarm.allcfs.land(targetHeight=0.02, duration=1.0+Z)
swarm.timeHelper.sleep(1.0+Z)
当按钮被按下后,我想要使用rostopic的数据。在主机上,我通过ROS的VRPN客户端发送数据。 http://wiki.ros.org/vrpn_client_ros 我想要计算“tracker name”/pose主题的数据。