# Debug FAQ

## Gazebo crashed when connecting to image\_view

This can happen in Ubuntu 16 and under VMware environment.

example error messages:&#x20;

> vmw\_ioctl\_command error Invalid argument

> gzserver: /build/ogre-1.9-mqY1wq/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreRenderSystem.cpp:546: virtual void Ogre::RenderSystem::setDepthBufferFor(Ogre::RenderTarget\*): Assertion \`bAttached && "A new DepthBuffer for a RenderTarget was created, but after creation" "it says it's incompatible with that RT"' failed.

solution: [upgrade](http://gazebosim.org/tutorials?tut=install_ubuntu#Alternativeinstallation:step-by-step) to Gazebo 7 by the following commands.

```
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install gazebo7 -y
```

If this cannot solve the problem, run the following command to disable OpenGL 3.0 (and use OpenGL 2.1 instead), or disable "Accelerate 3D Graphics" in VM display settings. In addition, increasing the amount of graphics memory to 2GB (in VM display settings) may also help.

```
echo "export SVGA_VGPU10=0" >> ~/.bashrc
```

reference: [GitHub issue](https://github.com/uzh-rpg/rpg_quadrotor_control/issues/58#issuecomment-499814392), [Gazebo forum](https://answers.gazebosim.org/question/13214/virtual-machine-not-launching-gazebo/)

## Gazebo: Error in REST request&#x20;

This is a known issue when running Gazebo in Ubuntu 18, which can cause the model spawn service to fail. The error message is the following.

> \[Err] \[REST.cc:205] Error in REST request

Solution: open the file `gedit ~/.ignition/fuel/config.yaml` and replace the url inside from `https://api.ignitionfuel.org` to `https://api.ignitionrobotics.org`.

Reference: [Gazebo forum](https://answers.gazebosim.org/question/25030/gazebo-error-restcc205-error-in-rest-request/)

## Support exFAT File System in Ubuntu

* If you have an USB drive with 32GB or less flash memory, it is high likely using [FAT32 ](https://en.wikipedia.org/wiki/File_Allocation_Table#FAT32)file system by default. One salient drawback of this file system is that the maximum file size is 4GB. If you have a 5GB ROS bag (logging data) locally on the robot, you cannot copy it to this USB drive.&#x20;
* The good news is you can format this flash drive into [exFAT ](https://en.wikipedia.org/wiki/ExFAT)file system, which can support much larger size for a single file. However, this file system is not natively supported by Ubuntu 16.04. The solution is to install the following packages.

```bash
sudo apt update 
sudo apt install exfat-fuse exfat-utils
```

Reference: [How to Mount an exFAT Drive on Ubuntu Linux](https://linuxize.com/post/how-to-mount-an-exfat-drive-on-ubuntu/)

## A stop job is running for Session c1 of user gdm (1min 30s)

This happens to Ubuntu 18 (and above probably) Linux OS. The shutdown process is not clean and the user has to wait 1min 30s for the shutdown process to complete. By playing with `journalctl` , I was able to identify the daemon process is Xwayland.

The observed behavior is prevented if Xorg instead of Wayland is used for the login screen in gdm3. Therefore, edit section `[daemon]` in `/etc/gdm3/daemon.conf` as follows:

```
/etc/gdm3/daemon.conf:
[daemon]
# Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false
```

Reference: [Stack Exchange](https://unix.stackexchange.com/questions/273876/a-stop-job-is-running-for-session-c2-of-user/496563#496563), [Debian Bug report logs](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=843090#10)

## Shortcut Ctrl+Shift+E opens Emoji&#x20;

This can happen on an Intel NUC computer when trying to split the window vertically in `terminator`.

To change the OS' emoji picker shortcut, we can open the `ibus-setup` GUI and setting a different shortcut under the `Emoji` tab as described [here](https://askubuntu.com/questions/1039008/how-can-i-change-the-keyboard-shortcut-for-emoji-picker/1039039#1039039).

Or you can do it on the terminal as described [here](https://askubuntu.com/questions/1039008/how-can-i-change-the-keyboard-shortcut-for-emoji-picker/1141692#1141692). To completely disable the emoji picker shortcut, run:

```
gsettings set org.freedesktop.ibus.panel.emoji hotkey "@as []"
```

## (Deprecated) Debug Errors & Solutions

### **1. install pylint**

When installing `pylint` by `sudo /usr/bin/python -m pip install pylint`, the error message is

```
    Complete output from command python setup.py egg_info:
    Error: typed_ast only runs on Python 3.3 and above.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hZvW3z/typed-ast/
```

solution: `pip install --upgrade setuptools`

When using RoboWare, we sometimes see the prompt message to remind us of installing `pylint`. If click the install button, the command run by itself would be `sudo /usr/bin/python -m pip install pylint`. This will install `pylint` from `pip`. Then you may see the other error message

```
ERROR: Cannot uninstall 'enum34'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
```

This is because the package `enum34` is managed by `apt` rather then `pip`. If you then try to uninstall `enum34` in pip, you will see that many (103 on my computer) ROS packages will be removed at the same time, because these ROS Kinetic packages depend on this specific version of `enum34`, and `apt` will automatically manage these dependencies for you. So we cannot just simply uninstall or upgrade this package.

Given the fact that we cannot modify `enum34`, how could we solve this problem? The solution could be a "detour" plan. That is to install `pylint` directly from `apt` rather than `pip`, though `pip` was run automatically by RoboWare.

To search which package to install: `apt search pylint`. Then we can see three possible options: `pylint`, `python-pylint-common`, and `python3-pylint-common`. The first one is good enough. Then just run `sudo apt install pylint`. Done!

Finally, check if this package was installed successfully by `pip list | grep pylint`.

### **2. python-environment-related problems**

```
AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'
```

It is high likely that you are running a wrong version python other than required. Check your environment by

* `which python`
* `which python3`
* `which pip`
* `which pip3`
* `env | grep python`
* `env | grep PATH`
* `env | grep PWD`
* `pip list | grep cflib`
* `pip show cflib`
* `pip3 show cflib`

For example: in `virtualenv` environment, running `which pip` may return `/home/username/venv/bin/pip` rather than `/usr/bin/pip`.

For the error message above, the reason is that `cfclient` is running a wrong version of `numpy` library. A related discussion can be found in [this issue](https://github.com/numpy/numpy/issues/12736#issuecomment-454442867) in `numpy` github repo.

This problem is due to the residual files of `numpy` of version `1.15.4`, which should be clearly uninstalled before installing the `1.16.0` version.

Showing solution in code,

* `pip3 uninstall numpy`
* `pip3 install numpy==1.15.4`

would solve this issue.

Also, continuing to execute the following two lines would upgrade `numpy` to `1.16.0` and `cfclient` would still work.

* `pip3 uninstall numpy`
* `pip3 install numpy`

By exploring files in `~/.local` directory, we can see that when this issue happens, there is always a `numpy-1.15.4.dist-info` directory in position `~/.local/lib/python3.5/site-packages`, no matter how you uninstall and reinstall numpy. However, after reverting to numpy of version `1.15.4` and uninstalling it, this directory goes away, and only the `numpy-1.16.0.dist-info` directory left there.

### **3. ROS error in Python script**

```
Traceback (most recent call last):
  File "./ucr_demo.py", line 72, in <module>
    cfs[i].goTo(goal=C[i], yaw=0, duration=3.0)
  File "/home/arcslab/catkin_ws/src/crazyflie_mrs/scripts/crazyflie.py", line 94, in goTo
    self.goToService(groupMask, relative, gp, yaw, rospy.Duration.from_sec(duration))
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 435, in __call__
    return self.call(*args, **kwds)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 515, in call
    responses = transport.receive_once()
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py", line 727, in receive_once
    p.read_messages(b, msg_queue, sock)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 353, in read_messages
    self._read_ok_byte(b, sock)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 336, in _read_ok_byte
    raise ServiceException("service [%s] responded with an error: %s"%(self.resolved_name, str))
rospy.service.ServiceException: service [/cf4/go_to] responded with an error: timeout

```

I am trying to do a five robot demo with crazyflies, but some of them failed and dropped to the ground. Then I powered off those failed robots and this error emerged. This is because the server cannot communicate with those powered off robots. This error then terminated the script and I lost control of all my robots.

Possible solutions:

1. Connect to a joystick and set up an emergency button, so than you will still have control of your robots when bad things happen.
2. Instead of solution (1), we can also directly send through command line `rosservice call /cf1/emergency` to shut down the robot. Also, it is doable to have a keyboard interface that sends takeoff, land, emergency, etc.
3. Use a "try-except" structure in the Python script to handle (actually pass) these errors. Such that when error appears, the script can still continue running the remaining part.

```
    try:
        run()
    except rospy.ROSInterruptException:
        pass
```

### **4. ROS package dependency**

```
Failed to load nodelet [/camera/register_depth_rgb] of type [depth_image_proc/register] even after refreshing the cache: Failed to load library /opt/ros/kinetic/lib//libdepth_image_proc.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libopencv_core3.so.3.3: cannot open shared object file: No such file or directory)
```

This is due to the mismatched path or name in ROS packages. The solution is to upgrade all packages to the latest. This can be solved by

* `sudo apt-get update`
* `sudo apt-get upgrade`
* `sudo apt-get dist-upgrade`
