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 / 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_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 / 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 / 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 / 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 / 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():