Skip to content

Instantly share code, notes, and snippets.

View Veilkrand's full-sized avatar

Alberto Veilkrand

View GitHub Profile
@Veilkrand
Veilkrand / shop.html
Last active April 23, 2023 08:17
Front store template for the Django+Stripe tutorial in Medium
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Django+Stripe Tutorial">
<meta name="author" content="Alberto NG based on Bootstrap example templates">
<title>My Shop - Frontstore</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/pricing/">
@Veilkrand
Veilkrand / install_python37.bash
Last active November 21, 2022 00:05
Install Python3.7 in Ubuntu 16.04
## For Ubuntu 16.04 Xenial
# Install Python3.7
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
# Create virtual environment with python3.7
tf::Transform
ArucoMapping::arucoMarker2Tf(const aruco::Marker &marker)
{
cv::Mat marker_rotation(3,3, CV_32FC1);
cv::Rodrigues(marker.Rvec, marker_rotation);
cv::Mat marker_translation = marker.Tvec;
cv::Mat rotate_to_ros(3,3,CV_32FC1);
rotate_to_ros.at<float>(0,0) = -1.0;
rotate_to_ros.at<float>(0,1) = 0;
@Veilkrand
Veilkrand / gist:23c3859c45e216b3ac7319321ef5ce1b
Created February 12, 2019 02:11
Unwrapping angles to [-pi,pi]
## Using Numpy functions result should be [-pi,pi]
import numpy as np
phases = np.arctan2(np.sin(phases), np.cos(phases))
## equivalen to:
phases = np.angle(np.exp(1j*phases))
## Modulo approach
phases = (( -phases + np.pi) % (2.0 * np.pi ) - np.pi) * -1.0
## Programmatic approach in C++
'''
/** this conversion uses conventions as described on page:
* https://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm
* Coordinate System: right hand
* Positive angle: right hand
* Order of euler angles: heading first, then attitude, then bank
* matrix row column ordering:
* [m00 m01 m02]
* [m10 m11 m12]
* [m20 m21 m22]*/
@Veilkrand
Veilkrand / gist:29d3a79acbf44489a9a8d6c711b38b80
Created January 9, 2019 02:56
Upstream PX4+Mavros install

New PX4 work space

  1. Install Mavros in ~/px4_ws/src http://dev.px4.io/en/ros/mavros_installation.html
  2. Clone Firmware in ~/px4_ws/src. git clone --recursive https://github.com/PX4/Firmware
  3. Create virtual link for sitl_gazebo package in ~/px4_ws/src: ln -s Firmware/Tools/sitl_gazebo mavlink_sitl_gazebo
  4. Catkin build
  5. Fix Gazebo paths:
export GAZEBO_MODEL_PATH=$HOME/px4_ws/src/mavlink_sitl_gazebo/models
export GAZEBO_RESOURCE_PATH=$HOME/px4_ws/src/mavlink_sitl_gazebo/worlds
<launch>
<include file="$(find raspicam_node)/launch/camera_module_v2_640x480_30fps_autocapture.launch" />
<node name="web_video_server" pkg="web_video_server" type="web_video_server" output="screen"/>
</launch>
@Veilkrand
Veilkrand / install_ros_ubuntu_mate.sh
Last active September 14, 2018 05:09
Install script for ROS Kinetic for Ubuntu Mate (Xenial) RPI3. I doesn't build and source catkin workspace. I includes packages for perception and dron mavlink.
#!/bin/sh
# Source
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update
# Install ros packages and dependencies
sudo apt -y install ros-kinetic-desktop-full ros-kinetic-rqt python-rosinstall ros-kinetic-mavros ros-kinetic-web-video-server ros-kinetic-aruco-ros ros-kinetic-vision-opencv ros-kinetic-video-stream-opencv ros-kinetic-uvc-camera ros-kinetic-usb-cam ros-kinetic-test-mavros ros-kinetic-rviz-visual-tools ros-kinetic-rostopic ros-kinetic-roslaunch python-rosinstall python-rosinstall-generator python-wstool build-essential ros-kinetic-pyros python-rosdep
# Init and source installation
#!/usr/bin/env python
import math
import rospy
from sensor_msgs.msg import Image, JointState
from simple_arm.srv import *
class LookAway(object):
def __init__(self):
#!/usr/bin/env python
import math
import rospy
from std_msgs.msg import Float64
from sensor_msgs.msg import JointState
from simple_arm.srv import *
def at_goal(pos_j1, goal_j1, pos_j2, goal_j2):
tolerance = .05