Skip to content

Instantly share code, notes, and snippets.

# Reading from a MCAP file
# sudo apt install ros-$ROS_DISTRO-ros-base ros-$ROS_DISTRO-ros2bag ros-$ROS_DISTRO-rosbag2-transport ros-$ROS_DISTRO-rosbag2-storage-mcap
from mcap import __version__
print(__version__)
"""script that reads ROS2 messages from an MCAP bag using the rosbag2_py API."""
import argparse
from rclpy.serialization import deserialize_message
from rosidl_runtime_py.utilities import get_message
@horverno
horverno / circle.cpp
Created June 17, 2022 07:37
cpp ROS circle
#include <visualization_msgs/Marker.h>
#include <math.h>
///....
ros::Publisher circ_marker_pub = n.advertise<visualization_msgs::Marker>("pure_circle", 1);
///....
#!/usr/bin/env python
import sys
import os
import struct
import numpy as np
import rospy
from std_msgs.msg import Header
from sensor_msgs.msg import Image, CompressedImage, CameraInfo, PointCloud2, PointField
from image_geometry import PinholeCameraModel
#!/usr/bin/env python
## PYTHON2
# subscribes to PointCloud2, transforms to "map" and saves as npy
import rospy
from sensor_msgs.msg import PointCloud2
import sensor_msgs.point_cloud2 as pc2
import numpy as np
@horverno
horverno / quickdemo.py
Created October 26, 2018 15:18
Aruco marker-based OpenCV distance measurement
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import sys
import numpy as np
sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')
import cv2
import cv2.aruco as aruco
import numpy as np
import rectangleArea as ra