zhongtianda / px4_gazebo_fuel

14 stars 2 forks source link

Drone not trigger #3

Open giangdao1402 opened 6 months ago

giangdao1402 commented 6 months ago

Hi @zhongtianda Thank for your great repo When i try it, i encountered a problem

https://github.com/zhongtianda/px4_gazebo_fuel/assets/98149078/8eddbd8b-ccec-47dc-bbfc-70702c2e57e6

Can you give me some advice ?

zhongtianda commented 6 months ago

It seems that there is no visual positioning enabled and the PX4 parameters need to be modified,you can see: https://www.yuque.com/xtdrone/manual_cn/ekf_settings

zhongtianda commented 6 months ago

I missed a part of the PX4 parameters setting and the blog has been updated.

giangdao1402 commented 5 months ago

Hello, thank you @zhongtianda i did run it successfully using gazebo ground truth pose with your instruction ! Now i use vins mono to run it. I use /vins_estimator/imu_propagate for cxr_control, exploration and mavros/vision_pose/pose. But something wrong with transform. Have you ever fly with vins mono. Can you give me some advices Thank you !!!

zhongtianda commented 5 months ago

@giangdao1402 The types of /vins_estimator/imu_propagate and /iris_0/mavros/vision_pose/pose are different. To provide localization ro px4, you need to run a conversion code similar to the following. If there are changes elsewhere, you also need to make corresponding modifications to ensure that the input provided to the algorithm is correct. import rospy from geometry_msgs.msg import PoseStamped, Point from nav_msgs.msg import Odometry import math from pyquaternion import Quaternion import tf import sys

vehicle_type = sys.argv[1] vehicle_id = sys.argv[2] local_pose = PoseStamped() local_pose.header.frame_id = 'world' quaternion = tf.transformations.quaternion_from_euler(0, 0, 0) #绕 zyx旋转 q = Quaternion([quaternion[3],quaternion[0],quaternion[1],quaternion[2]]) print(q)

def vins_callback(data):
local_pose.pose.position.x = data.pose.pose.position.x local_pose.pose.position.y = data.pose.pose.position.y localpose.pose.position.z = data.pose.pose.position.z q= Quaternion([data.pose.pose.orientation.w,data.pose.pose.orientation.x,data.pose.pose.orientation.y,data.pose.pose.orientation.z]) q = q*q localpose.pose.orientation.w = q[0] localpose.pose.orientation.x = q[1] localpose.pose.orientation.y = q[2] localpose.pose.orientation.z = q[3] print(q_)

rospy.init_node(vehicletype+""+vehicle_id+'_vins_transfer') rospy.Subscriber("/vins_estimator/odometry", Odometry, vins_callback,queue_size=1) position_pub = rospy.Publisher(vehicletype+""+vehicle_id+"/mavros/vision_pose/pose", PoseStamped, queue_size=1) rate = rospy.Rate(30)

while not rospy.is_shutdown(): if (local_pose.pose.position == Point()): continue else:

print("Vins pose received")

    local_pose.header.stamp = rospy.Time.now()
    position_pub.publish(local_pose) 
try:
    rate.sleep()
except:
    continue