Skip to content

Instantly share code, notes, and snippets.

View JEnoch's full-sized avatar

Julien Enoch JEnoch

View GitHub Profile
@JEnoch
JEnoch / main.rs
Created December 28, 2023 11:49
Test `git2::Repository::revparse_single()`
use std::path::Path;
fn main() {
use git2::Repository;
let url = "https://github.com/not-an-aardvark/every-git-commit-shorthash.git";
let repo_dir = Path::new("./target/every-git-commit-shorthash");
let repo = if repo_dir.exists() {
if repo_dir.is_dir() {
@JEnoch
JEnoch / z_replay.py
Last active May 9, 2023 17:33
A Zenoh Python script that queries a time-series Storage (typically InfluxDB) for past publications and replay them
#
# A Zenoh Python script that queries a time-series Storage (typically InfluxDB)
# for past publications and replay them
#
import sys
import time, datetime
import argparse
import json
import zenoh
@JEnoch
JEnoch / zigbee-ros2-teleop.py
Created February 16, 2023 10:12
A Zenoh python script demonstrating ROS2 + Zigbee/MQTT integration
# This script is an example of ROS2 + Zigbee/MQTT integration thanks to Zenoh.
#
# By default, it assumes that:
# - a zenoh-bridge-dds is deployed and routes the ROS2 traffic to zenoh. It's configured to use "simu" as a scope.
# - a zenoh-bridge-mqtt is deployed and routes the MQTT traffic coming from zigbee2mqtt software
#
# This script can connect to any Zenoh endpoint using the "-e" option (a Zenoh router, the zenoh-bridge-dds or the zenoh-bridge-mqtt).
# Then it performs the following:
#
# - It subscribes in Zenoh to "zigbee2mqtt/device/button" to receive JSON messages from zigbee2mqtt when a Zigbee push button named "device/button" is pressed.
@JEnoch
JEnoch / ros2-teleop.py
Created December 16, 2022 10:21
ros2-teleop.py using 'cyclonedds' instead of 'pycdr'
import sys
from datetime import datetime
import argparse
import curses
import zenoh
import json
from dataclasses import dataclass
from cyclonedds.idl import IdlStruct
from cyclonedds.idl.types import int8, int32, uint32, float64
@JEnoch
JEnoch / 2022-16-06-Webinar.md
Last active December 13, 2022 21:19
Webinar 06/12/2022: ROS2 Robot-to-Anything with Zenoh

Turtlebot3 simulation demo

Setup

On a Ubuntu VM in your prefered cloud:

  • zenohd:
    • wget https://download.eclipse.org/zenoh/zenoh/0.6.0-beta.1/x86_64-unknown-linux-gnu/zenoh-0.6.0-beta.1-x86_64-unknown-linux-gnu.zip
    • unzip zenoh-0.6.0-beta.1-x86_64-unknown-linux-gnu.zip
  • Optional (to serve the HTML page):
  • sudo apt install apache2
@JEnoch
JEnoch / zenoh-bridge-dds-downsampling.md
Created September 20, 2021 21:02
zenoh/DDS bridge: downsampling of periodic topics

Bridging the DDS traffic over a constrained connectivity (in throughput and/or number of message per second) might require to perform downsampling of some periodic DDS publications.

A new option for this purpose have been introduced in the new IAC2 branch of the zenoh bridge for DDS: --periodic-topics <topics_regex>=<period_in_ms>

Example of usage

Assuming you need to bridge the following topics over UDP, and want to ensure a minimal period between each re-publication (period values here are just examples and might not be relevant):

@JEnoch
JEnoch / publisher.c
Created July 8, 2021 13:26
CycloneDDS TRANSIENT_LOCAL helloworld
// NOTE: modified version of
// https://github.com/eclipse-cyclonedds/cyclonedds/tree/c261053186c455abc63ca5ac7d56c0808a59c364/examples/helloworld
#include "dds/dds.h"
#include "HelloWorldData.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
@JEnoch
JEnoch / zenoh-chat.html
Created June 24, 2021 07:44
A simple HTML/Javascript chat using zenoh REST API
<dl>
<dd>
<p>
Chat via zenoh!<br>
<form id="connect-form">
URL of zenoh router's REST API:
<input id="router_url" type="text" required value="http://localhost:8000">
<input type="submit" value="connect"
class="w3-button w3-round w3-border w3-padding-small w3-theme-d1 w3-right w3-section"
onclick="return subscribeChatroom();"><br>