Forum

Author Topic: Automatic mission planning python api - select Home point problem  (Read 1098 times)

hcexpo

  • Newbie
  • *
  • Posts: 3
    • View Profile
I am trying to automate the Plan Mission task through python API. I am importing Home point from the txt file as a shape.

In order to use min_altitude parameter I need to select that Home point. This is available in Plan mission GUI window, but I cannot find a way to declare that point using python API.
This is what I have so far.
1. I can load the shape and it is available to be selected if GUI used
2. I can get new mission plan but it doesn't take into account min_altitude since I dont know how to specify home point

Thanks in advance

Code: [Select]
print("Importing Home point")
chunk.importShapes(path=home_point_path, replace=True, crs=crs)

print("Mission planning started")
plan_mission_task = Metashape.Tasks.PlanMission()

#mission parameters
plan_mission_task.sensor = 0 #choose the camera that was used for input photos
plan_mission_task.min_altitude = 5
plan_mission_task.horizontal_zigzags = True
plan_mission_task.min_waypoint_spacing = 0.6
plan_mission_task.max_waypoints = 65000
plan_mission_task.overlap = 50
plan_mission_task.attach_viewpoints = True

plan_mission_task.apply(chunk)


Paulo

  • Hero Member
  • *****
  • Posts: 1320
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #1 on: January 26, 2022, 02:30:04 PM »
hello hcexpo,

supposing your home point is the the last shape in your chunk then following would select it:
Code: [Select]
home = chunk.shapes[-1]
home.selected = True
and if you want to get the home altitude just do:
Code: [Select]
home.geometry.coordinates[0].z # home point altitude in chunk.shapes.crs
in the task definition if you want to define the home_point then use:
Code: [Select]
plan_mission_task.home_point = home.key # home point key
Hpe this useful,
« Last Edit: January 26, 2022, 02:39:12 PM by Paulo »
Best Regards,
Paul Pelletier,
Surveyor

hcexpo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #2 on: January 26, 2022, 02:49:23 PM »
Hi Paulo,

thanks a lot for the quick answer, I tried this but this doesn't resolve the problem.  It selects the point (it becomes active) but it doesn't use it for plan_mission_task

Maybe I formulated the question the wrong way.
The proper question would be How to pass the Home point as an argument to Metashape.Tasks.PlanMission()

I would expect to have something like below

print("Importing Home point")
chunk.importShapes(path=home_point_path, replace=True, crs=crs)
home = chunk.shapes[-1]

print("Mission planning started")
plan_mission_task = Metashape.Tasks.PlanMission()

#mission parameters
plan_mission_task.home_point = home
plan_mission_task.sensor = 0 #choose the camera that was used for input photos
plan_mission_task.min_altitude = 5
plan_mission_task.horizontal_zigzags = True
plan_mission_task.min_waypoint_spacing = 0.6
plan_mission_task.max_waypoints = 65000
plan_mission_task.overlap = 50
plan_mission_task.attach_viewpoints = True

plan_mission_task.apply(chunk)


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #3 on: January 26, 2022, 03:00:03 PM »
Hello hcexpo,

Please try plan_mission_task.home_point = home.key
Best regards,
Alexey Pasumansky,
Agisoft LLC

hcexpo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #4 on: January 26, 2022, 04:44:00 PM »
Hi Alexey,

I figured it out. I see now that the home_point attribute is available from version 1.8.0. and I am using earlier version of Metashape

Thanks a lot guys,

hcexpo