Skip to content

Instantly share code, notes, and snippets.

View lukicdarkoo's full-sized avatar

Darko Lukić lukicdarkoo

View GitHub Profile
@lukicdarkoo
lukicdarkoo / labelme2yolo.py
Created August 15, 2020 20:18
LabelMe to YOLO
"""
Converts LabelMe annotations to annotations compatible with YOLO.
The script does the following:
- cleans (!) the output directory and prepare it for training,
- splits the dataset on validation and training,
- converts all LabelMe annoations (*.json) to YOLO annoations (*.txt) and
- creates YOLO metadata (`.data`, `.names`, `train.txt` and `valid.txt`)
"""
import os
@lukicdarkoo
lukicdarkoo / uwb.py
Last active August 29, 2020 21:37
UWB Follower
# pip3 install pyserial
import time
import serial
import rclpy
import threading
from rclpy.node import Node
from std_msgs.msg import Int32
@lukicdarkoo
lukicdarkoo / rospm.sh
Last active April 22, 2020 19:38
Simple ROS Package Helper
# Quick start
# Install dependencies: pip3 install rosinstall_generator vcstool colcon-common-extensions; sudo -H pip3 install rosdep
# Install the script: curl https://gist.githubusercontent.com/lukicdarkoo/d03196b15367b804b27c142dad8644e9/raw/503201cc3b2a86c61dfb4f3cf1cc761cbc096bff/rospm.sh >> $HOME/.bashrc; exec bash
rospm-install() {
# This tool combines `rosinstall_generator`, `vcs` and `colcon` to
# easily install package in a custom ROS workspace
# Set default parameters
PACKAGE_NAME=$1
@lukicdarkoo
lukicdarkoo / nmea0138.c
Last active September 13, 2019 08:44
NMEА0183 sentence parser
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
const char PROPRIETARY = 'P';
const char MANUFACTURER_IDENTIFIER[] = "UWV";
#define NMEA0183_OUT_OF_RANGE -1
@lukicdarkoo
lukicdarkoo / hamming.c
Created September 10, 2019 22:06
Hamming Error Correction
// Reference: https://www.geeksforgeeks.org/hamming-code-in-computer-network/
#include <inttypes.h>
#include <stdio.h>
#include <assert.h>
#define PRINT_BITS(x) \
for (int i = sizeof(x) << 3; i; i--) \
putchar('0' + (((x) >> (i - 1)) & 1)); \
@lukicdarkoo
lukicdarkoo / circbuff.c
Last active September 10, 2019 09:00
Bit-aware circular buffer
#include "circbuff.h"
void circbuff_init(circbuff_t *circbuff) {
circbuff->end_bit = 0;
circbuff->end_byte = 0;
circbuff->start_bit = 0;
circbuff->start_byte = 0;
}
uint8_t circbuff_size(circbuff_t *circbuff) {
@lukicdarkoo
lukicdarkoo / isa.py
Created August 22, 2019 12:14
EPFL: Notify when a course state is changed on IS-Academia
import sys
import time
import smtplib
import logging
from pyquery import PyQuery
from requests_html import HTMLSession
logging.basicConfig(filename='isa.log', format='[%(asctime)s] %(message)s', filemode='w', level=logging.INFO)
logger = logging.getLogger('isa')
@lukicdarkoo
lukicdarkoo / nmea0183.py
Created August 20, 2019 12:07
NMEА0183 sentence parser
import re
from functools import reduce
def nmea0183_create(arguments, proprietary='P', manufacturer_identifier='UWV'):
"""
Create NMEА0183 sentence
Parameters
----------
@lukicdarkoo
lukicdarkoo / configure.sh
Created July 30, 2019 09:32
USB OTG Console for Armbian
sudo su
echo 'g_serial' >> etc/modules
echo 'ttyGS0' >> etc/securetty
echo 'echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role' > etc/init.d/otg_config.sh
chmod +x etc/init.d/otg_config.sh
@lukicdarkoo
lukicdarkoo / demodulation.c
Last active November 11, 2023 01:38
QAM modulation in C without complex library
#include <math.h>
#include <stdio.h>
typedef struct _complex {
double imag;
double real;
} complex_t;
const int SAMPLE_RATE = 160E3;
const float FREQUENCY = 40E3;