Skip to content

Instantly share code, notes, and snippets.

View plusk01's full-sized avatar

Parker Lusk plusk01

View GitHub Profile
@plusk01
plusk01 / snippet.cpp
Last active August 7, 2019 21:22
ROS sensor_msgs PointCloud2 from cv::Mat
void reverse_memcpy(unsigned char* dst, const unsigned char* src, size_t n)
{
for (size_t i=0; i<n; ++i)
dst[n-1-i] = src[i];
}
// ----------------------------------------------------------------------------
sensor_msgs::PointCloud2 cloudmsg;
cloudmsg.header.stamp = _img->header.stamp;
@plusk01
plusk01 / lastbag.sh
Last active November 24, 2019 04:27
#!/bin/bash
# Given a directory with at least one bag file, find the filename with the
# latest timestamp (%Y-%m-%d-%H-%M-%S) in name and open it with `rqt_bag`.
# This is particularly useful given a directory of many rosbags that were
# created via `rosbag record` without an explicit filename.
# If the files were created with `rosbag record -o <name>`, then <name>
# will be appended with a timestamp, in which case the latest of *these*
# bags can be found with `./lastbag <name>`.
#
# Parker Lusk
@plusk01
plusk01 / nonoverlapping_random_circles.sh
Last active January 3, 2020 18:54
Sample non-overlapping circles from a uniform square - useful for initialization of multiple objects
#!/bin/bash
function draw_uniform {
# generates a random float in [a b)
# n.b.: a, b must be ints
a=$1
b=$2
echo "$((a+RANDOM%(b-a))).$((RANDOM%999))"
}