Skip to content

Add example for publishing an array type #104

@maksimdrachov

Description

@maksimdrachov

_EXAMPLES = """
Example: publish constant messages (no embedded expressions, just regular YAML):
\b
yakut pub uavcan.diagnostic.record '{text: "Hello world!", severity: {value: 4}}' -N3 -T0.1 -P hi
yakut pub 33:uavcan.si.unit.angle.scalar 2.31 uavcan.diagnostic.Record 'text: "2.31 radian"'
Example: publish sinewave with frequency 1 Hz, amplitude 10 meters:
\b
yakut pub -T 0.01 1234:uavcan.si.unit.length.scalar '!$ "sin(t * pi * 2) * 10"'
Example: as above, but control the frequency of the sinewave and its amplitude using sliders 10 and 11
of the first connected controller (use `yakut joystick` to find connected controllers and their axis mappings):
\b
yakut pub -T 0.01 1234:uavcan.si.unit.length.Scalar '{meter: !$ "sin(t * pi * 2 * A(1,10)) * 10 * A(1,11)"}'
Example: publish 3D angular velocity setpoint, thrust setpoint, and the arming switch state:
\b
yakut pub -T 0.1 \\
5:uavcan.si.unit.angular_velocity.Vector3 '!$ "[A(1,0)*10, A(1,1)*10, (A(1,2)-A(1,5))*5]"' \\
6:uavcan.si.unit.power.Scalar '!$ A(2,10)*1e3' \\
7:uavcan.primitive.scalar.Bit '!$ T(1,5)'
Example: simulate timestamped measurement of voltage affected by white noise with standard deviation 0.25 V:
\b
yakut pub -T 0.1 6:uavcan.si.sample.voltage.scalar \\
'{timestamp: !$ time()*1e6, volt: !$ "A(2,10)*100+normalvariate(0,0.25)"}'
""".strip()

I think arrays are pretty common, but there's no example on how to publish them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions