[SOLVED] Trying to figure out how to make a smooth sumo code


#1

Hi everyone !

I started using mBlock to program mBot not so long ago, and I’m having a lot of fun !

Lastly I tried to make a sumo program for the association where I work. It was a struggle but it ended up working and I was very happy.

But at some point I noticed a priority issue : there’s a round arena that is black, with white stripes all around. If the mBot sees an obstacle, it accelerates.

The issue being that it accelerates even if the obstacle is outside the ring, and it prioritize this acceleration, while the goal is to stay in the ring as long as possible.

I searched a lot since, and found some interesting things, I started using a variable wich gave more control overall.

Last week I finally found a solution to the issue. If I shorten the time of acceleration, it will accelerate but then stop if there’s a white line in sight.

But now I’m facing a new problem… The acceleration is totally jerky.

I can make the mBot accelerate longer but it increases the risk of it going out of the ring.

So here’s my question : is there a way to make it smoother - while keeping a short time of reaction to a white line ?

Thanks in advance for any answer.

Here’s the code I’ve made :


#2

@Robin1 I don’t completely understand what you’re trying to do, but I’ll take a closer look later this week and see what I can find out. :slight_smile:


#3

I’m still not sure what you need, could you please explain? What does your setup look like?


#4

Hi !

I’m sorry, I’m not sure if I explained it clearly.

Basically, the idea is what is called a sumo bot.

There’s a ring I have here wich is totally black except for the outline that is white.

You take two mBots, put them here.

You use their following line sensor to stay inside the ring.

And you have a part of the program for both mBots, that says “when you see an obstacle”, run into the obstacle at full speed.

The problem I ran into is that, if there’s an obstacle, the mBot will run into it and even push itself out of the ring.

The goal is that the mBots push each other out of the ring, but as soon as they see the outline of the ring (a white line), they stop.

So the line follower sensor must be prioritized, so they stay insidie the ring.

The issue is that if I put it like this, if I make the mBot accelerate (to run into the other) for 1 second, during that second it doesn’t care about going out of the ring.

So if I change the lenght, like it accelerate for 0.1 second, it works.

But now it accelerate for 0.1 second, stop, accelerate again, stop, and that until there’s no obstacle or until there’s a white line.

I’m trying to find a way to make it accelerate without stopping until there’s no more obstacle, or there’s a white line.

Is this even possible to do ?


#5

I tried to take a picture of the setup, but apparently it’s too big for here.

So here’s a google drive link :
https://drive.google.com/file/d/15Rlfr4nrA_6wegoyGqJjuWRZKb_l25SF/view?usp=sharing

I hope this helps.


#6

@Robin1 I see now! I think you need a different type of code logic. I’ll try writing a new one; I don’t have your sumo setup, so I guess you can test it for me. :smiley: Give me a few days while I work on it.


#7

@Robin1 try this code. I think you will want the robot to turn longer than it does, but we can fix that more easily when we need. :slight_smile:


#8

Thank you !

It works perfectly !

As you said yes I’ll want the robot to turn longer than it does (it goes out of the ring). I did wonder how you do that though, haha I’m still a real beginner here.

My first intuition was to add a 0.1 second wait after the “turn right”, but finally just increasing the turning speed makes it turn more.

Really, thank you infintely.

It’s working flawlessly now. And I think I understand a little bit more how mBlock works.

Have an awesome day, and thanks again ! You’re a savior !


#9

I’m glad I could help! Let me know if you need anything else. Do you want help making the robot turn for a longer time, or is that solved now? :slight_smile:

I’m a Christian, so I try to be kind and help other, since Jesus is my savior! :smiley:

Have an awesome week!


#10

I’m answering a bit late, but it’s ok I solved it :slight_smile:

Thanks again.

I totally respect christianity, I remember my grandma being christian and she was the nicest person I ever knew, talking to everyone all the time.

I wish you lots of happiness.


#11

Thanks, you too!