Skip to content

Instantly share code, notes, and snippets.

@clalancette
clalancette / ziptest.cc
Last active May 19, 2024 10:47
libzip example to create archive
// Copyright (c) 2018, Chris Lalancette
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
@clalancette
clalancette / delete-lunar
Created July 10, 2019 14:14
groovy script to delete lunar
import hudson.model.Cause
count = 0
for (p in Jenkins.instance.allItems) {
if (
(
p.name.startsWith("lunar_") ||
p.name.startsWith("Lsrc_") ||
p.name.startsWith("Lbin_") ||
@clalancette
clalancette / delete-indigo
Last active July 10, 2019 16:01
groovy script to delete indigo
import hudson.model.Cause
count = 0
for (p in Jenkins.instance.allItems) {
if (
(
p.name.startsWith("indigo_") ||
p.name.startsWith("Isrc_") ||
p.name.startsWith("Ibin_") ||
@clalancette
clalancette / disable-lunar
Created July 10, 2019 14:17
groovy script to disable lunar jobs
import hudson.model.Cause
count = 0
for (p in Jenkins.instance.allItems) {
if (
(
p.name.startsWith("lunar_") ||
p.name.startsWith("Lsrc_") ||
p.name.startsWith("Lbin_") ||
@clalancette
clalancette / disable-indigo
Last active July 10, 2019 16:01
groovy script to disable indigo jobs
import hudson.model.Cause
count = 0
for (p in Jenkins.instance.allItems) {
if (
(
p.name.startsWith("indigo_") ||
p.name.startsWith("Isrc_") ||
p.name.startsWith("Ibin_") ||
@clalancette
clalancette / ros-sync-remove-dbgsym.py
Created September 11, 2019 13:37
Python script to remove dbgsym packages from ROS sync notices and recalculate package numbers
#!/usr/bin/python3
import sys
if len(sys.argv) != 3:
print("Usage: %s <input> <distro>" % (sys.argv[0]))
sys.exit(1)
infile = sys.argv[1]
distro = sys.argv[2]
@clalancette
clalancette / xacro-launch.py
Created December 5, 2019 18:45
Using xacro with ROS 2 python launch
The goal here is to be able to use the ROS 2 python launch system to generate URDF files from xacro files, utilizing substitution. All of the comments below are an attempt to solve this problem.
# Robot state publisher
In order to make this work, it is easiest to use the refactored robot_state_publisher branch https://github.com/ros/robot_state_publisher/tree/ros2-refactor . The reason for this is that the refactor takes the `robot_description` as a parameter rather than as an argument on the command-line. This branch isn't currently reviewed or released into any ROS 2 distribution, so it needs to be built from source. (I'll note that it is probably *possible* to make all of this work with the version of robot_state_publisher released into Eloquent, but the rest of this comment will assume you are using the ros2-refactor branch).
```
source /opt/ros/eloquent/setup.bash
mkdir -p rsp_ws/src
cd rsp_ws/src
git clone https://github.com/ros/robot_state_publisher -b ros2-refactor
@clalancette
clalancette / get_unique_node_name
Created December 5, 2019 19:49
Alternative implementation of get_unique_node_name for https://github.com/ros2/geometry2/pull/182
std::string get_unique_node_name()
{
const static std::string chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static std::random_device rd;
static std::minstd_rand g{rd()};
// The uniform_int_distribution takes a closed interval of [a, b]; since that
// would include the \0, we remove one from our string length.
static std::uniform_int_distribution<std::string::size_type> pick(0, chars.length() - 1);
@clalancette
clalancette / clang-tidy.bash
Created January 6, 2020 16:04
clang-tidy bash script to check ROS 2 packages
#!/bin/bash -xe
# FIXME: arguments to ignore certain files
usage() {
echo "Usage: $0 [OPTIONS]"
echo " OPTIONS:"
echo " -a <arg> Add any additional arguments to the clang-tidy command-line"
echo " -c <arg> Skip additional checks"
echo " -h Show this help message"
@clalancette
clalancette / end_to_enu
Last active January 28, 2020 15:58
NED to ENU
#include <cmath>
#include <cstdio>
#include <tf2/LinearMath/Matrix3x3.h>
#include <tf2/LinearMath/Quaternion.h>
void print_quat(double x, double y, double z, double w)
{
tf2::Quaternion quat(x, y, z, w);
fprintf(stderr, "Quaternion:\n");