ArduPilot / ArduPilot/MAVProxy
Having issues while running magfit script
- Dominant language
- Python
- Stars
- 595
- Forks
- 773
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 18
Description
Hi guys,
when I am trying to run command for magfit, I am facing this issue, (refer below image)
```
command --->> magfit_WMM.py --cmot --elliptical --mag 1 --reduce 10 /home/orion/ardupilot/modules/mavlink/pymavlink/tools/test1_grey_vtol_qhover_160323.bin
```

I tried with mavproxy>tools also, even there I was facing errors, (I followed this video - https://www.youtube.com/watch?v=K7Gn-tXdJSE&feature=youtu.be) from official documentation.
documentation link - https://ardupilot.org/copter/docs/common-magfit.html
Logs -
```
Attitude source ATT mtypes=['GPS', 'MAG', 'ATT', 'BAT']
Extracted 54 points
Current: Vector3(-178.19, -198.93, 191.47) diag: Vector3(0.98, 1.02, 0.99) offdiag: Vector3(-0.02, -0.00, -0.00) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
Traceback (most recent call last):
File "/home/orion/.local/lib/python2.7/site-packages/MAVProxy/modules/lib/magfit.py", line 686, in OnButton
self.callbacks[event.GetId()]()
File "/home/orion/.local/lib/python2.7/site-packages/MAVProxy/modules/lib/magfit.py", line 691, in run
magfit(self.mlog, self.timestamp_in_range)
File "/home/orion/.local/lib/python2.7/site-packages/MAVProxy/modules/lib/magfit.py", line 366, in magfit
c = fit_WWW()
File "/home/orion/.local/lib/python2.7/site-packages/MAVProxy/modules/lib/magfit.py", line 183, in fit_WWW
(p,err,iterations,imode,smode) = optimize.fmin_slsqp(wmm_error, p, bounds=bounds, full_output=True)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/slsqp.py", line 207, in fmin_slsqp
constraints=cons, **opts)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/slsqp.py", line 370, in _minimize_slsqp
raise ValueError("Objective function must return a scalar")
ValueError: Objective function must return a scalar
```
Please suggest any solutions.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the magfit_WMM.py command and inspect MAVProxy/modules/lib/magfit.py, especially fit_WWW where the traceback reaches scipy.optimize.fmin_slsqp. Done means the command no longer raises “Objective function must return a scalar” for the supplied log.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100