Scratch Positioning Issue

I’ve been trying to get my head around the motor positioning command in Scratch. My DI software update has been done today, as has the Dexter Software and the Brick Pi 3 Robot. I’m trying to get the little LEGO dude to simply drive in a square, but when I put in Motor A position 90 it will do all sorts of things sometimes doing 5 full circles, sometimes turning about 180 degrees sometimes turning random other degrees. What am I missing here - I don’t expect it to be exact, but the way it is at present I cannot suggest to other teachers to try this as it will just end in frustration. Is there another way to program IN SCRATCH to get the robot to turn fairly accurately a certain number of degrees? The motor moving forward is fine with both motors working in unison and progressing for however many seconds I say. This position thing is a project stopper, but I’m hoping I’m just missing something. Any support would be greatly appreciated.

Hello @shabysheik1,
the behaviour will indeed change depending on the state of the robot. Position 0 will be where the robot was booted up from. If it had gone forward quite a bit, you can “unwind” the motors to go back to position 0.

What I think you’re trying to achieve, and correct me if I’m wrong, is having the motors move by a certain number of wheel rotations. Is that correct?

If so, you have to read the current encoder position, add the number of degrees that you want your motor to turn, and then use set motor position.
It is not available in a single block.

Hope this helps.

Hi again Cleoqc I cannot find a SET MOTOR POSITION block or command or even series of blocks that will allow me to reset the sensor value. I can certainly have the cat tell me the sensor value, but how do I then reset it? I appreciate your patience…

Hi Cleo

I cannot see a set motor position in SCRATCH, nor anything that I could combine to get the motor to spin for an assigned variable number of turns. I can read the position value, but cannot seem to apply it to any broadcast attribute. I hope this makes sense.

Shane

My apologies for not answering right away, I was away for a bit.
It is not a specific block, but a broadcast command that you have to enter.

Broadcast MOTOR A POSITION 180 for example

Cleo

Hi,

we tried the set motor position today and found a strange behaviour:
The motor would turn almost to the right position and then continue back and forth.
We added a say block that showed the current position and the value would circle around the desired value (e.g. when we tried to set it to 180 it would be 181, 178, 182, …)

I tried the same thing from python with a similar result. How do I set the absolute position correctly?

Is there a solution to this or no. I have had similar problems using positioning. It do nt seem to work conisitently. I tried using a block that takes the encoder value and adds 10 to it and having another that adds -10 to go the other way. It sometimes works for a couple tries and then does not. If I reboot, I can do the same thing and it stops working the same. Also, in the motor example program in scratch, there are these displayed variables for sensor one value and status and motor a value and status. How can I make others for motor b, c, d and other sensors?
Thanks,
Tim Cooper

If you are using the BrickPi3 and the motor is oscillating while using position control, try updating the firmware. There was an error in the firmware prior to 1.4.6 that resulted in the motors oscillating.

Matt

Matt the issue is that position in scratch becomes a really big number really quickly – all I wanted to do was tell the motor to turn 90 degrees. As the position value is continually progressing this is not really the best option.

shaby

Setting the target position is absolute. If you set the target to 90 degrees, it will attempt to run to the 90-degree position. If it’s at 360 when you issue the command, it will run backwards 270 degrees to get to 90. If it’s at -45 when you issue the command, it will run forwards 135 degrees to get to 90. Is this what you are experiencing?

If you want relative rotation, do as cleoqc suggested. Read the current position, add the relative rotation you want, and set that as the target position.

The encoder value is in degrees. 1 rotation is 360 degrees. 100 rotations is 36,000 degrees. If you want to deal with smaller numbers, you can divide the degrees by 360 to get rotations.