Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Almost done with my PhD thesis...

Sam Pfeiffer awesomebytes

💭
Almost done with my PhD thesis...
View GitHub Profile
@awesomebytes
awesomebytes / Get_type_cpp.md
Created Oct 27, 2020
Get variable type user friendly name in C++
View Get_type_cpp.md

How to get the type of a variable in C++

#include <boost/units/detail/utility.hpp>
using boost::units::detail::demangle;
auto demangled_name = demangle(typeid(MY_VARIABLE).name());
std::cout << "variable is of type: '"<< demangled_name << "'" << std::endl;
@awesomebytes
awesomebytes / qt_ssh_x11_forwarding_no_glx_no_egl.md
Created Oct 21, 2020
ssh -X with opengl Qt enabled app solution to neither GLX nor EGL are enabled
View qt_ssh_x11_forwarding_no_glx_no_egl.md

ssh -X Qt OpenGL error solution

To avoid the following error: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled when doing X forwarding via SSH one needs to install the following (in the remote machine where you are sshing into). This also solves black screen for me.

# This is needed in the remote machine
sudo apt-get install libegl-mesa0 libglx-mesa0
@awesomebytes
awesomebytes / qt_serialbus.md
Last active Nov 10, 2020
Use qt serialbus in ubuntu 18.04 with qt 5.9
View qt_serialbus.md

Using the Qt serialbus (to access a CAN bus) in Ubuntu 18.04

I was trying to compile a Qt project that uses the Qt serialbus module and it was not configuring when using qmake, the error was: Unknown module(s) in QT: serialbus. So I needed to build qtserialbus myself.

While trying to build it I ran into: fatal error: private/qobject_p.h: No such file or directory.

# Overkill: get all qt-stuff
sudo apt install qml-module-qt-labs-folderlistmodel qml-module-qtquick-extras qml-module-qtquick-controls2 qt5-default libqt5quickcontrols2-5 qtquickcontrols2-5-dev qtcreator qtcreator-doc libqt5serialport5-dev build-essential qml-module-qt3d qt3d5-dev qtdeclarative5-dev qtconnectivity5-dev qtmultimedia5-dev
@awesomebytes
awesomebytes / default_camera_info.py
Last active Oct 9, 2020
Publish a default camera_info topic from an image topic
View default_camera_info.py
#!/usr/bin/env python
import sys
import numpy as np
import cv2
import rospy
from cv_bridge import CvBridge, CvBridgeError
from sensor_msgs.msg import CameraInfo, Image, CompressedImage
"""
Publish a default CameraInfo topic from an Image or CompressedImage topic
@awesomebytes
awesomebytes / dockerexec.py
Last active Oct 2, 2020
docker exec -t forwarding signals wrapper
View dockerexec.py
#!/usr/bin/env python3
import sys
import argparse
import os
import subprocess
import signal
import time
import threading
import shlex
import docker
View top_by_name.md
@awesomebytes
awesomebytes / code_connect_via_command_line.md
Last active Oct 8, 2020
How to open Visual Studio Code via command line (local file, remote-ssh, docker, remote-docker)
View code_connect_via_command_line.md

How to open Visual Studio Code via command line

In order to open a Visual Studio Code sometimes we want to do it from the command line. Either because that allows us to just open the current file or folder, or because we would like to script opening some specific resource. This resource may be placed in another machine (e.g. via ssh), or in a docker container (running in the same machine or in another machine).

Local file or folder

code <file or folder>
# e.g. code .
@awesomebytes
awesomebytes / find_roscores.py
Created Sep 22, 2020
Find roscores running in your network
View find_roscores.py
#/usr/bin/env python
import socket
import time
from multiprocessing import Process, Queue
def check_server(address, queue, port=11311):
# Create a TCP socket
s = socket.socket()
try:
s.connect((address, port))
View config_to_available_roscore.sh
# this is part of .bashrc / .bash_profile
if [[ $(ps aux | grep bin/roscore | grep -v grep) ]]; then
export ROS_MASTER_URI=`python -c "import rosgraph; print(rosgraph.Master('ip_checker').getUri())"`
export ROS_IP=`python -c "import rosgraph; print(rosgraph.Master('ip_checker').getUri().replace('http://','').replace(':11311/',''))"`
export ROS_NETWORK_INTERFACE=`ifconfig | grep $ROS_IP -1 | awk 'NR==1{print $1}' | sed 's/://g'`
else
echo "No roscore found, setting ROS_MASTER_URI and ROS_IP to localhost defaults."
export ROS_MASTER_URI=http://localhost:11311
export ROS_IP=127.0.0.1
export ROS_NETWORK_INTERFACE=lo
View Visualize_custom_apriltags.md

To visualize a custom AprilTags description

In python/ipython 2.7

custom_apriltag_string = "wwwwwwwwwbbbbbbwwbddddbwwbddddbwwbddddbwwbddddbwwbbbbbbwwwwwwwww"
for idx, c in enumerate(custom_apriltag_string):
    if idx % 8 == 0 and idx > 0:
        print
    print c,
You can’t perform that action at this time.