Reseting and clearing caches after landing for a new takeoff

We a custom AirSDK mission. After 3-4 landings, we observe that mission is not working properly. Is it related with caches still having some values? How can we reset and kill working processes after landing?
Any recommendation?

2 Likes

Hi @Vulture151,

Can you provide more details about your mission ? Do you usr a custom guidance mode or Fsup stage ?

Regards,
Axel

Copyright (c) 2023 Parrot Drones SAS

Redistribution and use in source and binary forms, with or without

modification, are permitted provided that the following conditions

are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright

notice, this list of conditions and the following disclaimer in

the documentation and/or other materials provided with the

distribution.

* Neither the name of the Parrot Company nor the names

of its contributors may be used to endorse or promote products

derived from this software without specific prior written

permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

“AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS

FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE

PARROT COMPANY BE LIABLE FOR ANY DIRECT, INDIRECT,

INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,

BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS

OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED

AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,

OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT

OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF

SUCH DAMAGE.

from fsup.genstate import State, guidance_modes
import guidance.descent_pb2 as gdnc_descent_msgs
from fsup.missions.default.uid import UID
from fsup.missions.default.landing.normal import (
Descent as DefaultDescent,
)
import os
import cfgreader
import colibrylite.estimation_mode_pb2 as cbry_est
from fsup.missions.default.features.precise_home_manager import (
PreciseHomeManager,
)
from fsup.missions.default.landing.normal import (
Descent as DefaultDescent,
)

_PRECISE_MODE_NAME = UID + “.descent”

@guidance_modes(“com.parrot.missions.default.descent_to_ground”)
class PreciseHomeDescent(DefaultDescent):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
self.gdnc_dsc_svc = None

    # ---------------------------Get precise Home manager

    self.phome_manager = self.mission.get_manager(
        PreciseHomeManager, create_if_needed=True
    )
    # ---------End of precise get home manager--------------------------------------
    # To enable descent precise home
    self.landing_type = gdnc_descent_msgs.TYPE_DEFAULT

def enter(self, msg):
    # self.phome_manager = self.mission.get_manager(PreciseHomeManager, True)

    # To enable descent precise home
    self.landing_type = gdnc_descent_msgs.TYPE_DEFAULT

    if (
        self.phome_manager is not None
        and not self.phome_manager.is_move_already_interrupted()
    ):
        # Start precise home manager and find target
        # self.phome_manager.start_process()
        if self.phome_manager.is_target_found():
            self.log.info("TARGET FOUND")
            self.landing_type = gdnc_descent_msgs.TYPE_DEFAULT_PRECISE
            self.phome_manager.set_move_in_progress(True)

    self.set_guidance_mode(
        UID + ".descent_to_ground",
        gdnc_descent_msgs.Config(
            type=self.landing_type,
            target_type=gdnc_descent_msgs.TARGET_TYPE_GROUND,
        ),
    )

    # You should call self.phome_manager.stop_process() in exit() of your state
    # in order to make precise home manager ready for the next takeoff

    self.mc.dctl.cmd.sender.set_estimation_mode(cbry_est.LANDING)
    self.log.info("PRECISE LANDING FINAL")
    # KILL MANAGER
    # def step(self, msg):
    #     self.log.info("takeoff - ascent - Step - Enter")
    #     self.log.info(msg)
    #     self.log.info("takeoff - ascent -  Step - Exit")

def exit(self, msg):
    self.phome_manager.stop_process()
    self.phome_manager = None
    self.log.info("PRECISE LANDING completed")

    self.log.info("PRECISE LANDING EXIT - EXIT")

PRECISE_HOME_DESCENT_STATE = {
“name”: “precise_home_descent”,
“class”: PreciseHomeDescent,
}
this is final landing. It is landing precisely.

TRANSITIONS = [
# Overwritten transitions
[
Dctl("motors_ramping_done"),
"takeoff.normal.wait_ascent",
"takeoff.takeoff_to_photo.ascent",
],
[
Dctl("motors_ramping_done"),
"takeoff.normal.wait_motor_ramping",
"takeoff.takeoff_to_photo.ascent",
],
# New transitions
[
GdncAscent("done"),
"takeoff.takeoff_to_photo.ascent",
"takeoff.takeoff_to_fire.ascent",
],
[
GdncAscent("done_without_immobility"),
"takeoff.takeoff_to_photo.ascent",
"takeoff.takeoff_to_fire.ascent",
],
[
GdncAscent("done"),
"takeoff.takeoff_to_fire.ascent",
"flying.firewaypoints",
],
[
GdncAscent("done_without_immobility"),
"takeoff.takeoff_to_fire.ascent",
"flying.firewaypoints",
],
[
FireMission("cl_takeoff"),
"ground.idle",
"takeoff.normal",
],
[
FireMission("cl_fly_home"),
"hovering",
"flying.flyhome",
],
[
FireMission("cl_fly_to"),
"hovering",
"flying.fireflytopath",
],
[
FireMission("cl_fly_circle_position"),
"hovering",
"flying.firecycle",
],
` [` ` MissionFlightPlan("done"),` ` "flying.firewaypoints",` ` "hovering",` ` ],` ` [` ` MissionFlightPlan("done"),` ` "flying.fireflytopath",` ` "hovering",` ` ],` ` [` ` MissionFlightPlan("done"),` ` "flying.flyhome",` ` "flying.precise_home_search",` ` ],` ` [` ` GdncDescent("done"),` ` "flying.precise_home_search",` ` "flying.precise_home_search_final",` ` ],` ` [` ` GdncDescent("done"),` ` "flying.precise_home_search_final",` ` "landing.precise_home_descent",` ` ],` ` [` ` Dctl("landed_detected"),` ` "landing.precise_home_descent",` ` "landing.normal.stopping_motors",` ` ],` ` # [` ` # Dctl("done"),` ` # "landing.precise_home_descent",` ` # "ground.idle",` ` # ],` ` [` ` MissionFlightPlan("done"),` ` "flying.firecycle",` ` "hovering",` ` ],`
]

Thanks for you code.

What kind of wrong drone behavior are you talking about when you say that mission is not working properly? What is your problem?

I think I have found the error. I was stopping precise home manager after that I was assigning none to phome_manager object. this was crashing code after landing. If we dont reboot then drone takes off with a crashed airsdk.Commented out and solved.
self.phome_manager.stop_process()
#self.phome_manager = None
But If I make a second take off when drone comes back for Precise landing it can not find the pad. What do we need to make precise landing available for second take off? Is stop_process not enough? what is ground.reset state? do we need that?

Hi Axelm,
After landing if I make another takeoff , Phome_manager is not finding the target in the second landing. I stop the phome_manager after exiting landing stage. What am I missing?
Code for exit part of landing is as follows:
def exit(self, msg):

  •  try:*
    
  •    self.phome_manager.stop_process()*
    
  • except:*
  •    self.log.info("Problem with stopping phome_manager.stop_process()")*
1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.