Scratch 3 seems to only have commands to start one motor at a time for X seconds. With two motors, one at each wheel, how do I tell both motors to go for a while so the robot moves forward?
Put two "received [message name] message" events and attach a motor control block to each of them.
Related
He only moves a little bit and not moves forever
The (move 10 steps) block will only move your player by a tiny bit. It moves in the direction that your sprite is facing.
If you would like to have it moving for a longer period of time, (and smoother), I'd recommend using a loop of some kind.
Putting a Forever() loop around it will have it always move forward.
Repeat(number of times to repeat) will move it forward however many times you want.
Try to experiment with more of these loops and see which one best fits your project and goals.
You have multiple options. The first is to put the 'move 10 steps' block into a forever loop, so you code goes like the first one in the image and that will make your sprite move 10 blocks until the stop button is pressed.
Or alternatively, you could use a repeat (no. of times to repeat) block, like the second one:
Two Block Options
That's all!
I want simulate an inverted pendulum via Simcape. For this, i created a Model with SolidWorks and tranformed it to Simscape. So far so good. Everything worked and my Simulation shows the predicted physical Behavior.
But now i want to add a dc motor to my simulation, which is hooked to the sledge via belt.
I tried to connect the dc motor block with the revolute joint of the pulley, but it seems Matlab has some issues with it. It shows the error shown below.
Further you can see my simscape modell of my inverted pendulum and how i connectet the Dc motor block to the revolute jo
Has anybody an idea how to connect the dc motor correctly or is there somthing wrong with my simscape model?
I´m kind of running out of ideas and I´m gratefull for any help I can get.
enter image description here
It says one of your componenet that needs to rotate, is strictly connected to the world. I believe you need yo change that.
I am going to control 4 wh raspberry robot in Simulink. I found this one to control DC motor with simulink: https://www.mathworks.com/matlabcentral/fileexchange/41528-raspberry-pi-dc-motor-h-bridge-driver-block-sfunction?s_tid=srchtitle It is just for a one motor. My question: is it possible to build a simulink model for 4wheeled robot car by this model? I understood that, by changing to - or + value of block constant motor will drive anticlockwise or clockwise. How to be to turn left or right? It doesn't like Python or C programming, so it's stopped project. Especially for Simulink, any idea or suggestions would be greatly approtiated! Thank you so much in adwance!
I added images which i meant in comment. I am a newbie, so please, don't judge me quality)
enter image description here
enter image description here
Recently, in a project for school. I have come across an increasingly frustrating and what seems to be an unsolvable problem. Whilst attempting to create a diving game, in which the sprite of a diver (sprite x) touches clones of a fish sprite (referred to as y by me) to rack up scores as high as 25. While the mechanisms for diver movement appear to be completely fine. However, loading the game would result in no reaction from the fish and its clones. I had already programmed the clones of the fish sprites to hide and delete themselves if touching sprite x. However, the fish refused to clone itself even after many attempts at rewriting the script. I would like to know if there was anything I missed or screwed up. Thank you. And these are the images of the respective scripts of the sprites in links below. Thank you.
Here's your problem:
WHEN I RECEIVE "start game"
WAIT (2) SECS
REPEAT (25)
CREATE CLONE OF "myself"
WAIT (6) SECS
BROADCAST "game over"
You're starting the game, waiting 2 seconds, cloning the fish 25 times, and then ending the game.
There's at least one issue here, and probably another.
First of all, you're cloning all of the sprites into the exact same spot. The clones are piling on top of each other, giving the appearance of only being one fish, since they're all in the exact same space. I'd advise moving to a random x and y on the stage in between each clone.
Second, you have BROADCAST "game over" immediately there. This works if this is the way you're implementing a time limit on the game, but otherwise, you're just ending the game 6 seconds after the last fish appears.
So, correcting these two things, you end up with something like this:
WHEN I RECEIVE "start game"
WAIT (2) SECS
REPEAT (25)
GO TO X: ([RANDOM PICK (-200) TO (200)]) Y: ([RANDOM PICK (-150) TO (150)])
CREATE CLONE OF "myself"
WAIT (6) SECS
If you want each fish to disappear after 6 seconds, then add a DELETE THIS CLONE to the above script.
You can delete this script:
That's now covered by the other script, above, and is also slightly buggy. It's kinda useless now.
And, in your other script, the one starting WHEN GREEN FLAG CLICKED... to have the fish disappear when touching the diver, replace the WHEN GREEN FLAG clicked with a WHEN I START AS A CLONE.
I want to write a code for my Ev3 robot with two motors. I want it to be able to go a certain distance, in this case forward until the motors have turned a maximum of 2500 degress for four seconds. Then I want the robot to go back the same distance. But the problem is that sometimes only one motor spins while the other does nothing and sometimes a motor will continue to spin long after it has returned to its original position. I wonder if there is any way I can improve the code I have. I have tried it on several different Ev3 equitment so it is most likely not a hardware problem. Any help would be appreciated :)
b = Brick('ioType','usb');
b.outputStepSpeed(0,Device.MotorA,60,0,2500,0,Device.Brake);
b.outputStepSpeed(0,Device.MotorD,60,0,2500,0,Device.Brake);
pause(4)
b.outputStop(0,Device.MotorA,Device.Brake);
b.outputStop(0,Device.MotorD,Device.Brake);
tacho = b.outputGetCount(0,Device.MotorA);
disp(['> Tachometer: ' num2str(tacho)]);
b.outputClrCount(0,Device.MotorA);
b.outputClrCount(0,Device.MotorD);
pause(0)
b.outputStepSpeed(0,Device.MotorA,-60,0,tacho,0,Device.Brake);
b.outputStepSpeed(0,Device.MotorD,-60,0,tacho,0,Device.Brake);
pause(4)
b.outputStop(0,Device.MotorA,Device.Brake);
b.outputStop(0,Device.MotorD,Device.Brake);
tacho =
b.outputGetCount(0,Device.MotorA);
disp(['> Tachometer: ' num2str(tacho)]);
b.outputClrCount(0,Device.MotorA);
b.outputClrCount(0,Device.MotorD);
clear
do check if your ports are correct and if they are connected. Do also know that not all EV3 motors are manufactured perfectly the same which means some can be stronger, making it almost impossible to move straight. Using a gyro might help out in this case.
Do comment if you need further help!