-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParamValueTypes #11
Comments
Currently, there is no other way to read If you have an idea how we could approach it please let me know. |
btw This is very important for setparamvalue messages of int parameters |
I know, this is a shortcoming at the moment.
pt., 20 maj 2022 o 13:46 numan ***@***.***> napisał(a):
… btw This is very important for setparamvalue messages of int parameters
—
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEHICRN34MQ55WJNB67KMTVK53QFANCNFSM5WOOQU5Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I think as a temp solution to set int parameters, this works: const message = new common.ParamSet()
message.targetSystem =1
message.targetComponent = 1;
message.paramId = "CAL_AIR_CMODEL";
message.paramType = 6;
let tmpBuffer = Buffer.alloc(4)
tmpBuffer.writeInt32LE(0)
message.paramValue = tmpBuffer.readFloatLE();
await send(port, message, new MavLinkProtocolV2()) of course, the value inside of writeInt32LE is value we want to set, and I have not yet tested this extensively. I will keep you updated if I encounter anything with this "solution" |
I think the biggest problem that I can see here is that the parameter has the value associated with it on the definition level and not in the bytes on the wire (or am I wrong?). With that, it is hard to figure out what type to serialize the data to. I might think of some generator that will kind of generate a list of properties that are properly typed when a value is assigned to it. |
I think you are absolutely correct. There is no way of parsing paramvalue withouth knowing the definions of paramtype. However at some level that is bound to happen. For example, some of the params are actually enums and their definitions are in parameter metadatafiles of their respected firmwares. Or I might just be overthinking it, you are the boss :D |
ok so ... relevant code is below. they are taken from ardupilotmega.py after i installed pymavlink, but i donr know where it is in their repo import struct
def param_value_send(self, param_id, param_value, param_type, param_count, param_index, force_mavlink1=False):
return self.send(self.param_value_encode(param_id, param_value, param_type, param_count, param_index), force_mavlink1=force_mavlink1)
def param_value_encode(self, param_id, param_value, param_type, param_count, param_index):
return MAVLink_param_value_message(param_id, param_value, param_type, param_count, param_index)
class MAVLink_param_value_message(MAVLink_message):
unpacker = struct.Struct("<fHH16sB")
def pack(self, mav, force_mavlink1=False):
return self._pack(mav, self.crc_extra, self.unpacker.pack(self.param_value, self.param_count, self.param_index, self.param_id, self.param_type), force_mavlink1=force_mavlink1) tl;dr: , in pymavlink value of paramvaluesend is serialised by I did not check but proably similiar issue exist in node-amvlink param value send, and pymavlink paramvalue messages. (and maybe all param related messages in many auto generated mavlink libs?) maybe param related messages values should not be float and instead bytearray kind of thing in mavlink :/ |
i got an answer, as it turns out this is the intended way. Unless you want to add something this issue can be closed |
I am still not done with it and I'll keep this issue open until I get a more humane way of dealing with both reading and setting values for parameters. I'd love to have (at the very least for the known configuration options) a fully type-safe way of dealing with settings. But it requires both time and a good idea how to do it so it makes sense, of which I am short at the moment. One day, hopefully... |
What is the correct way to parse the value of ParamValue?
In the docs it is stated that actual type of param_value fields are indicated in param_type fields.
Right now we can parse the correct values via something like :
1- Is this the correct way?
2- can it be done inside node-mavlink?
3- I dont know if there are other messages like that, but if so passing on the raw value of fields might be helpfull. In this case since paramValue is at the start of payload; code is clean but if it were to at the middle of the payload, we might have had to search for the correct offset etc.
The text was updated successfully, but these errors were encountered: