Skip to content

Instantly share code, notes, and snippets.

@srathi-monarch
srathi-monarch / wc.py
Created August 7, 2023 06:24
Node to count the number of messages on topics.
#! /usr/bin/env python3
from sys import argv
import rospy
def cb(msg, cb_args):
counters, i = cb_args
counters[i] += 1
@srathi-monarch
srathi-monarch / fake_clock.cpp
Last active August 1, 2023 06:56
(Unnecessarily complicated?) fake clock publisher for ROS
#include <ros/ros.h>
#include <rosgraph_msgs/Clock.h>
template <typename T> auto to_ros(const T &t) {
auto dur = std::chrono::duration_cast<std::chrono::nanoseconds>(t);
return std::make_pair(int32_t(std::chrono::duration_cast<std::chrono::seconds>(dur).count()),
int32_t(dur.count() % 1000000000UL));
}
int main(int argc, char **argv) {
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="SubstitutionType">
<xs:restriction base="xs:string">
<xs:pattern value="$\(anon .*|$\(arg .*|$\(dirname .*|$\(env .*|$\(eval .*|$\(find .*|$\(optenv .*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BoolType">
<xs:union memberTypes="SubstitutionType">
@srathi-monarch
srathi-monarch / .clang-format
Created July 12, 2023 08:31
The default clang-format config used in clion
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
@srathi-monarch
srathi-monarch / .zshrc.local.zsh
Last active July 31, 2024 13:34
Zsh config to be used on top of GRML zsh config. Includes ros, fzf.
xmodmap -e "keysym Print = Menu" 2> /dev/null
# Setup Paths
export PATH="${PATH}:${HOME}/.local/bin:${HOME}/.cargo/bin"
export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:${HOME}/.local/opt/glibc/glibc232/lib
export PATH=$PATH:/home/srathi/.spicetify
@srathi-monarch
srathi-monarch / rosmode.zsh
Created June 27, 2023 06:29
Disable fzf for roscompletion
alias ros='touch ~/.roscomp && zsh ; exit'
export FZF_DEFAULT_OPTS="--reverse"
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh
if [ ! -f ~/.roscomp ] ; then
source /home/srathi/.local/share/fzf-zsh-completion.sh # Breaks ROS Completion
else
rm ~/.roscomp
fi