Skip to content

Instantly share code, notes, and snippets.

View awesomebytes's full-sized avatar

Sam Pfeiffer awesomebytes

View GitHub Profile

Compile Kernel with PREEMPT_RT

When following https://docs.ros.org/en/foxy/Tutorials/Miscellaneous/Building-Realtime-rt_preempt-kernel-for-ROS-2.html

I built this in a VM using the Ubuntu ubuntu-20.04.5-desktop-amd64.iso. I needed to provide the VM with 7GB of RAM to avoid OOM (out of memory) errors. I needed to provide it with 60GB of storage space (Ubuntu installation needs short of 7GB and the kernel compilation seems to need over 40GB, plus testing the .deb installation it fills the disk).

39G	linux-5.15.73
8.2M	linux-headers-5.15.73-rt52_5.15.73-rt52-8_amd64.deb
84M	linux-image-5.15.73-rt52_5.15.73-rt52-8_amd64.deb
1.2G	linux-image-5.15.73-rt52-dbg_5.15.73-rt52-8_amd64.deb
1.2M	linux-libc-dev_5.15.73-rt52-8_amd64.deb
@awesomebytes
awesomebytes / image_flip.py
Created October 17, 2022 00:55
ROS Image stream camera flip either horizontally, vertically or both via OpenCV
#!/usr/bin/env python
import sys
import rospy
from sensor_msgs.msg import Image, CompressedImage
import numpy as np
import cv2
from cv_bridge import CvBridge, CvBridgeError
"""
@awesomebytes
awesomebytes / how_to_publish_rostopic_pub_launchfile.md
Last active July 20, 2022 02:25
rostopic pub in a launchfile with a complex message (PointCloud2)

How to publish with rostopic pub in a launchfile with a complex message

Using the dictionary syntax: http://wiki.ros.org/ROS/YAMLCommandLine#Command-line_and_messages_.28dictionaries.29 We avoid the problem of requiring double quotes inside of the args field. (I found no way to realiably escape the quotes, for double quote I used " and for single quote I used ' but I still was getting errors).

<launch>
    <!-- Publishing a dummy empty pointcloud (but with x y z fields described to avoid
    errors like: Failed to find match for field 'x'. ) -->
    <node name="dummy_pointcloud_pub" pkg="rostopic" type="rostopic"
@awesomebytes
awesomebytes / message_filter_over_rosbag.py
Last active July 15, 2024 14:32
message_filters ApproximateTimeSynchronizer over a rosbag (without roscore or /use_sim_time)
#!/usr/bin/env python
import itertools
import sys
import time
import rospy
import rosbag
import message_filters
"""
Example using a message_filters filter (ApproximateTimeSynchronizer) iterating
@awesomebytes
awesomebytes / nvidia_cuda_fail_workaround.md
Last active May 16, 2023 09:21
Nvidia CUDA driver not working after suspend or hibernation workaround

How to reset the GPU to use CUDA after suspend or hibernation

I needed to do:

sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm

From the nvidia forums.

I also got the following error fixed (docker-nvidia related) with these commands:

# How to play audio from inside a docker container
```bash
# Run your docker image with
-v /run/user/$UID/pulse/native:/run/user/$UID/pulse/native \
-e PULSE_SERVER=unix:/run/user/$UID/pulse/native
```
And you can try to use `speaker-test`.
This was found here: https://stackoverflow.com/a/28995539

Datestamp

DATESTAMP=$(date +"%Y_%m_%d_%H_%M")
@awesomebytes
awesomebytes / 0001-Apply-https-github.com-PointCloudLibrary-pcl-pull-38.patch
Created September 8, 2021 06:08
Apply https://github.com/PointCloudLibrary/pcl/pull/3853 from Davide Faconti to improve Voxelgrid runtime by 20% to 1.8.1 tag (backport)
From 466e0f57b15e11ab19af900341f98a726ad1bf73 Mon Sep 17 00:00:00 2001
From: Sammy Pfeiffer <[email protected]>
Date: Wed, 8 Sep 2021 16:06:44 +1000
Subject: [PATCH] Apply https://github.com/PointCloudLibrary/pcl/pull/3853 from
Davide Faconti to improve Voxelgrid runtime by 20% to 1.8.1 tag (backport)
---
filters/include/pcl/filters/impl/voxel_grid.hpp | 7 +++++--
filters/src/voxel_grid.cpp | 6 ++++--
2 files changed, 9 insertions(+), 4 deletions(-)
@awesomebytes
awesomebytes / rostopic_republisher_rate.py
Created August 31, 2021 01:08
Rostopic public republisher (at higher or lower rate)
#!/usr/bin/python2
import rospy
import rostopic
import argparse
import threading
# Borrowed from https://chaonan99.github.io/2018/rostopic-republish/
global g_msg
g_msg = None
function yawAngleFromQ(time, value, v1, v2, v3)
M_PI = 3.14159265358979323846
a = v1
b = v2
c = v3
d = value
aa = a * a
ab = a * b
ac = a * c