Skip to content

Instantly share code, notes, and snippets.

View awesomebytes's full-sized avatar

Sam Pfeiffer awesomebytes

View GitHub Profile
@awesomebytes
awesomebytes / simple_debian_repository.md
Last active May 7, 2024 11:50
How to create a simple debian repository with minimal dependences

Simple debian repository

How to have a simple debian repository to offer your packages.

Requirements

You probably have them already installed

  • Python (I used 2.7).
  • dpkg-scanpackages: sudo apt-get install dpkg-dev
  • gzip: sudo apt-get install gzip
@awesomebytes
awesomebytes / debian_from_ros_pkg.md
Last active May 7, 2024 11:50
How to create a debian from a ROS package
@awesomebytes
awesomebytes / example_interactive_debugging_1.py
Created April 30, 2024 09:39
Interactive debugging tips in Python with ipdb, hickle and ipython
#!/usr/bin/env python
"""Example of usage of ipython debugger (ipdb)
to interactively debug something in the code with autocomplete and color support.
You may need to install:
sudo pip install ipdb
"""
@awesomebytes
awesomebytes / quaternion_from_points.py
Last active April 29, 2024 22:49
Get a quaternion representing the orientation of the plane given by three points in space.
#!/usr/bin/env python
import numpy as np
import math
from tf.transformations import euler_from_quaternion, quaternion_from_euler
from geometry_msgs.msg import Point
"""
Stuff to compute an orientation quaternion
from three points in the space (that represent a plane,
@awesomebytes
awesomebytes / to_grayscale.py
Created April 18, 2020 04:08
Node to convert a ROS Image topic publisher from RGB to grayscale (rgb or bgr to mono8) using opencv and cv_bridge
#!/usr/bin/env python
import sys
import rospy
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
import cv2
"""
Node to transform an input Image topic into
@awesomebytes
awesomebytes / code_connect_via_command_line.md
Last active March 26, 2024 09:54
How to open Visual Studio Code via command line (local file, remote-ssh, docker, remote-docker)

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 / message_filter_over_rosbag.py
Last active March 15, 2024 13:36
message_filters ApproximateTimeSynchronizer over a rosbag (without roscore or /use_sim_time)
#!/usr/bin/env python
import itertools
import sys
import time
import rospy
import rosbag
import message_filters
"""
Example using a message_filters filter (ApproximateTimeSynchronizer) iterating
@awesomebytes
awesomebytes / ipython_to_file.md
Created March 16, 2016 10:38
Save iPython session to a python file as code

Save an iPython session commands/code to a file

You must use the magic method %save:

In [1]: %save?
Type:       Magic function
String Form:<bound method CodeMagics.save of <IPython.core.magics.code.CodeMagics object at 0x7fb5d25bb1d0>>
Namespace:  IPython internal
File: /usr/lib/python2.7/dist-packages/IPython/core/magics/code.py
@awesomebytes
awesomebytes / threaded_function_python.md
Last active February 7, 2024 11:51
Make a function or method threaded in python with a decorator

How to make a python function or class method threaded

From this stack overflow question I got this great snippet.

# Threaded function snippet
def threaded(fn):
    """To use as decorator to make a function call threaded.
    Needs import
    from threading import Thread"""
@awesomebytes
awesomebytes / htc_vive_controller_keypresses.py
Last active February 3, 2024 23:51
Example on how to retrieve the HTC vive controller keypresses using pyopenvr
#!/usr/bin/env python
import time
import pprint
import openvr
"""
Get the HTC Vive controllers keypresses and print them to screen.