Skip to content

Instantly share code, notes, and snippets.

@oak-tree
oak-tree / motor.cpp
Last active November 24, 2019 16:30
motor
// in this example the position mode will be selected and started, after the input 1 is triggered, the motor moves to a set position (flagposition mode)
//1. Step: mapping the frequently used SDO´s
map U16 ControlWord as output 0x6040:00
map U32 ProfileVelocity as output 0x6081:00
map S32 TargetPosition as output 0x607A:00
map U32 Inputs as input 0x60FD:00
map S32 ActualPosition as input 0x6064:00
map S32 AnalogInput as input 0x3320:01
map S08 HomingMethod as output 0x6098:00
@oak-tree
oak-tree / video_builder.py
Created March 4, 2020 12:42
create video from all jpeg in current folder
image_height,image_width,_ =cv2.imread(os.listdir()[0]).shape
output_path = os.path.join(os.getcwd(), "result.avi")
video_size = image_width, image_height
video_fps = 5
video_size = image_width, image_height
video_FourCC = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter(output_path, video_FourCC, video_fps, video_size)
for i in sorted(os.listdir()):
#include <stdio.h>
#include <assert.h>
inline cudaError_t checkCuda(cudaError_t result)
{
if (result != cudaSuccess) {
fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result));
assert(result == cudaSuccess);
}
return result;
import tensorflow as tf
import os
import time
import numpy as np
import matplotlib.pyplot as plt
from tensorflow import keras
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
@oak-tree
oak-tree / realtime.cpp
Created August 16, 2022 10:20
realtime
void SetRealTimePriority() {
int ret;
pthread_t this_thread = pthread_self();
// used to store the scheduling priority
struct sched_param params;
// set the priority to the maximum.
params.sched_priority = sched_get_priority_max(SCHED_FIFO);
LOG(INFO) << "Trying to set thread realtime prio = " << params.sched_priority << std::endl;
// Attempt to set thread real-time priority to the SCHED_FIFO policy
ret = pthread_setschedparam(this_thread, SCHED_FIFO, &params);