0
0
Drone Programmingprogramming~10 mins

Collision avoidance in swarms in Drone Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if two drones are too close.

Drone Programming
if distance(drone1.position, drone2.position) [1] safe_distance:
    avoid_collision()
Drag options to blanks, or click blank then click option'
A<
B==
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than instead of less than.
Checking for equality only.
2fill in blank
medium

Complete the code to update drone velocity to avoid collision.

Drone Programming
if distance(drone.position, neighbor.position) < safe_distance:
    drone.velocity = drone.velocity [1] avoid_vector
Drag options to blanks, or click blank then click option'
A/
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Adding the avoid vector instead of subtracting.
Multiplying velocity by avoid vector.
3fill in blank
hard

Fix the error in the collision check condition.

Drone Programming
if distance(drone.position, neighbor.position) [1] safe_distance:
    slow_down()
Drag options to blanks, or click blank then click option'
A<=
B<
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' which checks the wrong condition.
Using '<' without equality.
4fill in blank
hard

Fill both blanks to create a dictionary of drones with their speeds above threshold.

Drone Programming
fast_drones = {drone.id: drone.[1] for drone in swarm if drone.[2] > speed_threshold}
Drag options to blanks, or click blank then click option'
Aspeed
Bvelocity
Daltitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'velocity' which is a vector, not a speed value.
Using 'altitude' which is unrelated.
5fill in blank
hard

Fill all three blanks to filter drones and create a dictionary with adjusted speeds.

Drone Programming
adjusted_speeds = {drone.[1]: drone.[2] * speed_factor for drone in swarm if drone.[3] < max_speed}
Drag options to blanks, or click blank then click option'
Aid
Bspeed
Daltitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'altitude' instead of 'speed'.
Mixing keys and values incorrectly.