Skip to content

Instantly share code, notes, and snippets.

View PeterMitrano's full-sized avatar
🔬

Peter Mitrano PeterMitrano

🔬
View GitHub Profile
@PeterMitrano
PeterMitrano / read_bagfile_ros2_python.py
Created February 16, 2023 18:31
One way to read a bagfile from python in ros2
def open_bagfile(bagfile: Path):
reader = rosbag2_py.SequentialReader()
storage_options = rosbag2_py.StorageOptions(bagfile.as_posix())
converter_options = rosbag2_py.ConverterOptions("cdr", "cdr")
reader.open(storage_options, converter_options)
topic_types = reader.get_all_topics_and_types()
# Create a map for quicker lookup
type_map = {
@PeterMitrano
PeterMitrano / setup.py
Created January 17, 2023 05:25
Yolov7 setup.py
#!/usr/bin/env python
from distutils.core import setup
setup(name='yolo',
version='1.0',
description='yolo v7',
author='',
author_email='',
url='',
@PeterMitrano
PeterMitrano / aws_setup.sh
Last active October 20, 2021 19:03
AWS setup
# NOTE: if using this outside ec2, you will need to copy your ~/.aws/credentials into the computer first
sudo apt update
sudo apt install -y g++ build-essential cmake git htop tree tmux curl openssh-server imagemagick maim vim-gtk3 i3 python3-pip python3-virtualenv libappindicator3-dev castxml qt5-style-plugins trash-cli checkinstall gparted net-tools rename libreadline-dev imagemagick policykit-1-gnome
sudo apt upgrade
git config --global user.email "peter@`echo $HOSTNAME`"
git config --global user.name "peter"
sudo apt-get install ubuntu-drivers-common
@PeterMitrano
PeterMitrano / motion_planning_tutorial.cpp
Created September 17, 2021 18:51
y-shaped robot pose goal(s)?
#include <ros/ros.h>
#include <moveit/kinematic_constraints/utils.h>
#include <moveit/planning_interface/planning_interface.h>
#include <moveit/planning_pipeline/planning_pipeline.h>
#include <moveit/planning_scene_monitor/planning_scene_monitor.h>
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/robot_state/conversions.h>
#include <moveit_msgs/DisplayTrajectory.h>
#include <moveit_visual_tools/moveit_visual_tools.h>
#!/bin/bash
PS3='Choose a workspace type: '
options=("default" "debug")
select opt in "${options[@]}"
do
case $opt in
"default")
source /home/peter/catkin_ws/devel/setup.bash
cd /home/peter/catkin_ws/
catkin profile set default
@PeterMitrano
PeterMitrano / setup_catkin_ws.sh
Last active April 15, 2021 20:35
setup catkin ws
#!/bin/bash
source /opt/ros/noetic/setup.bash
mkdir catkin_ws
cd catkin_ws
mkdir src
cd src
sudo apt install python3-wstool python3-osrf-pycommon python3-catkin-tools
@PeterMitrano
PeterMitrano / ompl_python_is_satisfied
Created March 11, 2021 15:22
demo that is satisfied cannot be overridden in python
from functools import partial
from math import sin, cos
import numpy as np
from ompl import base as ob
from ompl import control as oc
class MySampleableGoalRegion(ob.GoalSampleableRegion):
@PeterMitrano
PeterMitrano / serialize_deserialize_rospy_python3
Created March 4, 2021 15:58
Quick example of how to serialize then deserialize a ROS msg in python 3
from io import BytesIO
from geometry_msgs.msg import Point
p = Point(x=2, y=4)
print(p)
buff = BytesIO()
p.serialize(buff)
serialized_bytes = buff.getvalue()
@PeterMitrano
PeterMitrano / naive_random_tree.py
Created February 21, 2021 03:41
Naive Random Tree Animation
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from matplotlib.animation import FuncAnimation
N = 100
a_max = 0.1
s = 1
@PeterMitrano
PeterMitrano / thread_test.py
Last active February 6, 2021 17:44
Example of a class with a thread
#!/usr/bin/env python
import threading
import time
import weakref
class BadRobot:
def __init__(self):
self.should_disconnect = False