0
0
Drone Programmingprogramming~10 mins

Gazebo integration for 3D simulation 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 initialize the Gazebo client in your drone simulation.

Drone Programming
import gazebo_client

gazebo_client.[1]()
Drag options to blanks, or click blank then click option'
Astart
Blaunch
Cinit
Dconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'init' which is not defined.
Using 'connect' which is for network connections, not initialization.
2fill in blank
medium

Complete the code to spawn a drone model in Gazebo at a specific position.

Drone Programming
from gazebo_client import spawn_model

spawn_model('drone', position=[1])
Drag options to blanks, or click blank then click option'
A{'x':0, 'y':0, 'z':0}
B[0, 0, 0]
C0, 0, 0
D(0, 0, 0)
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list instead of a tuple which may cause errors.
Passing separate values without grouping them.
3fill in blank
hard

Fix the error in the code to correctly subscribe to Gazebo's drone pose topic.

Drone Programming
def pose_callback(msg):
    print(msg.position)

subscriber = gazebo_client.[1]('drone/pose', pose_callback)
Drag options to blanks, or click blank then click option'
Asubscribe
Bconnect
Clisten
Dpublish
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'publish' which is for sending messages, not receiving.
Using 'connect' which is not a valid method here.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps drone names to their altitude if altitude is above 10.

Drone Programming
altitudes = {drone: [1] for drone, data in drones.items() if data['altitude'] [2] 10}
Drag options to blanks, or click blank then click option'
Adata['altitude']
B>
C<
Ddrone
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' which reverses the condition.
Using drone name as value instead of altitude.
5fill in blank
hard

Fill all three blanks to filter and map drone speeds above 5 into a new dictionary with uppercase drone names.

Drone Programming
fast_drones = [1]: [2] for [3], info in drone_data.items() if info['speed'] > 5}
Drag options to blanks, or click blank then click option'
Adrone.upper()
Binfo['speed']
Cdrone
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'info' as key instead of drone name.
Using 'drone' as value instead of speed.