Archive for March, 2010

Rudimentary object tracking

Tuesday, March 16th, 2010

While waiting for a PF Infra Red receiver so that i can automate the tracks, i decided to hook up a webcam and see what was easily possible. After a weekend of wasted time, i found a really easy solution – Roborealm for object tracking, which has a plugin so send standard NXT-G bluetooth messages to the NXT. More info to follow (probably…) but for now a quick vid:

360 Mechanical Arm

Wednesday, March 3rd, 2010

This project was inspired by the Lego Robotic Arm building contest on NXTLog, and also by my fascination with 360 tracked grabs – i used to work on a salvage yard and these machines are ridiculously flexible, and very intuitive to drive. The vid below shows a yard very much like the one i worked in, and demonstrates what i was trying to achieve.

Now, obviously that machine relies heavily on hydraulics, something we don’t get to play with using Lego Technics. I also have very little pneumatics, and to be honest most of it isn’t powerful enough for what i was doing. This meant i had to be pretty creative with the “transmission” for the open/close of the grab. I started at the grab end and simply worked my way down the arm, with no real overall plan and being mainly restrained by the size and shape of the NXT motors.






Control is using the Mindsensors PS2 interface, which allows you to plug a PS2 controller into the NXT, and use all the buttons, and both analogue sticks, with -100 to +100 reported on the X and Y axis for each stick. This makes proportionate motor control a cinch to program in NXT-G – just check if the reading is greater or less than 0 with a compare block, plug the output of that into Motor Direction. Run the reading through an absolute value maths block, and use that for motor power. Job done.

The actual code for control of the arm is a bit more complicated. The two NXT bricks communicate using NXT, with the “Master” connecting to the “Slave” using slot 1 in the NXT bluetooth menu – this needs to be connected before running the code – I tried using NXT-G blocks to automatically initiate the connection, but it didn’t always work, and there’s no easy way to check within the program whether the connection is up.


Left Stick Y-Axis: Shoulder – Forward on the stick moves the shoulder forward/down
Left Stick X-Axis: Waist rotation
Right Stick Y-Axis: Elbow – Forward on the stick moved the elbow forwards/up
Right Stick X-Axis: Wrist – Right on the stick moves wrist outwards

L1: Open Claw
R1: Close Claw
L2: Rotate claw Anti-clockwise
R2: Rotate claw Clockwise

The main controls match those used on real-world mechanical excavators.

The “Master” controls the Shoulder, Elbow and Wrist joints, on Motor ports C, B and A respectively. These use a block which is a slightly modified version of the code above, with a fixed “multiplier” for motor powers so movement remains consistent despite the different gear ratios. These are set to 1.0 for the Shoulder, 0.8 for the Elbow and 0.25 for the Wrist. All of the motor blocks are set to correct motor power, so even with a 0.25 power multiplier they will still use full power if the load on them is high – the NXT will increase the power if it’s not enough to give the expected movement speed. The code also has a “dead zone” of -15 to +15, as a “centered” ps2 analogue stick can report anywhere in this range (older pads are worse than newer ones, reporting -35 to +35 for some of the pads i’ve tried).

The code runs a constant loop, checking if the pad reading is inside the “dead zone”, if so it does nothing. If outside the dead zone, it compares to 0, converts to absolute value, multiplies by the constant and powers the motor, looping till the stick is back in the “dead zone”.

The “Slave” nxt controls Waist rotation, Wrist rotation and Claw on motors A, B and C respectively. The master nxt checks the PS2 pad and leaves a message in the mailbox for the “Slave” to check, the slave runs 3 constant loops, checking the mailboxes and acting accordingly.

Due to the worm gear used for opening/closing the claw, when the claw is rotated it also opens and closes slightly, as the claw rotates around the drive shaft for the worm gear. To counter this, the slave nxt turns the claw motor proportionately whenever the wrist is rotated, ensuring the grip stays the same.


Props to Mindsensors for making the PSP-NX V3 Playstation 2 interface for NXT, and Lego for making NXT.

So, what to put here then?

Wednesday, March 3rd, 2010

Somewhere to keep all my lego bits and pieces, and log the projects.