Skip to content

Instantly share code, notes, and snippets.

View fxprime's full-sized avatar

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

View GitHub Profile
### ekf config file ###
ekf_filter_node:
ros__parameters:
# The frequency, in Hz, at which the filter will output a position estimate. Note that the filter will not begin
# computation until it receives at least one message from one of the inputs. It will then run continuously at the
# frequency specified here, regardless of whether it receives more measurements. Defaults to 30 if unspecified.
frequency: 25.0
# The period, in seconds, after which we consider a sensor to have timed out. In this event, we carry out a predict
# cycle on the EKF without correcting it. This parameter can be thought of as the minimum frequency with which the
import launch
from launch_ros.actions import ComposableNodeContainer, Node
from launch_ros.descriptions import ComposableNode
def generate_launch_description():
"""Launch file which brings up visual slam node configured."""
#include <i2cmaster.h>
#define uint16_t unsigned int
typedef struct
{
uint16_t Red;
uint16_t Green;
uint16_t Blue;
uint16_t Clear;
} RGB;
@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