Skip to content

Instantly share code, notes, and snippets.

View fxprime's full-sized avatar

ArduinoNa ขายอุปกรณ์ Arduino, เครื่องมือช่าง, raspberry pi, สอน ROS fxprime

View GitHub Profile
@fxprime
fxprime / rosbag_to_video.py
Created April 23, 2023 15:52
Convert rosbag to video with .avi format, Usage rosbag_to_video.py [ROSBAG.bag] [OUTPUT.avi]
#!/usr/bin/env python
import sys
import rospy
import rosbag
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
def save_images_from_rosbag(rosbag_file, topic_name, output_file):
@fxprime
fxprime / calibrate_fisheye_camera.py
Created April 23, 2023 14:53
calibrate_fisheye_camera using KB8 for VI
import cv2
#assert cv2.__version__[0] == '3', 'The fisheye module requires opencv version >= 3.0.0'
import numpy as np
import os
import glob
CHECKERBOARD = (7,10)
subpix_criteria = (cv2.TERM_CRITERIA_EPS+cv2.TERM_CRITERIA_MAX_ITER, 30, 0.1)
calibration_flags = cv2.fisheye.CALIB_RECOMPUTE_EXTRINSIC+cv2.fisheye.CALIB_CHECK_COND+cv2.fisheye.CALIB_FIX_SKEW
# calibration_flags = cv2.fisheye.CALIB_RECOMPUTE_EXTRINSIC+cv2.fisheye.CALIB_FIX_SKEW
objp = np.zeros((1, CHECKERBOARD[0]*CHECKERBOARD[1], 3), np.float32)
@fxprime
fxprime / bag_to_images.py
Created April 21, 2023 12:53 — forked from wngreene/bag_to_images.py
Extract images from a rosbag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Extract images from a rosbag.
"""
import os
import argparse
/**
*
*/
const int dirPin = 8;
const int stepPin = 9;
const int enablePin = 7;
const int sw = 6;
const int delayMicros = 500; //Delay between each step
const int maximumSteps = 230;
@fxprime
fxprime / DRV8825_accelStepper.ino
Last active January 8, 2023 09:34
Control single stepper motor using DRV8825 with library AccelStepper
#include <AccelStepper.h>
const int StepPin = 9;
const int DirPin = 8;
const int EnablePin = 7;
AccelStepper stepper(AccelStepper::DRIVER, StepPin, DirPin, 0, 0, true);
@fxprime
fxprime / DRV8825_stepper_motor.ino
Created January 7, 2023 09:00
Control single stepper motor without library
const int dirPin = 8;
const int stepPin = 9;
const int enablePin = 7;
void setup() {
pinMode(enablePin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(enablePin, LOW);
/**
ตัวอย่างการใช้ PS2 Wireless กับ Arduino
PS2X_lib
ในการอ่านค่า joy PS2 ของร้าน Modulemore
โดยต่อ
UNO R3 --- > PS2 adapter
GND - GND
5v - VCC
D3 - DAT
D4 - CMD
/**
* Smart farm simple version
* Control 2 motor with RC remote
* Right horizontal stick control throttle
* Left vertical stick control steering
* Created by : ModuleMore.com
*/
#include <Arduino.h>
/* -------------------------------------------------------------------------- */
/* ModuleMore AM2306 (Modbus) Example code */
/* -------------------------------------------------------------------------- */
/* ------------------------------- วิธีการต่อ ------------------------------- */
/**
* ESP8266 ---> MAX485 ---> AM2306
* 5V 5V RED
* GND GND BLACK
* - RE (ต่อกับDE)
/* -------------------------------------------------------------------------- */
/* ModuleMore AM2306 (Modbus) Example code */
/* -------------------------------------------------------------------------- */
/* ------------------------------- วิธีการต่อ ------------------------------- */
/**
* ESP8266 ---> MAX485 ---> AM2306
* 5V 5V RED
* GND GND BLACK
* - RE (ต่อกับDE)