rover_follow.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. '''
  2. This is an example builder script that sets up a a set of rovers to
  3. be driven by ArduPilot for demonstrating follow mode
  4. The rover has the basic set of sensors that ArduPilot needs
  5. To start the simulation use this:
  6. morse run rover_follow.py
  7. '''
  8. from morse.builder import *
  9. num_vehicles = 3
  10. for i in range(num_vehicles):
  11. vehicle = ATRV('Vehicle%u' % i)
  12. vehicle.properties(Object = True, Graspable = False, Label = "Vehicle")
  13. # set rovers 3 meters apart
  14. vehicle.translate(x=0.0, y=3*i, z=0.0)
  15. # add sensors needed for ArduPilot operation to a vehicle
  16. pose = Pose()
  17. vehicle.append(pose)
  18. imu = IMU()
  19. vehicle.append(imu)
  20. gps = GPS()
  21. gps.alter('UTM')
  22. vehicle.append(gps)
  23. velocity = Velocity()
  24. vehicle.append(velocity)
  25. # create a compound sensor of all of the individual sensors and stream it
  26. all_sensors = CompoundSensor([imu, gps, velocity, pose])
  27. all_sensors.add_stream('socket')
  28. vehicle.append(all_sensors)
  29. # make the vehicle controllable with speed and angular velocity
  30. motion = MotionVW()
  31. vehicle.append(motion)
  32. motion.add_stream('socket')
  33. # Environment
  34. env = Environment('land-1/trees', fastmode=False)
  35. env.set_camera_location([10.0, -10.0, 10.0])
  36. env.set_camera_rotation([1.0470, 0, 0.7854])
  37. env.set_camera_clip(clip_end=1000)
  38. # startup at CMAC. A location is needed for the magnetometer
  39. env.properties(longitude = 149.165230, latitude = -35.363261, altitude = 584.0)