mavlink/MAVSDK-Swift

Parameters - setParamFloat works but setParamInt does not

mmanionRIIS opened this issue ยท 13 comments

I am able to change the parameters with setParamFloat, but not with setParamInt. I'm thinking it might have to do with using Int32, but thats just speculation. The weird thing is that setParamInt will return "onCompleted" so it will appear that it successfully changes the param, but it does not. Anyone else come across this?

// return Completed and changes the value
    func setParameterFloat(_ parameter: String, _ value: String) {
        if let newValue = Float(value){
            mavsdkDrone.drone?.param.setParamFloat(name: parameter, value: newValue)
                .subscribe(onCompleted: {
                    print("Changed \(parameter) to \(value)")
                }, onError: { (error) in
                    print(error)
                })
                .disposed(by: disposeBag)
            }
    }
    // return Completed but does not change the value
    func setParameterInt(_ parameter: String, _ value: String) {
        if let newValue = Int32(value){
            mavsdkDrone.drone?.param.setParamInt(name: parameter, value: newValue)
                .subscribe(onCompleted: {
                    print("Changed \(parameter) to \(value)")
                }, onError: { (error) in
                    print(error)
                })
                .disposed(by: disposeBag)
            }
    }
    ```

What param are you setting? What autopilot (I assume PX4?), and what version of it?

I'm using ArduPilot. I'm unable to change the RTL_LOIT_TIME or RTL_ALT.

I also tried the PILOT_ACCEL_Z, TERRAIN_SPACING, and STAT_RUNTIME as well, all unsuccessfully.

Edit: I also accounted for "increments", example. RTL_LOIT_TIME has increments of "1000".

What version of mavsdk_server or MAVSDK-Swift is it using? There have been some fixes, and for ArduPilot there might be some more coming up with MAVSDK v2.0.

I've updated to the latest version of the MAVSDK-Swift on the Main Branch, so 1.1, looks like it was updated 2 months ago.

Drone Specs:
Screen Shot 2022-08-29 at 8 54 08 AM

MAVSDK-Swift is on mavsdk-server 1.4.2: https://github.com/mavlink/MAVSDK-Swift/blob/main/Package.swift#L50. Let me try to update that to 1.4.4 tomorrow ๐Ÿ‘

Right, so there have been a couple of fixes since:
mavlink/MAVSDK#1703
mavlink/MAVSDK#1788

You can see the changes here: https://github.com/mavlink/MAVSDK/releases

Could you try with the newly-published MAVSDK-Swift v1.1.1?

I updated to 1.1.1. Unfortunately, had the same result.

Any chance you could try to debug what's happening in C++? Two ways:

  1. Build MAVSDK-C++ and try it there from your laptop (I guess it's a problem related to Ardupilot, not iOS).
  2. Build MAVSDK-C++ with mavsdk_server, run mavsdk_server on your laptop, and connect your iOS app to it using this interface.

I would personally go for 1, build a small example (e.g. this one) and try to reproduce there ๐Ÿ‘.

Also maybe @ykhedar has an opinion ๐Ÿ˜‡.

Thank you, will try this tomorrow and let you know how it goes!

Still working on resolving some errors I'm getting when building the C++. I'd bet this is on my end and will let you know when I get the C++ app up and running.

I'm pretty sure my error is related to mavlink/MAVSDK#1875

Screen Shot 2022-09-02 at 12 11 51 PM

Seems like you are trying to build an example from main with a MAVSDK from 1.4.x. How did you install MAVSDK? You should build it from main ๐Ÿ‘

I installed MAVSDK on MacOS using Homebrew, following this: https://mavsdk.mavlink.io/main/en/cpp/quickstart.html

Will give building form main a shot.