Skip to content

Instantly share code, notes, and snippets.

View rfzeg's full-sized avatar

Roberto Zegers R. rfzeg

  • The Construct
  • Aachen, Germany
View GitHub Profile
@rfzeg
rfzeg / publishers_from_launch_ file.txt
Last active March 5, 2021 11:27
ROS publisher from launch file
ROS Marker publisher:
Step 1: Transform Yaml file into Python dict notation.
Alternative 1, online tool:
A useful tool which will shows the result in Python notation of any YAML input is:
https://yaml-online-parser.appspot.com/
Make sure to remove excess single quotes (') and new lines.
Alternative 2, use a python :
@rfzeg
rfzeg / .bashrc
Created February 19, 2020 10:05
Promt the user to source the ROS distro and catkin workspace in each new terminal window.
# Allow for ROS source choice, paste this it in the user configuration file (.bashrc)
read -p "Do you want to source the ros_ws workspace in this new terminal window? (y/n): " input_choice
if [ "$input_choice" = "y" ]
then
echo "ROS sourced!"
# Source the distro specific setup file
source /opt/ros/kinetic/setup.bash
# Change ROS editor to nano
export EDITOR='nano -w'
@rfzeg
rfzeg / remap.cpp
Created May 1, 2019 02:56
remap c++
#include <iostream>
float remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax)
{
float fromAbs = fromValue - fromMin;
float fromMaxAbs = fromMax - fromMin;
float normal = fromAbs / fromMaxAbs;
float toMaxAbs = toMax - toMin;
@rfzeg
rfzeg / least_squares.cpp
Last active April 6, 2019 08:27
Implementation of least squares algorithm to fit a circle to a set of points
#include "least_squares.h"
#include <math.h>
/****************************************************************************
Least squares fit of circle to set of points.
by Dave Eberly ([email protected] or [email protected])
ftp://ftp.cs.unc.edu/pub/users/eberly/magic/circfit.c
---------------------------------------------------------------------------
Input: (x_i,y_i), 1 <= i <= N, where N >= 3 and not all points
are collinear
@rfzeg
rfzeg / start_rviz.launch
Created April 6, 2019 06:14
Launch file start Rviz option
<!-- By default, start RViz -->
<arg name="rviz" default="true" />
<!-- Run Rviz and load the default config to see the state of the move_group node -->
<include file="$(find package)/launch/moveit_rviz.launch">
<include if="$(arg rviz)" file="$(find package)/launch/moveit_rviz.launch">
<arg name="config" value="true"/>
<arg name="debug" value="$(arg debug)"/>
</include>
@rfzeg
rfzeg / gazebo_models.txt
Last active September 24, 2020 11:39
Add Gazebo environment variables to allow access to Gazebo models
0. First check what is the output of "echo $GAZEBO_MODEL_PATH"
What is the output of "echo $GAZEBO_MODEL_PATH"?
1. Run from command line to grant access to models once:
(Tip: cd to the ros package with roscd, then use pwd command to get the full path)
export GAZEBO_MODEL_PATH=~/simulation_ws/src/logistic_demo_sim/models:$GAZEBO_MODEL_PATH
2. To permanently enable Gazebo to locate gazebo model files (SDF's):
@rfzeg
rfzeg / cham_bot.urdf
Created January 24, 2019 10:38
cham-bot
<?xml version="1.0"?>
<robot name="cham_bot">
<link name="z_axis">
<visual>
<geometry>
<box size="0.2 0.2 6.5"/>
</geometry>
<origin rpy="0 0 0" xyz="0.25 0 7"/>
#!/usr/bin/python
#################################################################
##\file
#
# \note
# Copyright (c) 2010 \n
# Fraunhofer Institute for Manufacturing Engineering
# and Automation (IPA) \n\n
#
#################################################################
@rfzeg
rfzeg / one_hot_encode.py
Created October 1, 2018 10:34
One hot encode a list of sample labels. Return a one-hot encoded vector for each label.
def one_hot_encode(labels):
"""
One hot encode a list of sample labels. Return a one-hot encoded vector for each label.
: x: List of sample Labels
: return: Numpy array of one-hot encoded labels
"""
# TODO: Implement Function
depth = 10
one_hot = np.eye(depth)[labels]
@rfzeg
rfzeg / normalize_grayscale.py
Created October 1, 2018 09:56
Normalize a grayscale image with Min-Max scaling to a range of [0.1, 0.9]
def normalize_grayscale(image_data):
"""
Normalize the image data with Min-Max scaling to a range of [0.1, 0.9]
:param image_data: The image data to be normalized
:return: Normalized image data
"""
# Implement Min-Max scaling for grayscale image data
a = 0.1
b = 0.9
grayscale_min = 0