Skip to content

Instantly share code, notes, and snippets.

View mhdadk's full-sized avatar

Mahmoud Abdelkhalek mhdadk

View GitHub Profile
import numpy as np
def unwrap_theta(theta: float, prev_theta: float, range: float) -> float:
"""
Description
------------
unwrap_theta removes a discontinuous jump in theta by comparing it to prev_theta.
If |theta - \prev_theta| < (range/2), then we don't do anything to theta, since it
is within the correct range of prev_theta. Otherwise, if
@mhdadk
mhdadk / webcam_capture.cpp
Created August 4, 2023 13:25 — forked from sammy17/webcam_capture.cpp
Simple C++ program to capture a webcam frame in Linux
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/v4l2-common.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <fcntl.h>
#include <unistd.h>
@mhdadk
mhdadk / CMakeLists.txt
Created June 4, 2023 20:15 — forked from jarvisschultz/CMakeLists.txt
Simple Float32MultiArray +Eigen Demo
cmake_minimum_required(VERSION 3.5.1)
project(matrix_demo)
find_package(catkin REQUIRED
rospy
roscpp
std_msgs
)
include_directories(
@mhdadk
mhdadk / read_wav.py
Last active February 16, 2021 07:12
Read frames of a WAV file using the wave package in Python
import wave
"""
Generator of frames of byte strings of an audio file.
Arguments:
path (string): .wav file path.
frame_length_sec (float): length of frame in seconds. Common values are in the range [0.01,0.05].
frame_overlap (float): number between 0 (inclusive) and 1 (exclusive) representing the fraction of overlap between consecutive frames. Note
that the generator will get stuck if you input an overlap of 1.