I wanted to create a robot that avoids obstacles using a radar.
The main robot on the left has a rotating laser.
This laser has the Scene.addCircle script on "on.laser.hit".
The position of the generated circles is with scaled and translated coordinates, this is the pos: = [(e.pos (0) / 8) + 56, e.pos (1) / 8];
The circles appear in the smaller version of the scene on the right side of the main playfied and reproduce what the robot on the left "sees".
The small yellow circle with 7 lasers on the right also follows the position and angle of the main robot, but reduced and scaled.
this is the script on postStep:
(e) => {
x = scene.my.pos0; // x main robot
y = scene.my.pos1; // y main robot
a = scene.my.ang; // angle main robot
pos = [(x / 8) + 56, y / 8];
angle = a
}
Obstacle detection occurs in the right square.
The 7 lasers on the yellow circle act as distance meters.
The 7 lasers are connected with the thrusters of the main robot with scene.my.
In doing so, the main robot deviates and avoids obstacles indirectly.
I hope I have explained my idea well.
The yellow and red arrows pointing in and out were for decoration only.
Maybe short-term memory can be confusing, I changed the title.
I uploaded the scene to another computer (a little older), and the scene works very badly.
It goes slow and the main robot's laser hits objects many more times, generates many more circles in the right square and slows down the scene again.
I don't know why, if the scene lags, the laser hits several times ..
On my computer the scene runs smoothly and I hadn't noticed this problem.
I have tried reducing the simulation frequency to 10, and it works better.
If you want, try downloading it again to see if it works.
Thank you!!!
Hi Xray!!
Thanks!!!
I wanted the octopus to have a calm and fluid movement!
Since it was perhaps too slow, I reloaded the scene with the octopus movement a little faster !!
I am sorry for the late reply!!
I apologize for causing problems with the "Bacteria under the microscope" scene!
I deleted the scene!
Thanks for interesting
I didn't understand what happened.
the problem was "scene.my.sin"?
I won't write like that anymore!
Hello s_noonan.
Thank you!!
Yes, the shield is the only idea I came up with to have an arc of green balls always in front of the vehicle.
"Making balls based on the angle and position of the generator", is difficult for me.
Luckily this scene doesn't give any problems...
Soon, I'll try to edit the "Bacteria under the microscope" scene with your advice.
Thanks again !!
I would like to ask a question:
Is there a way to comment on scripts so that algodoo does not delete them from the menu script?
I tried with this syntax:
(comment);
It's probably not a right way!
There's a way?
Thanks in advance!!