Threading multiple crazyflies (not using swarm class), erratic flying. How to fix? #1749
Unanswered
john-amadora
asked this question in
Q&A
Replies: 3 comments 3 replies
-
Hi John. Thanks for sharing your code. Before we dive in, can you verify that your CFs that share a radio are on the same radio channel? Channel switching takes a significant amount of time and can slow communications. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hello. I would suggest to do the following:
with SyncCrazyflie(URI, cf) as scf:
mc = MotionCommander(scf, default_height = DEFAULT_HEIGHT)
mc._reset_position_estimator()
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
cb=param_deck_flow)
logconf = LogConfig(name=drone, period_in_ms=500)
logconf.add_variable('stateEstimate.x', 'float')
logconf.add_variable('stateEstimate.y', 'float')
logconf.add_variable('stateEstimate.z', 'float')
logconf.add_variable('pm.vbat', 'float')
scf.cf.log.add_config(logconf)
logconf.data_received_cb.add_callback(log_pos_callback)
if not deck_attached_event.wait(timeout=3):
print(f"{drone}:No flow deck detected!")
enable = False
logconf.start()
URI1 = uri_helper.uri_from_env(default='radio://0/70/2M/E5E5E5E5E5')
URI1 = 'radio://0/70/2M/E5E5E5E5E5' |
Beta Was this translation helpful? Give feedback.
2 replies
-
great, thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I coded in control of 3 synchronous drones via the python wrapper for the crazyflie and using only the motion commander class for movement. I did this instead of the swarm class because each drone will be having its own command and the swarm class is limited to sending setpoints, synchronous movement, and sequential movement.
I implemented my system using threading in python. That is, the crazyflie and the motion commander is initialized in a function and the thread is enabled three times in main all with its own URI.
When one drone is enabled, hovering is steady, but when 3 drones are enabled, the drones tend to drift by a lot.
How can I fix this? I am thinking that perhaps they are sharing state estimates. Any ideas?
Here's what the function looks like. This is called 3 times in main to thread together. For more context, I want to control each drone based on command submitted by an external controller (handled by another thread). May not be the smartest implementation, I am not a compsci major after all. I just develop as needed.
Beta Was this translation helpful? Give feedback.
All reactions