项目作者: VimDrones

项目描述 :
Motion Capture System Simulator Base on Gazebo8, can be use for vehicle SITL position Estimate
高级语言: Python
项目地址: git://github.com/VimDrones/GazeboMotionCapture.git
创建时间: 2018-03-23T02:50:34Z
项目社区:https://github.com/VimDrones/GazeboMotionCapture

开源协议:MIT License

下载


GazeboMotionCapture

Motion Capture System Simulator Base on Gazebo, can be use for vehicle position Estimate

install

  1. pip install GazeboMotionCapture

dev

  1. git submodule update --init --recursive

usage

  1. #example with dronekit
  2. print "Start simulator (SITL)"
  3. import dronekit_sitl
  4. sitl = dronekit_sitl.start_default()
  5. connection_string = sitl.connection_string()
  6. # Import DroneKit-Python
  7. from dronekit import connect, VehicleMode
  8. # Connect to the Vehicle.
  9. print("Connecting to vehicle on: %s" % (connection_string,))
  10. vehicle = connect(connection_string, wait_ready=True)
  11. import time
  12. import GazeboMotionCapture
  13. position_estimate = GazeboMotionCapture.PositionEstimate()
  14. def callback(id, position, orientation):
  15. print(id, position, orientation)
  16. if not position_estimate.init:
  17. position_estimate.first_position = position
  18. position_estimate.init = True
  19. position_estimate.receive_new_position(position[0], position[1], position[2])
  20. if position_estimate.is_ready():
  21. msg = vehicle.message_factory.att_pos_mocap_encode(
  22. int(round(time.time() * 1000)),
  23. orientation,
  24. position_estimate.ned_position[0],
  25. position_estimate.ned_position[1],
  26. position_estimate.ned_position[2])
  27. vehicle.send_mavlink(msg)
  28. GazeboMotionCapture.callback = callback
  29. motion_capture = GazeboMotionCapture.create_motion_capture(('192.168.1.49', 11345))
  30. motion_capture.start()
  31. time.sleep(10)
  32. motion_capture.exit()