Lesson 6: FORGE blocks

Bring your own devices in

The truck lessons used FORGE Studio's simulated truck and camera. Here you bring your own: a small program on this computer sends the truck's packet, the way your ground device will; your companion computer is checked on this computer before it goes on the drone; a real drive is replayed in the simulation; and you see how the radio can carry your own format, signed and encrypted.

  • About 50 minutes
  • Step 6 of 9 on the path
  • 10 steps

Start with step 1

Your Goal

By the end you can prove your own ground device and companion computer against your program in FORGE Studio before the drone flies, replay a real object's run in the simulation, and choose how the ground link travels on the radio.

You Need

  • FORGE Studio on a Windows computer (free for everyone until 31 December 2026)
  • The lesson Talk both ways first: its program is the one used here
  • Python 3 on this computer for the ground program (python.org); a companion computer only for its step

Try FORGE Studio free

Learn It with Your AI

In your AI app connected to Studio, ask:

Teach me Bring your own devices in

It walks you through each step in Studio, or does it while you watch. Connect an AI app

What You Will Learn

  • Export a program's byte layout, and the Python module and C header that make and read its packets.
  • Send a packet from your own program on this computer and see FORGE › Checks read it, with no drone connected.
  • Check your companion computer on this computer, in FORGE › Checks, before it goes on the drone.
  • Replay a real object's recorded run as an actor's path in the simulation.
  • Know what semi-simulation is, and when not to use it.
  • Choose how the ground link travels on the radio: FORGE Studio's format, or your own, signed or signed and encrypted.

Ideas First

The same bytes, simulated or real

A FORGE program says what its packets look like, byte by byte. In the simulation FORGE Studio makes those bytes from its actors. On the real drone your own devices make them: a ground program for the ground link, a companion computer for the USB link. The program does not change.

So the work before a real flight is to prove that your devices send exactly those bytes. FORGE Studio checks them for you on this computer, with no drone and no risk.

Three ways to fly with the ground link

Simulated: the truck and its GPS are actors; FORGE Studio sends their packets. Your device, through FORGE Studio: your ground program sends to this computer, and FORGE Studio passes each packet to the drone. Your own format on the radio: in a real flight the drone's telemetry radio carries only your packets, straight to your ground device, and FORGE Studio stays on the drone's Wi-Fi.

There is also semi-simulation: a real drone in the air, flying to a simulated truck. It is useful to test a landing approach high above an empty field. It is never a way to fly near people: the drone goes where the simulated truck is, whatever is really there.

Step by Step

  1. Open the program 2 min

    In Studio: FORGE

    The program of Talk both ways has a ground link both ways: the truck's packet comes in, a report goes out. Here your own program on this computer plays the truck's GPS.

    1. In FORGE, open New from example and choose Follow the truck and report home (School lesson).
    2. Press Save: the export in the next step works on the saved program.

    Type exactly

    New from example
    Follow the truck and report home (School lesson)

    It worked when FORGE shows follow_the_truck, saved.

  2. Export the byte layout and code 3 min

    In Studio: FORGE › Checks

    Whoever writes the software of a ground device or a companion computer needs the bytes of each packet. FORGE Studio writes them as a PDF, and writes the code too: a Python module (only Python's own standard library) and a C header (no library at all). Both make and read exactly the bytes the flight controller expects; they were checked against the flight controller's own code.

    The files go next to the program, in Documents › UVIRA FORGE Studio › Programs, and the folder opens with the PDF chosen.

    1. Open FORGE › Checks and press Export the byte layout and code under the ground link.
    2. Open the PDF and find the packet truck: its bytes, and an example.

    It worked when The Programs folder holds follow_the_truck.byte-layout.pdf, follow_the_truck_packets.py and follow_the_truck_packets.h.

  3. Send the truck from your own program 8 min

    In Studio: Setup › Connection

    Your ground program sends to FORGE Studio over the network: a port on this computer. With no drone connected, FORGE › Checks reads what comes in against the program, packet by packet, under the ground link (What your ground device sends), and says in plain words what is wrong, such as start bytes that do not match.

    The module's example sends the truck 5 times a second. Without values it sends test values; give it the truck's latitude, longitude and velocity to send your own.

    1. Open Setup › Connection. Under Ground link, set The ground computer is on to The network (Wi-Fi or cable) and keep the port 14650. That is the only setting: everything else is in FORGE.
    2. Open a command window in the Programs folder and run: python -c "import follow_the_truck_packets as k; k.example_ground(truck_lat=12.9716, truck_lon=77.5946, truck_vel_n=5, truck_vel_e=0)"
    3. Back in FORGE › Checks, under the ground link, What your ground device sends counts the packets and shows their newest values. Stop the program with Ctrl+C.

    Type exactly

    The ground computer is on
    The network (Wi-Fi or cable)
    Network (UDP) port the ground device sends to
    14650

    It worked when FORGE › Checks shows truck with your values, read against follow_the_truck, with no drone connected.

  4. Fly the simulation with your program as the truck 6 min

    In Studio: Setup › Connection

    In the simulation FORGE Studio normally makes the truck's packets itself. Switch it to Real packets, as in flight and the virtual flight controller takes the packets of your program instead, exactly as a real drone would take them from your ground device.

    Your program's truck stands still unless you change its values while it runs: the drone follows 15 m behind a truck that does not move, then flies home.

    1. In Setup › Connection › Ground link, set In the simulation to Real packets, as in flight.
    2. Start your program again (the command of the last step), with the place your simulation flies (Simulate › Where it flies).
    3. Connect the virtual flight controller, upload the program, and fly it as in Talk both ways. Then set In the simulation back to Studio makes the packets.

    Type exactly

    In the simulation
    Real packets, as in flight

    It worked when Fly › Data links showed truck in with your program's values while the drone flew.

  5. Check your companion computer here first 6 min

    In Studio: FORGE › Checks

    On the real drone the companion computer talks to the flight controller over USB, and FORGE Studio never sees those bytes. So it checks them before, in FORGE › Checks under the companion link: plug the companion computer into this computer instead of the drone, and Studio reads what it sends against the program, and sends it the packets going to it, with test values.

    No companion computer yet? Read this step and come back to it. The truck landing program's companion link is the one to try: its packet marker carries forward, right and down.

    1. Open Land on a moving truck (School lesson) in FORGE (it has a companion link).
    2. Plug your companion computer into this computer by its USB serial line. In FORGE › Checks, under the companion link, at Check your companion computer here first, choose its port and speed and press Start checking.
    3. Run your companion's program. The check counts each packet, its rate and its newest values, and says what is wrong in plain words. Press Stop checking when it is right.

    It worked when The check shows marker coming in with the values your companion computer sends, or you have read the step for later.

  6. Replay a real run in the simulation 6 min

    In Studio: Simulate › Actors

    Every connection is recorded, and the recording keeps the packets your devices sent. Two values of a packet that give a position, whatever your packet calls them, can become an actor's path: a latitude and a longitude, or metres north and east of home. The actor then moves the way the real object moved, at its own average speed.

    Near the simulation's place it is where it really was. Elsewhere it starts where the actor stands, with its shape and length kept.

    1. In Simulate › Actors, choose Platform truck. Under its waypoints, press Follow a recorded track.
    2. Choose the flight of the step before (or any flight where a device sent its position), say which two values give the position, check the line under it, and press Use this track, then Save actors.

    It worked when The truck's path on the map is the recorded run.

  7. Semi-simulation, and when not to use it 4 min

    In Studio: Setup › Connection

    With In a real flight: The simulated actors (semi-simulation) in Setup › Connection › Ground link, a real drone in the air gets the simulated truck's packets, made around where the drone started. It is for proving an approach high above an empty field before a real truck is involved.

    The drone flies to where the simulated truck is, not to anything real. Fly says so before you arm. Use it only in an open field with nobody near, at a height where nothing is in the way, with the pilot holding the radio and ready to take over.

    1. Find In a real flight in Setup › Connection › Ground link and read the note under it. Leave it on The ground computer's packets.

    It worked when You can say what the drone flies to in semi-simulation, and where it may be used.

  8. Your own format on the radio 8 min

    In Studio: FORGE

    By default the ground link goes through FORGE Studio, which shows and records it, signed and encrypted in a real flight. If your own ground station talks to the drone without FORGE Studio, choose telemetry radio: your own format in the ground link block. In a real flight the drone's radio then carries only the program's packets, straight to your ground device, and FORGE Studio stays on the drone's Wi-Fi. In the simulation nothing changes: they pass Studio as always.

    Choose protection too. Signed: nobody can send the drone false packets. Signed and encrypted: nobody can read them either. Both use the program's link key, worked out from this computer's pairing with the drone, so nothing secret goes over the air. The exported PDF, Python module and C header follow the same rules.

    1. In the ground link block set telemetry radio to your own format and protection to signed and encrypted, then save.
    2. In FORGE › Checks, press Export the byte layout and code again: the PDF now has a Protection section. With the drone connected and paired, Save the link key… saves the key for your ground station (its module's set_link_key takes it).
    3. Put the ground link back to FORGE Studio's format for the other lessons, and save.

    It worked when You can say what the radio carries in each format, and what signed and encrypted each protect.

  9. Common mistakes 3 min

    A packet that never matches. Start bytes, ID, byte order or checksum differ from the layout: the check says bytes come in but none is one of the program's packets. Compare your bytes with the PDF's example.

    Counters that go back. With protection, the drone takes only higher counters since it started. The exported code counts from the time; your own code must count up too.

    Semi-simulation near people. The drone flies to a truck that is not there. Only an open field, nobody near.

    The link key in a message or a file someone else can read. It lets anyone read and send this program's radio packets. Keep it like a password; a new version of the program has a new one.

    It worked when You have read the mistakes.

  10. Check yourself 3 min

    1. With no drone connected, how do you know your ground program sends the right bytes? Answer: Setup › Connection › Ground link reads them against the program in FORGE and shows each packet and its values, or says what is wrong.

    2. Where does FORGE Studio see your companion computer's bytes in a real flight? Answer: nowhere: they go straight to the flight controller over USB. That is why the companion check is done on this computer first.

    3. In your own format, signed and encrypted, what does the drone do with a packet whose tag is wrong? Answer: it drops it, without reading it.

    1. Answer each question before you read the answer.

    It worked when You have answered the three questions.

Next on the Path

Next lesson, about 30 minutesYour own program: look aroundBy the end you have built, checked and flown a program of your own, with five states, and you know where to find each block you need.

What you prove here flies the real drone: See the flight controller