Skip to content

Instantly share code, notes, and snippets.

View safijari's full-sized avatar

Jari safijari

View GitHub Profile
@safijari
safijari / depth_image_filter_ros.py
Created August 2, 2016 17:20
The code I used to apply a median filter to the Intel R200 camera's depth image coming from ROS. Note that you will need to remap topics and that once the filtering is done, you will need to pass it through a depth_image_proc/point_cloud_xyz node to get a point cloud (more info here http://wiki.ros.org/depth_image_proc#depth_image_proc.2BAC8-poi…
#!/usr/bin/env python
"""
Purpose of the file: subscribe to a topic called /image_raw of type sensor_msgs/Image
Apply filter to the resulting image
"""
from __future__ import print_function
import cv2
import numpy as np
import rospy
from sensor_msgs.msg import Image
@safijari
safijari / realsense_cloud_voxel_filtering.cpp
Last active December 21, 2023 10:10
The code I used to further denoise the R200 point cloud derived from the filtered cloud(see here https://gist.github.com/safijari/fca7fa75649dbaba4b0be54f5dd742ec). Note that this will need at least PCL 1.7.2 (for Ubuntu, it's in the official PPA)
/*
Purpose of node: subscribe to a point cloud, use a VoxelGrid filter on it with a setting that
clobbers voxels with fewer than a threshold of points.
*/
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <iostream>
#include <pcl/filters/voxel_grid.h>
/*
* Copyright (C) 2012-2014 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@safijari
safijari / mortalscumbag-mit-containername.zsh-theme
Last active December 29, 2019 01:34
My custom ZSH theme (mortalscumbag with CONTAINERNAME visualization)
function my_git_prompt() {
tester=$(git rev-parse --git-dir 2> /dev/null) || return
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
@safijari
safijari / Dockerfile-blog
Created April 3, 2017 17:47
Basic ROS Kinetic Dockerfile with some additional niceties
FROM osrf/ros:kinetic-desktop-full
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
RUN apt-get update && apt-get install -y \
tmux \
zsh \
curl \
wget \
vim \
emacs24 \
@safijari
safijari / .Xresources
Last active January 17, 2018 21:04
my i3 configs
Xft.dpi: 130 # helpful with general DPI weirdness
@safijari
safijari / bad circle test.py
Last active December 23, 2017 07:42
python properties
c = Circle(1)
print c.area # prints 3.141
print c.circumference # prints 6.282
c.radius = 2
print c.area # prints 3.141 which is incorrect
print c.circumference # prints 6.282 which is incorrect
from glob import glob
import rosbag
import yaml
import json
import os
fnames = glob('/folder/*.bag')
print fnames
bags = [rosbag.Bag(f) for f in fnames]
@safijari
safijari / i3_config_kalman
Created January 6, 2019 04:51
my old i3 config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!