Skip to content

Instantly share code, notes, and snippets.

View alifahrri's full-sized avatar
🌊

Fahri Ali Rahman alifahrri

🌊
View GitHub Profile
@alifahrri
alifahrri / vid2gif.md
Last active November 29, 2018 11:06
video to gif with ffmpeg
ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -f gif StickAround.gif

-ss 61.0 seek to 61.0 seconds
-t 2.5 only read 2.5 then stop

ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -filter_complex "[0:v] fps=12,scale=480:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" SmallerStickAround.gif
@alifahrri
alifahrri / rospy-cheat.md
Last active November 20, 2018 18:00
cheatsheet for rospy

get rospy.Time

now = rospy.Time.now()
now = rospy.get_rostime()
rospy.loginfo("Current time %i %i", now.secs, now.nsecs)

get time in seconds

now = rospy.get_time()
@alifahrri
alifahrri / gzlog.md
Last active November 20, 2018 09:34
gazebo data logger

playback in gui

gazebo -u -p ~/logs/double_pendulum/2016-01-25T15\:09\:49.677400/gzserver/state.log

from gazebo_ros

rosrun gazebo_ros gazebo --prefix '-u -p 2018-11-20T162127.065690/gzserver/state.log'
@alifahrri
alifahrri / roscpp-cheat.md
Created November 11, 2018 14:38
cheatsheet for roscpp

yaml

XmlRpc::XmlRpcValue my_list;
nh.getParam("my_list", my_list);
ROS_ASSERT(my_list.getType() == XmlRpc::XmlRpcValue::TypeArray);

for (int32_t i = 0; i < my_list.size(); ++i) 
{
  ROS_ASSERT(my_list[i].getType() == XmlRpc::XmlRpcValue::TypeDouble);
 sum += static_cast(my_list[i]);
@alifahrri
alifahrri / angle-wrap.py
Last active October 31, 2018 02:38
py code for wrapping around an angle
def norm_angle(dw) :
if math.fabs(dw) > math.pi :
return (-2*math.pi + dw) if dw > 0 else (2*math.pi + dw)
else : return dw
@alifahrri
alifahrri / cycheat.md
Last active October 28, 2018 04:54
cheatsheet for cython

setup.py

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)

all *.pyx files in a folder

@alifahrri
alifahrri / rpy-quat.md
Last active October 26, 2018 04:17
rpy <-> quaternion
#include <tf2/LinearMath/Quaternion.h>
#include <tf/transform_datatypes.h>
...
tf2::Quaternion myQuaternion;
myQuaternion.setRPY( 0, 0, 0 );  // Create this quaternion from roll/pitch/yaw (in radians)
ROS_INFO_STREAM(q);  // Print the quaternion components (0,0,0,1)
...
quaternionMsgToTF(quat_msg , quat_tf);

add breakpoint

(gdb) break filename.ext:line

list breakpoint

(gdb) info break

disable breakpoint

(gdb) disable 1 disable breakpoint 1

backtrace function call

(gdb) bt

examining the stack

@alifahrri
alifahrri / cuda_err_check
Created October 7, 2018 18:02
Error check for cuda code
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
@alifahrri
alifahrri / setup.sh
Created September 30, 2018 07:09
Install GTest
sudo apt-get install cmake libgtest-dev
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
# copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
sudo cp *.a /usr/lib