URGENT: Setting up Home Position/Fake GPS & Altitude Information (Navio2)

Hi everybody. I am seeking assistance setting up a home position, fake GPS & printing or live updates of altitude information in Ardupilot via Mavros as a total beginner. I’ve been exploring ways to customize my location settings as I am planning to fly my drone indoors without the usage of a GPS along with printing of altitude information, but I’m finding the process quite challenging.

I would greatly appreciate it if someone could guide me through the steps or provide resources that explain the process in a beginner-friendly manner.

Thank you!

Hi Louis,

Welcome to the forum!

We don’t have a step-by-step guide for Mavros integration. But I was able to find some links that I think will be useful to you:

You can also check the ROS forum for any specific questions you may have.

Hello @olesia.riman , thank you for your help! I have looked through what you have sent but was still not able to set it up. Its alright, i decided to switch to other modes that does not requires GPS/Home Position.

May i ask for help on automatic take off using MavROS along with hovering after take off? I am not allowed to plan waypoints as i am working on a project to fly my drone through gesture recognition. I have managed to get it armed, but taking off to no avail. I have look through the forums but could not seem to find anything.

This is the code i used:
#!/usr/bin/env python3

import rospy
from mavros_msgs.srv import CommandBool, SetMode
from geometry_msgs.msg import PoseStamped
from mavros_msgs.msg import State

class DroneController:
def init(self):
rospy.init_node(‘drone_controller’, anonymous=True)

    self.current_state = State()
    self.rate = rospy.Rate(20.0)  # 20 Hz update rate

    self.local_pos_pub = rospy.Publisher('/mavros/setpoint_position/local', PoseStamped, queue_size=10)
    self.state_sub = rospy.Subscriber('/mavros/state', State, self.state_cb)

    # Create services
    self.arm_service = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)
    self.set_mode_service = rospy.ServiceProxy('/mavros/set_mode', SetMode)


def state_cb(self, msg):
    self.current_state = msg

def arm(self):
    return self.arm_service(True)

def disarm(self):
    return self.arm_service(False)

def set_mode(self, mode):
    rospy.loginfo(f"Setting mode to {mode}")
    return self.set_mode_service(custom_mode=mode)

def hover(self):
    self.set_mode("ALT_HOLD")  # Change to ALT_HOLD mode for manual control if not already in ALT_HOLD mode

    # Arm the drone
    if not self.current_state.armed:

    # Set the initial position to the current position
    initial_pose = PoseStamped()
    initial_pose.pose.position.z = 0.0  # Start at ground level
    for _ in range(100):

    # Gradually increase altitude for takeoff
    takeoff_pose = PoseStamped()
    takeoff_pose.pose.position.z = 2.0  # Set the desired altitude for takeoff
    rospy.loginfo("Automatic takeoff initiated...")
    for _ in range(100):
        takeoff_pose.pose.position.z += 0.02  # Increase altitude gradually

    # Hover
    rospy.loginfo("Hovering in ALT_HOLD mode...")
    while not rospy.is_shutdown():
        # Adjust altitude or other control parameters as needed

The motor did not spin.

Thanks in advance!


Can you check if the issue lies with the code and not with the motor? Does it spin with other code? How is the motor connected?

Hello @olesia.riman,

I am sure that the issue lies with the code as i have flown the drone manually without any issues. The problem came when i am trying to fly it automatically. Thank you.


I can hardly be of help with a custom code.

Hopefully, someone from our users who’s experienced with it can advise something. You can also raise your question on the ROS forum or Mavros repo.