Skip to content

Instantly share code, notes, and snippets.

@simonlynen
simonlynen / ourputCompileTimeConstant
Created December 7, 2012 01:16
TMP to echo a compile time constant during compilation as a warning
//output a compile time constant
template<size_t size>
struct overflow{ operator char() { return size + 999999; } }; //always overflow
template<int VALUE>
void echoCompileTimeConstant()
{
char(overflow<VALUE>());
}
Usage:
@simonlynen
simonlynen / 16to8bit
Created March 11, 2013 13:36
16bit to 8 bit scaling
cv::Mat image;
image.create(image_height, image_width, CV_16UC1);
cv::Mat image_8bit;
image_8bit.create(image_height, image_width, CV_8UC1);
memcpy(image.data,frame_ptr->getImageRawPtr(),(image_width)*image_height*2);
uint16_t max=0;
@simonlynen
simonlynen / for_each_bag_print_info
Last active December 15, 2015 02:29
for all rosbags in directory list name and yaml info
for file in *.bag; do echo "$file" && rosbag info "$file" -y; done
#!/usr/bin/env sh
# It's a reference about what to do after freshly installing Ubuntu 12.04 desktop amd64.
# It's MY note and it suit me.
# Though I note the process down here as a ".sh" file,
# you SHOULD check it first or copy-and-paste the useful sections into your terminal
# to ensure the availability.
# I am NOT GUARANTEE the availability of this file (note)
# or I am not responsible for your lost if you follow this note.
# It's for amd64 only, not i386, though most of the codes should meet no problems in i386.
@simonlynen
simonlynen / flir_bag_to_avi
Created April 7, 2013 15:30
convert flir ir bags to avi
for file in *.bag; do echo "$file" && rosrun irdetect_16_8 bag_to_image "$file" /cam2/image_raw ~/Desktop/$file 16 1 1; done
@simonlynen
simonlynen / slerp.m
Created April 9, 2013 20:36
quaternion slerp matlab
function [ q3 ] = slerp( q1, q2, t )
%SLERP quaternion slerp
% computes the slerp of value t between quaternions q1 and q2
q1 = q1 ./ norm(q1);
q2 = q2 ./ norm(q2);
one = 1.0 - eps;
d = q1'*q2;
absD = abs(d);
@simonlynen
simonlynen / average_quats.m
Created April 9, 2013 20:36
quaternion average of a power two length vector of quaternions
function [ averagequat ] = average_quats( diffquats )
%AVERAGE_QUATS Average a series of quats, needs to be a two power length
%vector
% using slrp
range = size(diffquats);
if(range(1) ~= 4)
error 'quaternions must be 4 row vectors'
end
@simonlynen
simonlynen / ROS_odroid
Last active December 16, 2015 15:59
ROS odroid
#use some preinstalled ubuntu and activate swap:
http://wiki.ubuntuusers.de/Swap#Swap-als-Datei
#install some packages:
sudo apt-get update
sudo apt-get build-dep libcppunit-dev autoconf automake autotools-dev dh-autoreconf doxygen libtool m4 -y
sudo apt-get install python-nose python-empy python-sip-dev python-sip -y
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev liblog4cxx10-dev liblog4cxx10 libbz2-* wx-common libwxgtk2.8-dev libgtest* swig -y
@simonlynen
simonlynen / dd status
Last active December 16, 2015 19:09
dd status
sudo dd ... &
ps auxww |grep " dd " |grep -v grep |awk '{print $2}' |while read pid; do sudo kill -USR1 $pid; done
@simonlynen
simonlynen / git_branch_and_color
Last active January 29, 2016 11:00
git color and show branch
git config --global color.ui "auto"
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}