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 / 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 / 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 / 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 / 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 / .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 / 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 / point_cloud_visualization.py
Created March 19, 2021 09:11
ROS Rviz custom Point Cloud visualization example
#!/usr/bin/env python
"""
Rviz point cloud visualization marker example
Author: Roberto Zegers R.
Copyright: Copyright (c) 2021, Roberto Zegers R.
License: BSD-3-Clause
Date: March 2021
"""
@rfzeg
rfzeg / gazebo_simulation.launch.py
Created February 23, 2022 18:46
Minimal ROS2 launch file for Gazebo server and client using ExecuteProcess (command line arguments)
"""Launch Gazebo server and client with command line arguments."""
from launch import LaunchDescription
from launch.actions import ExecuteProcess
def generate_launch_description():
return LaunchDescription([
@rfzeg
rfzeg / include_gazebo_simulation.launch.py
Created February 23, 2022 19:04
Minimal ROS2 launch file via include and launch the gazebo.launch.py file.
"""Launch Gazebo server and client via include and launch the gazebo.launch.py file."""
import os
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
@rfzeg
rfzeg / launch_gazebo_world.launch.py
Last active March 10, 2022 21:51
ROS2 launch file that launches Gazebo including a Gazebo world
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource