Skip to content

Commit

Permalink
(#159) motion commander fix of deck detection
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Dec 22, 2020
1 parent 17f8aad commit 460ae8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions docs/user-guides/sbs_motion_commander.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ We want to know if the deck is correctly attached before flying, therefore we wi

Above `__main__`, start a parameter callback function:
```
def param_deck_flow(name, value):
global is_deck_attached
def param_deck_flow(name, value_str):
value = int(value_str)
print(value)
global is_deck_attached
if value:
is_deck_attached = True
print('Deck is attached!')
Expand All @@ -69,7 +70,7 @@ def param_deck_flow(name, value):
print('Deck is NOT attached!')
```

The `is_deck_attached` is a global variable which should be defined under `URI`
The `is_deck_attached` is a global variable which should be defined under `URI`. Note that the value type that the `param_deck_flow()` is a string type, so you will need to convert it to a number first before you can do any operations with it.

```
...
Expand All @@ -95,9 +96,10 @@ is_deck_attached = False
logging.basicConfig(level=logging.ERROR)
def param_deck_flow(name, value):
global is_deck_attached
def param_deck_flow(name, value_str):
value = int(value_str)
print(value)
global is_deck_attached
if value:
is_deck_attached = True
print('Deck is attached!')
Expand Down Expand Up @@ -594,8 +596,9 @@ def log_pos_callback(timestamp, data, logconf):
def param_deck_flow(name, value):
global is_deck_attached
value = int(value_str)
print(value)
global is_deck_attached
if value:
is_deck_attached = True
print('Deck is attached!')
Expand Down
9 changes: 5 additions & 4 deletions examples/step-by-step/sbs_motion_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def log_pos_callback(timestamp, data, logconf):
position_estimate[1] = data['stateEstimate.y']


def param_deck_flow(name, value):
global is_deck_attached
def param_deck_flow(name, value_str):
value = int(value_str)
print(value)
global is_deck_attached
if value:
is_deck_attached = True
print('Deck is attached!')
Expand Down Expand Up @@ -126,5 +127,5 @@ def param_deck_flow(name, value):

# take_off_simple(scf)
# move_linear_simple(scf)
move_box_limit(scf)
logconf.stop()
#move_box_limit(scf)
#logconf.stop()

0 comments on commit 460ae8a

Please sign in to comment.