Skip to content

Instantly share code, notes, and snippets.

View abhikpal's full-sized avatar

Abhik Pal abhikpal

View GitHub Profile
@abhikpal
abhikpal / convert_to_png.py
Created August 9, 2017 07:19
Convert SVG images in a folder to PNG.
import os
import sys
image_folder = sys.argv[1] if len(sys.argv) == 2 else '.'
folder_path = os.path.abspath(image_folder)
svg_images = [os.path.abspath(f) for f in os.listdir(folder_path) if f.endswith('.svg')]
for image_file in svg_images:
filename, ext = os.path.splitext(image_file)
os.system("inkscape -z -e {}.png {}".format(filename, image_file))
import pyglet
pyglet.options['shadow_window'] = False
window = pyglet.window.Window()
print("OpenGL info:")
print(window.context.get_info().get_version())
print(window.context.get_info().get_renderer())
print(window.context.get_info().get_vendor())
@abhikpal
abhikpal / frame_buffer_test.py
Last active July 2, 2017 18:09
Check if the machine supports frame buffers.
import pyglet
required_extensions = [
'GL_ARB_framebuffer_object',
'GL_EXT_framebuffer_object',
'GL_EXT_framebuffer_blit',
'GL_EXT_framebuffer_multisample',
'GL_EXT_packed_depth_stencil',
]
//
// PIN MAPPINGS
//
const int num_relays = 8;
const int relays[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int input_pin = A0;
const int input_threshold = 50;
//
const int num_relays = 8;
const int relays[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int duration = 1000;
void setup() {
for (int i = 0; i < num_relays; i++) {
pinMode(relays[i], OUTPUT);
digitalWrite(relays[i], HIGH);
}
/*
* LIGHT AVOIDER ROBOT
*
* A simple Arduino based obstacle avoider robot that uses two light dependent resistors to
* measure the amount of light in its environment and then move to the area with less light.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
/*
* LINE FOLLOWER ROBOT
*
* An Arduino based robot that uses an infrared sensor array to follow a line.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
*/
/*
* Callibration sketch for the accelerometer.
*
* Simply prints out the values from the x, y, and z axes to the serial monitor. These values can be
* used to calibrate the sensor.
*
* To use this code with the tilt controlled robot, keep the accelerometer flat and then record the
* readings for x and the y axes. The calibrated_x and calibrated_y in the tilt-robot sketch should
* be set to these base values.
*
/*
* BASIC ARDUBOT
*
* A simple Ardubot that demonstrates a basic set of movements.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
*/
@abhikpal
abhikpal / ardubotics-joystick-robot.ino
Created September 29, 2016 02:48
Arduino based joystick controlled robot.
/*
* Joystick Controlled Robot
*
* An arduino based robot that can be controlled using an analog joystick.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
*/