Skip to content

Instantly share code, notes, and snippets.

View patrickelectric's full-sized avatar
🏡
Working from home

Patrick José Pereira patrickelectric

🏡
Working from home
View GitHub Profile
@patrickelectric
patrickelectric / pub-sub-ros.md
Last active July 25, 2022 21:56
My personal investigation on the pub/sub frameworks around the world!

ROS

Long and love-rate (more rate than love) relationship, take mostly of this review with a grant of salt.

Great tools, libraries and projects

ROS (started in 2010) have some great tools visualize topics, send and debug messages, check frequencies, and much more. It's also possible to use more advanced tools and solutions like: rviz, gmapping, rtabmap, stereo_image_proc and the list goes on. With ROS, it's possible to take advantage of all drivers that exist for different pieces of hardware. Keep in mind that this is possible, but not easy, usually the drivers need specific configuration, custom settings and may give as output really complex data that needs to be processed or analyzed by another program.

Bureaucratic

ROS uses [catkin](https://github.com

@patrickelectric
patrickelectric / temporary_cache.py
Created April 18, 2022 17:29
Decorator that creates a cache for specific inputs with a configured timeout in seconds, useful for REST APIs
import time
from functools import wraps
from typing import Any, Callable, Dict
def temporary_cache(timeout_seconds: float = 10) -> Callable[[Callable[[Any], Any]], Any]:
"""Decorator that creates a cache for specific inputs with a configured timeout in seconds.
Args:
timeout_seconds (float, optional): Timeout to be used for cache invalidation. Defaults to 10.
@patrickelectric
patrickelectric / elefante.vue
Created May 3, 2021 18:43
Vue3 loader example
<template>
<span class="example">{{ msg }} - {{ potatoFunction() }}</span>
</template>
<script>
export default {
data () {
return {
msg: 'elefante!',
color: 'red',
}
@patrickelectric
patrickelectric / rtsp.py
Created April 20, 2021 15:58
rtsp factory python stream
import sys
import gi
sys.path.insert(0, "/usr/local/lib/python3.8/dist-packages")
print(sys.path)
#gi.require_version('Gst', '1.0')
from gi.repository import Gst, GstRtspServer, GObject
loop = GObject.MainLoop()
echo "potato, this's simple.sh!"
echo "Yes, 'it' is!"
{
"vehicles": [
{
"id": 1,
"components": [
{
"id": 1,
"messages": {
"RANGEFINDER": {
"type": "RANGEFINDER",
// https://steamcommunity.com/app/648800/discussions/0/1694922526906474288/
// https://www.saveeditonline.com/
Arrow_Stone - 186 - 0xba
Bow - 185 - 0xb9
#include <cstdint>
#include <cstdio>
namespace version_helper {
/**
* @brief Create the header sequence with checksum based in a string
*
* @tparam Type: Desired type of header
* @tparam N: Size of string
* @return Type: Header sequence created with checksum
@patrickelectric
patrickelectric / camera.xml
Created September 16, 2020 16:28
mavlink camera description file for QGC
<?xml version="1.0" encoding="UTF-8" ?>
<mavlinkcamera>
<definition version="1">
<model>HD Pro Webcam C920</model>
<vendor>HD Pro Webcam C920</vendor>
</definition>
<parameters>
<parameter name="camera-mode" type="uint32" default="1" control="0">
<description>Camera Mode</description>
<options>
@patrickelectric
patrickelectric / hunter_pylinter.sh
Created September 2, 2020 17:49
Find all pylint checks that are failing and print human friendly name for pylintrc
#!/usr/bin/env bash
keys=( $(pylint $(git ls-files '*.py') | rg '.*py:\d+:\d+: (.*):.*' -r '$1' | sort | uniq) )
msgs=( $(pylint --list-msgs | rg ":(.*) \(([A-Z]\d+)\).*" -r '$1,$2' | sort) )
for msg in "${msgs[@]}"; do
for key in "${keys[@]}"; do
if [[ $msg == *"$key" ]]; then
echo "${msg::-5}"
fi
done