Square Dance Rotation Program Lego
One of the first questions asked by a Lego NXT user/owner is 'How do I make my robot rotate by 90 degrees?' Indeed a simple question, but one that leads to great confusion. Of course after understanding more about the programming blocks we discover that rotation of the robot gets translated to rotation of the robot's motor. Furthermore we discover that 90 degrees rotation of a motor does not yield to 90 degrees rotation of the robot.
Could there be an easier way to rotate the robot? Then answer of course is, yes.
How rotations are generated by the Square Rotation Program. For each tip, the program proceeds as follows: If the number of 'ready' couples is not a multiple of 4. Welcome to SplitChainer SplitChainer is a program to rotate square dancers into squares, easy and fair. No matter whether on club evening or a larger Square Dance.
The purpose of this blog entry is to provide one solution to abstract motor rotation to robot rotation for the NXT robot. For simplicity we assume that your robot is using a left and right hand side motors, and rotation is on the robots center axis. By this I mean the left and righ hand motors will opperate on opposite directions to obtain rotation.
First Abstraction The first and most basic approach is to run both motors at the same time (in parallel) and rotate the motors in opposite directions by the same number of degrees as illustrated in the sequence image below. The number of degrees of motor rotation is obtained by trial and error. Once the correct angle is found create a My Block containing the two blocks, name this new block ROTATIONv1.rbt. Watch out the NXT Software sometimes rearranges the blocks. Rearrange so that the look as shown in the image above. With these steps you have successfully abstracted rotation of the robot by 90 degrees.
Second Abstraction Now that we have a way of rotating the robot by 90 degrees it would be nice to rotate it by any angle. Writing the motor rotation angle value for each motor might lead to errors or mistakes. This next step deals with preventing this error. For this we create a variable, we'll called it degrees. On the sequence panel add the writing and reading blocks for this variable as shown in the image to the right. Connect the wires as shown so that the variable value is feed into the rotation of both motors.
Select only motors C and B and create a new My Block. This will allow for an input into the new My Block. Name the new block ROTATIONV2.rbt The finished block sequence should look as shown in the image below. Notice this block provides for an input of the motor rotation angle.
Final Abstraction The previous abstraction will only allow right rotations. A negative number will not yield a left rotation. To deal with both left and right rotation we must identify if the input angle is either positive or negative to make the motors rotate in opposite directions. Use a Comparison block to find out if the number is greater than zero. Take the output of the Comparison block and feed it into the input of a Logical block set to NOT operation. The output of the Comparison block gets feed into the direction of the C motor while the output of the Logic block gets feed into the direction of motor B. The resulting sequence should look as follow.
Square Rotation Program (SQROT) Technical Details SQROT 5.16 (January 2018) is the latest version Download - Sample screens - How rotations are generated by the Square Rotation Program. For each tip, the program proceeds as follows:. If the number of 'ready' couples is not a multiple of 4, the program determines who will sit out by selecting couples who have sat out the fewest number of times, using a ratio of number of tips danced vs. Number of tips sat out. If several couples have the same ratio, couples to sit out will be selected at random from those couples. A random rotation is generated. The following procedure is repeated until no more changes are possible or until the user clicks the 'abort process' button:.
For each pair of couples, a value is calculated indicating how often those two couples have danced together. This value is then subtracted from the optimal number of times that the couples should have danced together.
The resulting value is then squared. All values are added together to produce a 'chi-square-like' statistic. Two couples (in different squares) are swapped within the rotation and the chi-square statistic is recalculated.
If the new statistic is less than the old statistic, the new rotation is saved, otherwise, the previous rotation is restored. The process continues until the program has tried swapping every couple with every other couple and no decrease has occurred within the statistic. Square numbers are then assigned and 'optimized' in a similar manner (also using a 'chi-square' statistic) so that dancers move around between different squares on the floor. 18-February-2018 13:17:18 Copyright ©.
Job Rotation Program
All Rights Reserved.