Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for publishing an array type #104

Open
maksimdrachov opened this issue May 5, 2024 · 0 comments
Open

Add example for publishing an array type #104

maksimdrachov opened this issue May 5, 2024 · 0 comments

Comments

@maksimdrachov
Copy link
Member

_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.

@maksimdrachov maksimdrachov changed the title Add example for publishgin an array type Add example for publishing an array type May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant