Skip to content

Instantly share code, notes, and snippets.

View mpkuse's full-sized avatar

Manohar Kuse mpkuse

View GitHub Profile
@mpkuse
mpkuse / main.py
Created January 19, 2021 11:09
Python ROS (rospy) dealing with rotation matrix and transformations
from tf.transformations import quaternion_matrix #Return homogeneous rotation matrix from quaternion.
from tf.transformations import quaternion_from_matrix #Return quaternion from rotation matrix.
from tf.transformations import quaternion_multiply
"""
>>> dir( tf.transformations )
['Arcball', '_AXES2TUPLE', '_EPS', '_NEXT_AXIS', '_TUPLE2AXES', '__builtins__', '__doc__', '__docformat__', '__file__', '__name__', '__package__', '_import_module', 'arcball_constrain_to_axis', 'arcball_map_to_sphere', 'arcball_nearest_axis', 'clip_matrix', 'compose_matrix', 'concatenate_matrices', 'decompose_matrix', 'division', 'euler_from_matrix', 'euler_from_quaternion', 'euler_matrix', 'identity_matrix', 'inverse_matrix', 'is_same_transform', 'math', 'numpy', 'orthogonalization_matrix', 'projection_from_matrix', 'projection_matrix', 'quaternion_about_axis', 'quaternion_conjugate', 'quaternion_from_euler', 'quaternion_from_matrix', 'quaternion_inverse', 'quaternion_matrix', 'quaternion_multiply', 'quaternion_slerp', 'random_qu
@mpkuse
mpkuse / rosbag_images_to_compressedimages.py
Last active November 12, 2020 14:24
rosbag Convert all raw images to compressed images. All other topics are copied from input bag to output bag
#!/usr/bin/env python
"""Convert all raw images to compressed images. All other topics are copied from input bag
to output bag
USAGE:::
python image_raw_to_compressed.py _bag:=/home/ttekep/data/gtsam/random2.bag
"""
import rospy
@mpkuse
mpkuse / CMakeLists.txt
Last active November 9, 2020 08:56
Ros Quickies
cmake_minimum_required(VERSION 2.8.3)
project(roveo_sensor_calibration)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
@mpkuse
mpkuse / opencv-filestorage.cpp
Created December 5, 2019 04:18
OpenCV 3 Read Write FileStorage YAML Example
//
// OpenCV provides an easy class interface for read and write cv::Mat
// can also use these with Eigen by converting eigen mat to cv::Mat using
// cv::cv2eigen() and cv::eigen2cv()
// Writing to file
cv::FileStorage storage("test.yml", cv::FileStorage::WRITE);
storage << "img" << img;
storage.release();
import cv2
import numpy as np
def convert_3x3_1x1__to__4x4(fname, outfname, outvarname ):
## READ YAML OPENCV
print( 'fname: ', fname )
fs = cv2.FileStorage(fname, cv2.FILE_STORAGE_READ)
@mpkuse
mpkuse / README.md
Last active June 6, 2019 02:16
tx2 load keras model with custom layer
@mpkuse
mpkuse / ImageNetLabels.cpp
Created June 3, 2019 09:31
ImageNet Labels C++ Class
#pragma once
#include <iostream>
#include <string>
class ImageNetLabels {
public:
ImageNetLabels()
{
@mpkuse
mpkuse / 1-Flat.cpp
Last active May 17, 2019 03:14
Linking faiss in your Cmake projects
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <cstdio>
#include <cstdlib>
@mpkuse
mpkuse / 1_pyserial.py
Last active January 31, 2019 11:10
NMEA0183 (GPS) and Python
import serial
import pynmea2
import collections
def signal_handle( sig, frame ):
# Save JSON
import json
with open( '/home/mpkuse/try/gps_nmea/data.json', 'w' ) as outfile:
json.dump( ARY, outfile )
exit(0)
@mpkuse
mpkuse / rosbag_to_image.py
Created December 14, 2018 09:53
ROS bag to images
import rosbag
from cv_bridge import CvBridge, CvBridgeError
import cv2
# Input : A ros-bag
# Output : Save the image msg as individual images. Edit as appropriate.
bag = rosbag.Bag('banana.bag')
for topic, msg, t in bag.read_messages(topics=['/mynteye/right/image_raw']):
# print msg