MCPcopy
hub / github.com/dronekit/dronekit-python / set

Method set

dronekit/__init__.py:2431–2458  ·  view source on GitHub ↗
(self, name, value, retries=3, wait_ready=False)

Source from the content-addressed store, hash-verified

2429 return self._vehicle._params_map.get(name, None)
2430
2431 def set(self, name, value, retries=3, wait_ready=False):
2432 if wait_ready:
2433 self.wait_ready()
2434
2435 # TODO dumbly reimplement this using timeout loops
2436 # because we should actually be awaiting an ACK of PARAM_VALUE
2437 # changed, but we don't have a proper ack structure, we'll
2438 # instead just wait until the value itself was changed
2439
2440 name = name.upper()
2441 # convert to single precision floating point number (the type used by low level mavlink messages)
2442 value = float(struct.unpack('f', struct.pack('f', value))[0])
2443 success = False
2444 remaining = retries
2445 while True:
2446 self._vehicle._master.param_set_send(name, value)
2447 tstart = monotonic.monotonic()
2448 if remaining == 0:
2449 break
2450 remaining -= 1
2451 while monotonic.monotonic() - tstart < 1:
2452 if name in self._vehicle._params_map and self._vehicle._params_map[name] == value:
2453 return True
2454 time.sleep(0.1)
2455
2456 if retries > 0:
2457 errprinter("timeout setting parameter %s to %f" % (name, value))
2458 return False
2459
2460 def wait_ready(self, **kwargs):
2461 """

Callers 2

__setitem__Method · 0.95
__setitem__Method · 0.80

Calls 2

wait_readyMethod · 0.95
errprinterFunction · 0.90

Tested by

no test coverage detected