Components

Components are the motors, propellers and batteries in the ThrustLab catalog. You look them up here to get the ids that simulations need. You can also save a private part of your own.

Every simulation needs a motor, a propeller and a battery, so you will use this page first.

Find one part by name

find returns the single part that matches. This is the quickest way to get an id:

python
from thrustlab import Client

client = Client()
motor = client.components.find(name="BadAss 2826-820Kv")
print(motor["id"], motor["spec_json"]["kv"])

A part is a dictionary. Its id starts with comp_, and spec_json holds the datasheet numbers.

name is a search, so a short name can match more than one part. Then find raises an AmbiguousComponentError. Its candidates list holds the matches, and you can pick one by id. If nothing matches, you get a NotFoundError.

Browse the catalog

list returns many parts, a page at a time. Filter by type, which is "motor", "propeller" or "battery":

python
for motor in client.components.list(type="motor", kv_gte=400, kv_lte=900):
    print(motor["name"], motor["spec_json"]["kv"])

Kv is the speed a motor turns for each volt. The other filters work the same way, through extra arguments. A name with brackets can't be a normal argument, so pass it in a dictionary:

python
long_props = client.components.list(
    type="propeller",
    **{"diameter[gte]": 14, "diameter[lte]": 16, "pitch[gte]": 8},
)

Add [gte] for "at least" and [lte] for "at most" after any of these names. You must set type first.

Browse the catalog
TypeFilters
Motorkv, weight, resistance, current_max, poles, stator_diameter, stator_length, voltage_nominal
Propellerdiameter, pitch, weight, max_rpm, inertia
Batteryseries_cells, capacity, c_rating, weight

To pick from a list of choices, add [in] and a comma-separated string. These filters work this way: brand, battery chemistry, propeller blades, rotation and maker. For brands you can also pass brand_in=["KDE", "T-Motor"].

A name the type doesn't have fails with a ValidationError that lists the names it does have.

Other useful arguments:

  • search="2826" matches part of a name.
  • sort_by="name" and sort_order="desc" change the order. With a type you can sort by a spec such as kv.
  • visibility="private" shows only your own parts.

client.components.brands() lists the brands with a count of parts for each.

Get one part by id

python
motor = client.components.retrieve("comp_...")

Add your own motor

create saves a private part that only your account can see. Give it a type, a name and a spec_json with the datasheet numbers. A motor needs these:

python
motor = client.components.create(
    type="motor",
    name="My Custom 4260 800Kv",
    spec_json={
        "kv": 800.0,
        "n": 14,
        "R": 0.042,
        "weight": 120.0,
        "diameter": 42.0,
        "length": 25.0,
        "u_nominal": 10.0,
        "iq_nominal": 1.1,
        "iq_max": 65.0,
    },
)

The numbers mean:

  • kv: rpm per volt.
  • n: number of magnet poles.
  • R: winding resistance between two motor wires, in ohms.
  • weight: grams.
  • diameter and length: millimeters.
  • u_nominal and iq_nominal: the no-load current, in amps, and the voltage it was measured at.
  • iq_max: the highest current in amps. You can give power_max, in watts, instead.

Use the real datasheet values. A no-load current that is much too high for a motor is refused, because it is usually the maximum current typed into the wrong field.

Batteries and propellers need other fields, which Creating components lists. Saving a propeller needs the Pro plan, and a free account gets a 402 error.

If a part you need isn't in the catalog at all, you can send it in for everyone. See Submissions.