Wednesday, June 15, 2016

Controlling MeArm Robot arm from an android device

I recently bought a MeArm robot arm and assembled.


This consists of 4 servo motors to control base, shoulder, elbow and gripper. Later I found "MeArm Controller" android application and decided to configure arduino bluetooth module to complete my setup.

Following is the breadboard view of my configuration.


I found it bit hard to configure the android app for the first time hence decided to note down configuration steps below.

1. Turn bluetooth on and open the application.






















2. Press the settings icon (triangle just below Reset button). This should take you to the following screen.




















3. Press the Connectivity button.




















4. Then tap on the bluetooth icon and select the correct address.
Now you should get a screen saying connected :)























5. Select the slider mode then provide Servo IDs.




















6. Press OK and you should get a screen similar to the following, where you have controls to the 4 servo motors.




















Here is my messy robot arm config,


Arduino sketch: (Credit to the original creator- I have only  modified baudrate for the bluetooth module)


Wednesday, June 8, 2016

Measure performance of a given JavaScript code

console.time("for loop");
for(var i=0; i < 100; i++){
  console.log("i is: " + i);
}
console.timeEnd("for loop");

Wednesday, April 27, 2016

How to add git branch name to the command line

How many times you run the git branch command to find out which branch you in?

Following will help you to overcome above hassle and have a quick glance at your branch name.



1. Open /home/<USER>/.bashrc file.
2. Add following to the bashrc, save and exit.
parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt
3. Open a new terminal window and browse your git repo :)

Friday, April 22, 2016

First shot with the AF_Motor Library

I had to use an Arduino motor shield as a HAT on a uno board, powered by four 1.2V rechargeable batteries, to power-up two DC motors. ( Yes, juice provided by arduino is not enough to power two motors )

 
























Since this is my first library usage, I had to find out how to install a library in my workspace and decided to note the steps as a reference here.

Howto Install the Library-

1. Download the library, in my case AF_Motor from
https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master.

2. Unzip and rename to motorsheild and copy in to the sketchbook libraries directory. (Create libaries directory, if not exists)
Eg:- /home/udara/sketchbook/libraries/ directory.

Why Rename: Default library name(adafruit-Adafruit-Motor-Shield-library-89a0973), contains hyphen(-) characters which causes library pickup issue during IDE startup.



3. Start/Restart IDE.

Hint: Browse File> Examples, you should see motorsheild sample sketches.

Sunday, April 3, 2016

how to resolve "M: bad interpreter" while working with bash scripts

This is a common problem if you try to port a script created in windows environment to unix,
 /bin/bash^M: bad interpreter: No such file or directory
How to solve this,

run dos2unix <BASH_SCRIPT>
Eg:- dos2unix run.sh

For further information: http://www.linuxcommand.org/man_pages/dos2unix1.html

Wednesday, March 2, 2016

Getting HTTP response back from a CURL POST request

CURL request:
curl -H "Content-Type: application/json" -H "Authorization: Basic <AUTH_VALUE>" -X POST -d '<BODY_CONTENT>' <EP_URL> -k -i

Sample request:

curl -H "Content-Type: application/json" -H "Authorization: Basic YWRtaW46YWRtaW" -X POST -d 'MBfcEW/91R0VTobzhbC0ZGjGvHN4c9OXFsbByP8s9IwJErS5FVAgOhzxAJCLh3tfl0MJad5joQ7X5jl7mAzy40Rjv6Pe4wVghjVjdmofYL/fuX8m/pToUmvWc9t7S4DER31lGPBrlWEpEtIk/Nj025Xm5/cvAsUXpuTvLeOYt5v+cYHHmNtulG1dEfzMYQbjTQ1W/TVvWHG8LUfdXvVXt0R3QI6r/DnVszVIOKDbpD7OdKkLQ9J7W4kOSDZL1euIaSaWfLr0l+K0M+Eme1jG9np/qmNXOGZZyXR+ETpGuPDASV3TVK9hXKH18COwQ//e0db+6bGSPLPIb1KcshKIz4xZ3z15OaXDHRzZx71gFO4raVYIQAbxlx0wSw/D2Ap1qkXvBYFGIqAW+NPzVCGu/8Vu9BaUcSBZ5v1v4RKstWHKmaRTlRpRs0i1uEBoZHuw3sCN+HWLeIIjjNcWpNs3L1E1H/Wzny3uxwiPqZolA4LsnRj8kY5yJ1FoqNFs+i2lPqUvLhQZMCvPCF+on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8SazMqEgzhL4LPsV6bFX9pSN8nb9PiI/6sXq2sTGIdN/czqrRE7j/xBywhvcZXA9g+8yiUnZKwJ5YQkoAIKCySh0auw19/GqaU4bwt3TPBuomW3UTdHE=' https://localhost:9443/endpoints/PageLogEventReceiver -k -i

Sample response: 

HTTP/1.1 401 Unauthorized
Set-Cookie: JSESSIONID=B083D193C0722F2CA8021BA2021BA4F0; Path=/; Secure; HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Length: 14
Date: Wed, 02 Mar 2016 16:30:48 GMT
Connection: close
Server: WSO2 Carbon Server

_AUTH_FAILURE_