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 / spawn_two_urdf_robots.launch.py
Created March 23, 2023 14:44
Spawn two robots from URDF files, without robot_state_publisher node (spawn_entity.py script with argument -file instead of -topic)
import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.substitutions import Command, LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
@rfzeg
rfzeg / how_to_install_turtlebot3_simulation.md
Created February 24, 2023 17:12
How to install a turtlebot3 ROS simulation.

If neccesary:

sudo apt-get update
sudo apt-get upgrade

Then:

cd ~/catkin_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git -b noetic-devel
@rfzeg
rfzeg / print_number_of_laser_rays.py
Last active May 29, 2023 19:10
ROS2: Retrieve the total number of laser rays using the python interpreter (adjust topic name if neccesary)
import rclpy
from sensor_msgs.msg import LaserScan
from rclpy.qos import ReliabilityPolicy, QoSProfile
def scan_callback(msg):
global g_node
g_node.get_logger().info('Number of rays: "%d"' % len(msg.ranges))
g_node.get_logger().info('Angle of first ray: "%.2f"' % msg.angle_min)
g_node.get_logger().info('Angle of last ray: "%.2f"' % msg.angle_max)
g_node.get_logger().info('Total angular area of coverage: "%.2f"' % (msg.angle_max-msg.angle_min))
@rfzeg
rfzeg / CMakeLists.txt
Last active November 30, 2022 14:25
Python launch file to start a simulated world and include sdf models (does not spawn robot)
cmake_minimum_required(VERSION 3.8)
project(my_package)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
@rfzeg
rfzeg / launch_simulation_world_and_xacro_file.py
Created March 16, 2022 08:16
ROS2 launch file for simulation, world, xacro robot description and robot_state_publisher
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
from ament_index_python.packages import get_package_prefix
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.conditions import IfCondition
@rfzeg
rfzeg / ros2_gazebo_and_urdf_robot.launch.py
Last active September 9, 2023 09:00
ROS2 launch Gazebo and spawn URDF robot using Execute Process
"""Launch Gazebo server and client with command line arguments."""
"""Spawn robot from URDF file."""
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration
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
@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 / 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 / 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
"""