Sent command to arducopter
arm(),disarm(),takeoff(),land(),flyTo()
Received arducopter status isArmed(),getMode(),getAttitude(),getAltitude(),getHeading(),getSpeed(),getLocation()
First Clone ardupilot-sdk-python from github
git clone https://github.com/drgowen/ardupilot-sdk-python
Adding function for getting Raw IMU in SDK
def getIMU(self): if 'RAW_IMU' not in self.mav.messages: raise Error("Haven't received RAW_IMU information yet") att = self.mav.messages['RAW_IMU'] return self.dictCopy(att, ['xacc','yacc','zacc'])
Example for get Attitude,Raw IMU from /dev/ttyUSB0 Baudrate:57600
from ardupilot import ArduPilot import time as time_ #make sure we don't override time def millis(): return int(round(time_.time() * 1000)) ac = ArduPilot("/dev/ttyUSB0",57600) #ac.arm() #ac.disarm() start_time = millis() while(1): if(millis()-start_time > 200): print ac.getAttitude() print ac.getIMU() start_time = millis()
Reference: https://github.com/drgowen/ardupilot-sdk-python
No comments:
Post a Comment