Forum

Author Topic: Automatic mission planning python api - select Home point problem  (Read 17183 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: 1599
    • 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: 15676
    • 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
 


 

geot

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #5 on: December 07, 2024, 12:15:39 AM »
I’m attempting to save the mission plan programmatically using the following code:

Code: [Select]
chunk.camera_track.save(r'C:temp\mission_plan.kmz',
                        file_format='wpml',
                        drone_name='M3E',
                        payload_name='M3E',
                        max_waypoints=5000)

However, I encounter the following error: Error: Can't find corresponding WPML config

When I manually export the mission plan using the Export Camera Track option in the GUI, it works perfectly fine.

What could be causing this error? I’m using Metashape Professional, version 2.1.1.

Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15676
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #6 on: December 17, 2024, 07:46:33 PM »
Hello geot,

Can you please check, if the problem is resolved by adding payload_position='Main gimbal' parameter to the export task.
Best regards,
Alexey Pasumansky,
Agisoft LLC

geot

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #7 on: December 19, 2024, 01:16:13 AM »
This did the trick, thanks Alexey!

geot

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #8 on: March 17, 2025, 02:11:05 PM »
The flight planning generally works well; however, we occasionally encounter outliers - specifically, image locations appearing below the surface (see attached screenshots). What could be causing this issue?

Additionally, how can we remove these outliers? Selecting them and using right-click -> delete doesn’t seem to be an option.

Thanks for your insights.   

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15676
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #9 on: March 17, 2025, 05:51:11 PM »
Hello geot,

You can select frames related to the camera track in the Model view using Rectangle Selection tool - it could be convenient to switch to a side view (XZ or YZ) and to orthographic mode, thus you can easily select all frames below certain level, then to delete them click on Remove Selected Items button on the Animation pane toolbar.

However, I think that such low altitude frames should not appear, if you use reasonable value in Min Altitude in Plan Mission dialog.
Best regards,
Alexey Pasumansky,
Agisoft LLC

geot

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Automatic mission planning python api - select Home point problem
« Reply #10 on: March 20, 2025, 11:53:29 AM »
Manual removal works as described, thanks.

Min_altitude is a relative height (relative to start point). Since we have to fly from the top of the cliff, we need to set this height to negative values to be able to conduct the mission at all. Shouldn't the safety_distance parameter be the one that prevents points below terrain?

Also, is there a way to make the camera symbols smaller? Currently, it's quite difficult  to see where the points are actually located.