# Viper Quadcopter

**URL:** <https://forum.opencyphal.org/t/viper-quadcopter/816>\
**Category:** Applications & Usage\
**Created:** [April 29, 2020, 5:06am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816 "2020-04-29T05:06:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [April 29, 2020, 5:06am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/1 "2020-04-29T05:06:42Z")

</div>

Good morning everyone ☕ 😉

I’m part of a small group which is working on

> building a **Arduino MKR Vidor 4000** based quadcopter flight controller with all the features found in state-of-the art quadcopter designs making resourceful use of all components (MCU, FPGA, WiFi NINA, …) located on the Vidor 4000 in order to control a **Micro Aerial Vehicle (MAV)**.

In our opinion the **Arduino MKR Vidor 4000** is an especially interesting board for such an application since the onboard FPGA enables interesting capabilities, such as being used as an optical flow sensor in combination with a downward facing camera.

The current block diagramm looks like that:

 ![viper-baseboard-block-diagram](https://forum.opencyphal.org/uploads/default/original/1X/f354f5f1506d72b8d15b063f10cbb2555584f18f.png)

A current 3D rendering of the quadcopter and some of its electronics can be seen here (the red boards on top are Zubax Orel 20 ESCs).

 ![ViperQuadcopter_rendering_top](https://forum.opencyphal.org/uploads/default/original/1X/8c6254cff99509e3f780af403c48dfe677572329.png)

 ![ViperQuadcopter_rendering_bot](https://forum.opencyphal.org/uploads/default/original/1X/c37b334b12a8960bb6c9a3b96ebad5ff19fe3ca2.png)

The repositories containing all relevant code are located within the [107-systems](https://github.com/107-systems) GitHub organisation. One repository that might be of special interest to this community is [107-Arduino-UAVCAN](https://github.com/107-systems/107-Arduino-UAVCAN) which is currently work in progress and will provide an abstraction of libcanard in the form of an Arduino library.

Some more eye candy: Here’s a picture of the Arduino MKR Vidor 4000 with a MKR CAN Shield on top and the [VidorCameraAdapter](https://github.com/107-systems/VidorCameraAdapter) attached to it’s MiniPCIe slot.

 ![IMG_20200402_1509084](https://forum.opencyphal.org/uploads/default/original/1X/314c47b5b250a9cc949a76e150bfba95a81450e3.jpeg)

I’m looking forward to hear your thoughts on this one 😉

Edit: Adding pictures after being granted rights to more than one picture by Pavel (thank you 😉)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [April 29, 2020, 11:22am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/2 "2020-04-29T11:22:43Z")

</div>

Thanks Alexander. I’ve fixed the forum settings to avoid similar issues with posting in the future.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 6, 2020, 10:46am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/3 "2020-05-06T10:46:31Z")

</div>

I’ve got a question: How can I “see/generate” the CAN frame(s) for any kind of UAVCAN message (e.g. [heartbeat](https://github.com/UAVCAN/public_regulated_data_types/blob/master/uavcan/node/32085.Heartbeat.1.0.uavcan)) using the existing tools? My basic idea is that I want to generate a couple of test frames and feed it into our [Arduino UAVCAN library](https://github.com/107-systems/107-Arduino-UAVCAN) to see wether or not everything works as intented.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 6, 2020, 3:40pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/4 "2020-05-06T15:40:16Z")

</div>

Use the [PyUAVCAN](https://pyuavcan.readthedocs.io/) CLI tool. We’ve got a couple of examples published in the crash course, too:

> [@The Cyphal Guide](https://forum.opencyphal.org/t/the-cyphal-guide/778/1):
>
> ```auto
> $ pyuavcan pub 4919.my_project.MyMessageType.1.0 '{value: 1234, key: "Hello world!"}' --tr='CAN(can.media.socketcan.SocketCANMedia("vcan2",8),59)'
> 
> ```

The tool works on any platform but the CAN transport is currently only supported on GNU/Linux because it supports only SocketCAN as the backend. If you would like to use CAN on a different platform, please help us resolve this:

[https://github.com/UAVCAN/pyuavcan/issues/63](https://github.com/UAVCAN/pyuavcan/issues/63)

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 7, 2020, 3:48am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/5 "2020-05-07T03:48:07Z")

</div>

Hi Pavel,

Thanks for getting back to me. I’ve studied the crash course but I didn’t make the connection that I could just wip up a virtual can (= vcan 🤦‍♂️) and see the frames there. Thank you! ❤

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 26, 2020, 10:44am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/6 "2020-05-26T10:44:10Z")

</div>

Hi 👋  
After trying a l o t I’ve still not managed to get the pyuavcan tool installed AND running. Either my linux has the most f\*\*ked up Python environment ever (totally possible since this a system used heavily for all sorts of development work) or I just don’t get it. Is there a really failsafe way to get pyuavcan and all its dependencies installed regardless how the rest of the system is set-up?

```auto
$ python3.6 -m pyuavcan
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__ (pkg_name)
  File "/usr/local/lib/python3.6/dist-packages/pyuavcan/ __init__.py", line 69, in <module>
    raise RuntimeError('A newer version of Python is required')
RuntimeError: A newer version of Python is required

```

```auto
$ python3.8 -m pyuavcan
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
...
ModuleNotFoundError: No module named 'ruamel'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  ...
  File "/usr/lib/python3/dist-packages/apt/ __init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  ...
  File "/home/alex/.local/lib/python3.8/site-packages/pyuavcan/_cli/commands/_yaml.py", line 16, in <module>
    import ruamel.yaml
ModuleNotFoundError: No module named 'ruamel'

```

```auto
python3.8 -m pip install ruamel
Collecting ruamel
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  ...
  File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/ruamel/
```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 26, 2020, 10:59am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/7 "2020-05-26T10:59:11Z")

</div>

> [@aentinger](#):
>
> Is there a really failsafe way to get pyuavcan and all its dependencies installed regardless how the rest of the system is set-up?

Yes. In your case that would be:

```auto
python3.8 -m pip install pyuavcan

```

If you also want CLI tools, use this instead:

```auto
python3.8 -m pip install pyuavcan[cli]

```

More info: [https://pyuavcan.readthedocs.io/en/latest/pages/installation.html](https://pyuavcan.readthedocs.io/en/latest/pages/installation.html)

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 26, 2020, 11:11am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/8 "2020-05-26T11:11:01Z")

</div>

It works 🚀 ❤ !

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 26, 2020, 11:21am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/9 "2020-05-26T11:21:43Z")

</div>

But another issue whose source I don’t quite understand …

```bash
$ pyuavcan dsdl-gen-pkg https://github.com/UAVCAN/public_regulated_data_types/archive/master.zip dsdl_src/my_project
Error: RuntimeError: test saturated was already defined.

```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 26, 2020, 11:31am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/10 "2020-05-26T11:31:03Z")

</div>

Can you please re-run the command with `-vv` and post the output here?

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 26, 2020, 12:13pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/11 "2020-05-26T12:13:59Z")

</div>

Sure. Here’s the data gathered via

```bash
pyuavcan -vv dsdl-gen-pkg https://github.com/UAVCAN/public_regulated_data_types/archive/master.zip dsdl_src/my_project 2> pyuavcan.errlog

```

[pyuavcan.errlog](https://forum.opencyphal.org/uploads/short-url/uqvRD89RSvnC9BH1HS8UaVQiB6o.errlog) (69.7 KB)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 26, 2020, 1:02pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/12 "2020-05-26T13:02:19Z")

</div>

It’s a version mismatch that was just fixed in [https://github.com/UAVCAN/pyuavcan/pull/111](https://github.com/UAVCAN/pyuavcan/pull/111). Sorry. As we are still working on Nunavut and PyUAVCAN, occasionally things go out of sync causing problems of this kind. Can you please install the latest master of PyUAVCAN? Just clone the repo and run `pip install .` from its root directory. I think that should get you sorted out. I will be releasing a new version soon.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 26, 2020, 1:10pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/13 "2020-05-26T13:10:42Z")

</div>

No worries 😉 Unfortunately it’s still not quite cutting it.

Doing this …

```bash
git clone https://github.com/UAVCAN/pyuavcan
cd pyuavcan
python3.8 -m pip install .

```

… results in …

```bash
Processing /home/alex/projects/tools/pyuavcan
Collecting pydsdl~=1.4 (from pyuavcan==1.1.0.dev0)
  Using cached https://files.pythonhosted.org/packages/cf/46/89811eab172932d89e247c6c5b8ebb0fb595005cdefb57ceb0edafdd78a4/pydsdl-1.4.2-py3-none-any.whl
Collecting numpy~=1.16 (from pyuavcan==1.1.0.dev0)
  Using cached https://files.pythonhosted.org/packages/cf/5d/e8198f11dd73a91f7bde15ca88a2b78913fa2b416ae2dc2a6aeafcf4c63d/numpy-1.18.4-cp38-cp38-manylinux1_x86_64.whl
Collecting nunavut==0.2.3 (from pyuavcan==1.1.0.dev0)
  Using cached https://files.pythonhosted.org/packages/dc/53/d956f3833c419e6685d4f736d2dfaf41bc31b8e08b8753b249f8c71ded0c/nunavut-0.2.3-24-py3-none-any.whl
Collecting setuptools (from nunavut==0.2.3->pyuavcan==1.1.0.dev0)
  Using cached https://files.pythonhosted.org/packages/2c/c5/0d38afb961f83e0d51f319f7dc166195ebabc1ea3cb20a10a77f500f7156/setuptools-46.4.0-py3-none-any.whl
Installing collected packages: pydsdl, numpy, setuptools, nunavut, pyuavcan
  Running setup.py install for pyuavcan ... done
Successfully installed numpy-1.18.4 nunavut-0.2.4 pydsdl-1.4.2 pyuavcan-1.1.0.dev0 setuptools-46.4.0

```

When running …

```bash
pyuavcan -vv dsdl-gen-pkg https://github.com/UAVCAN/public_regulated_data_types/archive/master.zip dsdl_src/my_project 2> pyuavcan.errlog2

```

… I get another error:  
[pyuavcan.errlog2](https://forum.opencyphal.org/uploads/short-url/uniyQFJ3q6gXXwFA3ARLZb1ADNJ.errlog2) (79.3 KB)

Since your [commit](https://github.com/UAVCAN/pyuavcan/commit/2598d07fa933717488f99b9e1dd1b0f8c20245b0) is about pinning nunavut to 0.2.3 I’m wondering if I have a unclean build setup since it obviously uses 0.2.4 again.

```bash
Successfully installed numpy-1.18.4 nunavut-0.2.4 pydsdl-1.4.2 pyuavcan-1.1.0.dev0 setuptools-46.4.0

```

EDIT: For the record …

```bash
pyuavcan$ git log -n 1
commit 5463c0df6522885e87605db168a016d1a1d94541 (HEAD -> master, origin/master, origin/HEAD)
Merge: 5752640 2598d07
Author: Pavel Kirienko <pavel.kirienko@gmail.com>
Date: Tue May 26 15:59:47 2020 +0300

    Merge pull request #111 from jxltom/patch-1
    
    Update pydsdl as requirement to 1.4

```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 26, 2020, 1:17pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/14 "2020-05-26T13:17:56Z")

</div>

> [@aentinger](#):
>
> Since your [commit](https://github.com/UAVCAN/pyuavcan/commit/2598d07fa933717488f99b9e1dd1b0f8c20245b0) is about pinning nunavut to 0.2.3 I’m wondering if I have a unclean build setup since it obviously uses 0.2.4 again.

Please run `pip install nunavut==0.2.3` or just remove it and reinstall pyuavcan again (Nunavut will be pulled in automatically as a dependency).

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 27, 2020, 5:41am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/15 "2020-05-27T05:41:46Z")

</div>

Installation:

```bash
$ python3.8 -m pip install .
...
Collecting nunavut==0.2.3 (from pyuavcan==1.1.0.dev0)
  Using cached https://files.pythonhosted.org/packages/dc/53/d956f3833c419e6685d4f736d2dfaf41bc31b8e08b8753b249f8c71ded0c/nunavut-0.2.3-24-py3-none-any.whl
...
Installing collected packages: pydsdl, numpy, setuptools, nunavut, pyuavcan
  Running setup.py install for pyuavcan ... done
Successfully installed numpy-1.18.4 nunavut-0.2.3 pydsdl-1.4.2 pyuavcan-1.1.0.dev0 setuptools-46.4.0

```

Show nunavut version just to be safe:

```bash
$ python3.8 -m pip show nunavut
Name: nunavut
Version: 0.2.3
Summary: Generate code from DSDL using Jinja2 templates.
...

```

Running pyuavcan still generates an error (same as reported [here](https://forum.opencyphal.org/t/viper-quadcopter/816/13)):

```bash
pyuavcan -vv dsdl-gen-pkg https://github.com/UAVCAN/public_regulated_data_types/archive/master.zip dsdl_src/my_project 2> pyuavcan.errlog3

```

[pyuavcan.errlog3](https://forum.opencyphal.org/uploads/short-url/dkWNf0G5v3mfkPlQyDGED5tErtv.errlog3) (79.3 KB)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 27, 2020, 4:41pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/16 "2020-05-27T16:41:24Z")

</div>

Ah. Your root namespace directory `dsdl_src/my_project` does not appear to contain any DSDL source files. Maybe you forgot to specify version numbers? It should be like `Foo.1.0.uavcan` instead of `Foo.uavcan`.

The error message is absolutely unclear and it’s a bug. If you could confirm the above I am going to file it as such on GitHub.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 28, 2020, 5:34am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/17 "2020-05-28T05:34:05Z")

</div>

Good morning 👋

Yes I can in fact confirm that `dsdl_src/myproject` is empty. Also I don’t want to use any custom UAVCAN types, I just wanted to print a heartbeat on vcan0 via

```bash
$ pyuavcan pub 32085.Heartbeat.1.0 '{uptime:0xDEADBEEF, health:HEALTH_NOMINAL, mode:MODE_OPERATIONAL}'
Error: RuntimeError: Subsystem factory 'NodeFactory' for command 'publish' has failed: No module named 'uavcan'

```

Alas, it didn’t work either so I thought the command listed above the publish command in the crash course is necessary.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 28, 2020, 1:09pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/18 "2020-05-28T13:09:49Z")

</div>

> [@aentinger](#):
>
> Yes I can in fact confirm that `dsdl_src/myproject` is empty. Also I don’t want to use any custom UAVCAN types, I just wanted to print a heartbeat on vcan0 via

It failed because you didn’t generate the types. For that, you just need to run this:

```
pyuavcan dsdl-gen-pkg https://github.com/UAVCAN/public_regulated_data_types/archive/master.zip

```

Naturally, if you don’t have any custom types then you shouldn’t ask the generator to generate code for them.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [May 29, 2020, 4:52am UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/19 "2020-05-29T04:52:51Z")

</div>

Thank you for pointing this out. Obviously that’s not obvious for a first time user and the error message wasn’t very beneficial either. Now that I’ve generated types for UAVCAN only …

```bash
user@dir$ ls uavcan/
diagnostic file __init__.py internet metatransport node pnp primitive register si time

```

… I’ve attemted to publish a basic message using a basic example available within the pyuavcan documentation.

```bash
user@dir$ pyuavcan publish uavcan.diagnostic.Record.1.0 '{"text": "Hello world!"}'
Error: RuntimeError: Subsystem factory 'NodeFactory' for command 'publish' has failed: No module named 'uavcan'

```

For sure that error means something to your, for me it’s utterly meaningless 😉

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 29, 2020, 7:29pm UTC](https://forum.opencyphal.org/t/viper-quadcopter/816/20 "2020-05-29T19:29:21Z")

</div>

The tool is behaving as intended. The root cause is that the directory that contains the generated package is not listed as the Python import look-up path. This is mentioned in the documentation if you look at [`pyuavcan dsdl-gen-pkg --help`](https://pyuavcan.readthedocs.io/en/latest/pages/cli.html#subcommand-dsdl-generate-packages):

```
--output OUTPUT, -O OUTPUT
Path to the directory where the generated packages will be stored.
If not specified, defaults to the current working directory.
Existing packages will be overwritten entirely.
                 
The destination directory should be in PYTHONPATH to use the generated
packages

```

You can fix it like this, if you use bash/sh:

```auto
export PYTHONPATH=/your/directory:$PYTHONPATH

```

The problem with the bad error message is registered at [https://github.com/UAVCAN/pydsdl/issues/41](https://github.com/UAVCAN/pydsdl/issues/41)

[Next page](https://forum.opencyphal.org/t/viper-quadcopter/816.md?page=2)
