Code Monkey home page Code Monkey logo

Comments (6)

xinnad avatar xinnad commented on August 10, 2024

It looks like the issue comes from the way the flight controller casts the parameter value. The line in question is s->val.i = *(int32_t *)val; The equivalent line for a float param is s->val.f = *(float *)val; which works correctly. It seems like even though the param set message always sends a float value, the binary data contained in that float value is directly cast as whatever datatype the PARAM_TYPE_XXX says, in this case an int32.

A potential solution is:

  • gomavlib casts the data to an int32 (or other MAV_PARAM_TYPE) binary representation
  • casts that binary representation to a float*
  • sets the float value in the param set message to that binary representation

Does this seem like a reasonable approach? I'm not sure if this is an issue on other flight controllers or if it's only an issue for PX4.

from gomavlib.

xinnad avatar xinnad commented on August 10, 2024

I think I found a solution/workaround. It might be worthwhile to implement this in the gomavlib library so a user doesn't need to worry about casting datatypes. I used a standard type cast to convert the floating point value to an int, converted the int to its binary form with the encoding/binary package, and then wrote the resulting binary representation back to the address of my floating point parameter value. Things seem to work now.

from gomavlib.

xinnad avatar xinnad commented on August 10, 2024

Seems like this is the way the message is intended to work. The solution I proposed has been tested on hardware and seems to be reliable.

from gomavlib.

aler9 avatar aler9 commented on August 10, 2024

Hello, dialects are automatically generated from definitions, therefore this issue is common to all programming languages. At the moment there aren't much utilities in the library since it's already hard to support all upstream changes that come from the main Mavlink repository, so adding more stuff is out of the reach.

from gomavlib.

xinnad avatar xinnad commented on August 10, 2024

from gomavlib.

github-actions avatar github-actions commented on August 10, 2024

This issue is being locked automatically because it has been closed for more than 6 months.
Please open a new issue in case you encounter a similar problem.

from gomavlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.