Community
cancel
Showing results for 
Search instead for 
Did you mean: 
ZChen57
Beginner
993 Views

On what conditions need to calibrate GPS?

Jump to solution

I changed the OS of the INtel Aero RTF drone to Ubuntu 16.04 so I can develop my own code to do position control with the drone. I changed the take off point of the drone for new test, should I calibrate the GPS again to locate the new origin for the drone?

Also, is the unit in my code meter? Like if I want to control my drone from (0,0,0) to (0,0,1), is that right if I calibrate the GPS first at this (0,0,0) point, and run the code, would the drone take off and reach 1 meter high vertical?

If the gravity center of the drone is not on the center of the four rotors? How should I adjust the gravity center to make sure it takes off vertically?

0 Kudos
1 Solution
Eliza_D_Intel
Employee
118 Views
Hello ZChen57, Thank you very much for the code! The GPS should be calibrated when the drone does not follow the way-points or you notice strange behavior during flight. Could you please confirm that you are using a battery when running these test? I saw in this thread: https://forums.intel.com/0D50P00004DAH4a?fromCase=1 that you were using a wall power supply which will not work. You can find more examples on how to create python programs for Intel Aero here: http://python.dronekit.io/ Thank you and best regards, Eliza

View solution in original post

5 Replies
Eliza_D_Intel
Employee
118 Views
Hello ZChen57, Thank you for your interest in the Intel Aero Ready to Fly drone. Could you please provide us the code you are using? Unfortunately, we cannot provide a proper answer without it. Thank you and best regards, Eliza
ZChen57
Beginner
118 Views

Hi Eliza,

 

Thanks for your help. In my code, I inteded to let the drone follow a square with length as 2 meters. But when I run the code, it seems that the drone just fly to one direction without changing directions. And when the drone took off first, it should take off vertically, but it took off to another direction. I calibrated the drone on the table, now I'm running tests on the ground. Does this means the origin point (0,0,0) of the drone is set on the table where I calibrated? Should I re-calibrate the GPS on the ground where I consider it as the new origin point?

I just want to let the drone follow a small square first, is there any suitable demo python code for my reference?

Thanks in advance.

The code I'm using is like this:

 

import rospy

from std_msgs.msg import String

import mavros

from geometry_msgs.msg import PoseStamped

from mavros_msgs.msg import State

from mavros_msgs.srv import CommandBool, SetMode

 

import socket

import thread

import time

 

# callback method for state sub

current_state = State()

offb_set_mode = SetMode

def state_cb(state):

global current_state

current_state = state

 

local_pos_pub = rospy.Publisher("/mavros/setpoint_position/local", PoseStamped, queue_size=10)

state_sub = rospy.Subscriber("/mavros/state", State, state_cb)

arming_client = rospy.ServiceProxy("/mavros/cmd/arming", CommandBool)

set_mode_client = rospy.ServiceProxy("/mavros/set_mode", SetMode)

 

pose = PoseStamped()

#pose.pose.position.x = 0

#pose.pose.position.y = 0

#pose.pose.position.z = 2

 

def position_control():

# rospy.init_node('offb_node', anonymous=True) put this in the main()

# prev_state = current_state

# rate = rospy.Rate(5.0) # MUST be more then 2Hz

 

# send a few setpoints before starting

for i in range(20):

local_pos_pub.publish(pose)

print("sending pre commands\n")

rate.sleep()

 

# wait for FCU connection

while not current_state.connected:

# print("current_state = ",current_state)

# print("current_state.connected = ",current_state.connected)

print("current state not connected\n")

rate.sleep()

 

last_request = rospy.get_rostime()

k=0

while not rospy.is_shutdown():

now = rospy.get_rostime()

if current_state.mode != "OFFBOARD" and (now - last_request > rospy.Duration(0.1)):

set_mode_client(base_mode=0, custom_mode="OFFBOARD")

last_request = now

else:

if not current_state.armed and (now - last_request > rospy.Duration(0.1)):

arming_client(True)

last_request = now

 

# older versions of PX4 always return success==True, so better to check Status instead

if prev_state.armed != current_state.armed:

rospy.loginfo("Vehicle armed: %r" % current_state.armed)

if prev_state.mode != current_state.mode:

rospy.loginfo("Current mode: %s" % current_state.mode)

prev_state = current_state

x1=[0,2,2,0]

y1=[0,0,2,2]

z1=[2,2,2,2]

pose.header.stamp = rospy.Time.now()

pose.pose.position.x = x1[k]

pose.pose.position.y = y1[k]

pose.pose.position.z = z1[k]

local_pos_pub.publish(pose)

rate.sleep()

k=k+1

if k>3:

k=0

print("is shutdown\n")

 

if __name__ == '__main__':

try:

rospy.init_node('offb_node', anonymous=True)

prev_state = current_state

rate = rospy.Rate(20.0) # MUST be more then 2Hz

thread.start_new_thread(position_control,())

print("start position cotrol thread successfully\n")

except rospy.ROSInterruptException:

print("unable to start position cotrol thread\n")

while 1:

pass

 

 

Eliza_D_Intel
Employee
119 Views
Hello ZChen57, Thank you very much for the code! The GPS should be calibrated when the drone does not follow the way-points or you notice strange behavior during flight. Could you please confirm that you are using a battery when running these test? I saw in this thread: https://forums.intel.com/0D50P00004DAH4a?fromCase=1 that you were using a wall power supply which will not work. You can find more examples on how to create python programs for Intel Aero here: http://python.dronekit.io/ Thank you and best regards, Eliza

View solution in original post

ZChen57
Beginner
118 Views
Thanks. And I did the test with lipo battery since the adapter can not work. Intel Forums <supportreplies@intel.com>
Eliza_D_Intel
Employee
118 Views
Hello ZChen57, Thank you! I believe that this example: http://python.dronekit.io/examples/guided-set-speed-yaw-demo.html can help you modify the code you wrote in order to control the movement of your drone. Please let me know if I can assist you with any other information! Best regards, Eliza
Reply