Rawbots Club Forum

Rawbots General => General Discussion => Topic started by: Schicko on March 28, 2016, 11:05:28 pm

Title: Bot-Making Help
Post by: Schicko on March 28, 2016, 11:05:28 pm
Can someone help me with my bot please. I'd like to make it more stable somehow as it keeps moving around a lot (it hovers) but I don't know how. I'd also like to make the cannon at the bottom be able to aim depending on mouse position but I'm not sure how I'd do that or if it is even possible.

https://www.dropbox.com/s/n2oog5otwmupak7/bp_6?dl=0
Title: Re: Bot-Making Help
Post by: MarvinMan on March 28, 2016, 11:37:46 pm
Mechanically, that's a good stable design. In terms of the control system, the problem is that the altitude and pitch/roll control are not separate systems. You want one control loop for the altitude of one of those center continuums, and a separate pair of control loop to control the pitch and roll. This can either be done by directly measuring the pitch/roll with an accelerometer, or by taking the altitude difference between a pair of opposite jets.

You can't control things with the mouse. The closest you can get is dragging a part around to use as a target. Have a look at the combat bot threads for automatic turret designs.
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 12:54:09 am
Hey thanks for your reply MarvinMan. I don't really understand what you mean by "separate systems" though. Correct me if I'm wrong, but I thought I did make the systems separate. Or at least I think I made the altitude control systems separate to the the yaw/orthogonal movement control systems.

Also I don't think I have implemented proper pitch/roll control systems yet (at least not intentionally - apparently pitch/roll control can be achieved if the right combinations of two buttons from q/w/e/a/s/d are pressed). Would it be possible for you to show me examples of implementations of the two different methods you mentioned in the form of blueprints so that I could better figure out how to implement them on mine?

As for the centre continuum control loop, where should I put the output of that to? I'm assuming to the altitude control systems? If it is, would I need to replace the individual PID loops for each of the up/down jets with control from the continuum's PID instead? Or just combine them somehow? Forgive my asking so many questions. I'm a noob afterall :D.

Ideally I would like to end up with something as stable as Trook's "TI" in
with its full degree of movement but using less parts if possible. I've tried to figure out how he did the programming but I don't really understand it. It doesn't help that I don't know which jets are connected to which programs in the video.

It's a shame that mouse control is not possible. I think I will just make the cannon keyboard controlled instead. Or perhaps replace it with rotating lasers instead.

Anyways, thanks again.
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 12:55:00 am
Take a look at the Canary bot in the ACL topic (http://forum.rawbots.club/index.php?topic=30.0) too. It has a good stable hover system that is relatively easy to scale up or down.
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 01:00:04 am
Right, will do PressureLine. Thanks.

Wow I didn't realise there were so many blueprints in that topic. I will take a look at those too.

Oh BTW, the game crashes sometimes when I load blueprints/a new world. It will either close or the window will turn black and become unresponsive/uncloseable. Is there anyway I can prevent that?
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 01:21:20 am
The Black Screen Of Death is most likely caused by "NaN" (div0 etc) or "ħinf" errors. Use paired MIN/MAX math functions with the variable input on sample_a before your 'sensitive' functions.

'Sensitive' items include (but are not limited to):
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 01:28:03 am
I tried loading the Canary blueprint then this happened XD :

http://i.imgur.com/ZPYZbB5.jpg

It happens each time I load that blueprint, even after reloading the game. :/
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 01:32:59 am
You have this: http://forum.rawbots.club/index.php?topic=8.0 installed? It literally will not work without it.

Once I get home from work I'll upload my hovering target drone, which doesn't have any fancy aim code, just hovering and wall avoidance.
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 01:41:13 am
It looks like your zip contains a Windows executable. I'll have to run the windows version of the game under wine which I've not tried before. Is there perhaps a Linux installer for it?
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 01:51:13 am
The executable makes the changes to the 'resources.assets' file that are required for some of the things to work (string output on math_function hexes for one) as well as the HP balancing, you could simply run that part of the update in a windows environment, and copy the modified resources.assets into your linux install.

The .dll file is the really important bit though, it contains all the revised code for Rawbots, and is absolutely essential if you want to use any of the non-legacy ACL bots (since they will likely all have at least one ASIN/ACOS/ATAN for aiming code) If i understand correctly the .dll should work in Linux no problem (I have zero experience with using Linux, of any flavor, so that may not be correct)
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 01:55:05 am
Right, thanks. I will try that and tell you how it goes.

Edit: Awesome, copying the dll and using wine for the installer did the trick. I suspect I probably didn't need to dl the windows version as the data files look the same anyways. Oh well. At least I can load the canary now. Question though: say I were to save a blueprint/world in the modded version, would it still load in the vanilla version?
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 02:45:42 am
As long as you don't use an ACOS/ASIN/ATAN/ATAN2 type math_function, or use the string output on a math_function to drive a projector you should be ok. Everything else is pretty much just stat changes, and shouldn't cause anything to break.
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 03:02:31 am
Right. That's good to know. I'll try to figure out the new stuff from the mod, how the canary works and how to stabilise my bot in a little while. Right now I really need some sleep haha. Thanks again for all the help.

I think ifound your hover target: https://drive.google.com/drive/folders/0B42Wtrlp8xi9dTdPa0k2S2tmTE0

I will check it out later.
Title: Re: Bot-Making Help
Post by: PressureLine on March 29, 2016, 05:15:50 am
I think ifound your hover target: (link)

I will check it out later.

I totally forgot I had that up there ;D It's probably easier to look at the hovertarget than at Canary, since the code is a lot cleaner because the hovertarget doesn't have all the code to automatically disconnect the other control blocks, or all the interlinked stuff for coloring the jets.

Just remember to take the red floater off the top before engaging the lift jets!
Title: Re: Bot-Making Help
Post by: z26 on March 29, 2016, 05:52:31 am
That ti bot is impressive.
Title: Re: Bot-Making Help
Post by: Schicko on March 29, 2016, 06:33:28 pm
I figured that my bot design can't achieve the full degree of movement that Trook's TI can, so decided to make myself one of those and start from that design instead. Unfortunately, despite trying to duplicate the programming in the video as close as I can, my TI doesn't work like the one in the video and breaks.. Can someone help with this please?  ;D

Here is what I came up with: https://www.dropbox.com/s/qj6b51m1veptthe/bp_TI?dl=0

That one breaks after leaving it alone for a couple seconds, so here is an older version which has linear velocity controls disabled: https://www.dropbox.com/s/ian5tolhpxv8e6w/bp_TI4?dl=0

That one only breaks when you try and use angular velocity controls.

I tried my bot in both vanilla and modded clients, but it still breaks. I feel like I am probably doing the controls wrong, but I'm not sure where I went wrong with them.
Title: Re: Bot-Making Help
Post by: MarvinMan on March 29, 2016, 10:43:11 pm
The control system on the old one looks reasonable. The way it runs away rather than oscillating wildly suggests that you've got a positive kp/kd where it should be negative.

I'd recommend adding some fins for stable mechanical damping, and using MIN/MAX functions to limit the thrust values to something you can contain.
Title: Re: Bot-Making Help
Post by: z26 on March 30, 2016, 04:33:01 am
Sometimes i noticed than in highly critical code, the order you created the code hexes in can actually matter.  Sort off like 2 + (4 * 8 ) doesnt give the same result than (2 + 4) * 8

This can be slightly annoying since theres no way to notice that order by looking at the code.
Title: Re: Bot-Making Help
Post by: Schicko on March 30, 2016, 01:08:20 pm
Thanks all. Apparently all I needed was to rest a bit so I could better figure out what I was doing wrong. The angular velocity controls were all wrong as I had assumed that TrookLue made it so that [8] would make it pitch down and [5] would pitch up which wasn't the case. Also I muddled the roll controls, so that didn't help either. I've fixed it now though: https://www.dropbox.com/s/7qntthmbjamo9qp/bp_TI7?dl=0

Maybe I will implement better controls as per Marvin's suggestions and also add some weapons to it later.

Thanks again.

Edit: I think a bot that uses less parts than TI but can also move like it could be made. It would look something like https://www.dropbox.com/s/4s4kh3mqu2w0ehr/bp_1?dl=0 . The different degrees of movements would be attained by the 6 jets using thrust vectoring. I have no idea how that could be programmed in though  ;D. Any ideas?
Title: Re: Bot-Making Help
Post by: Schicko on March 31, 2016, 06:30:33 pm
No takers :'( ? It would be really great if someone could tell me how I might program PID controlled thrust vectoring even for one motor-elbow-jet setup, then at least I could try and go on from there. https://www.dropbox.com/s/51z5dsi5c1h51h5/bp_2?dl=0
Title: Re: Bot-Making Help
Post by: MarvinMan on March 31, 2016, 09:21:20 pm
That flies surprisingly well. The kp or the attack/release on the translational controls are perhaps a bit too aggressive. I'd be inclined to remove the ki term and calculate the required lift force directly from the pitch/roll so that it doesn't keep ramping up the trust when it hits a solid obstacle.

When it comes to thrust vectoring, trigonometry is your friend (but watch out for NaN outputs). I think your best option would be to use two elbows at 90 degrees rather than a single elbow on a motor. In that case, the top and bottom jets provide the lift, one set of elbows controls pitch and the other set controls roll. (use trig to calculate how much thrust to feed into the non-lift jets.

FYI, edits don't seem to show up as new posts, so if you have something new to add that you want people to see, make a new post (or message someone specific).
Title: Re: Bot-Making Help
Post by: Schicko on March 31, 2016, 10:11:53 pm
Hey thanks MarvinMan! I will try out removing the ki, but I'm not sure how I'd make it calculate the forces required. I think the same would apply for the thrust vectoring issue. How would I make it calculate the required forces/angles actively if their states change quickly and frequently? Do I just use the math operand and make it calculate lift force by using trig/pythag on the pitch/roll jets' thrust values? Keep in mind I am still a noob at Rawbots and robotics in general and I basically just figured out how to make TrookLue's bot by watching his video and using some common sense.

Oh and next time, I promise to edit less and post more ;D . Thanks again.

Edit: Whoops. Sorry for the mixup. Also realised it might not just be pythag I need to resolve vectors.
Title: Re: Bot-Making Help
Post by: z26 on March 31, 2016, 10:22:49 pm
That's not Pressureline :p
Title: Re: Bot-Making Help
Post by: MarvinMan on April 01, 2016, 10:58:07 am
If you have a jet on an elbow, and want to use it to provide thrust along some combination of two perpendicular directions (X and Y), you need to calculate the total thrust required and the angle of the elbow. Assuming you know what thrust you need it the X and Y directions, use those two values as the perpendicular sides of a right-angled triangle.

Use pythagoras to calculate the total thrust required (ie. the hypotenuse of the triangle)

Use trig to find the angle for the elbow. The function you need depends on the exact mechanical configuration, but ATAN should work for a jet placed directly on an elbow like in that blueprint you uploaded.

To calculate the total lift thrust required you need either the SIN or COS of the pitch and roll, then use pythagoras to combine those values. I have a bot that does something similar to enable jets that let it drive on walls or the ceiling. If you can't work it out yourself, I can upload the blueprint.
Title: Re: Bot-Making Help
Post by: Schicko on April 01, 2016, 12:35:59 pm
Thanks for the explanations MarvinMan, and sorry for the inconvenience. I think what you've said makes sense. I'll try working it out for myself, but feel free to upload your blueprint so I and others can use it for future reference.
Title: Re: Bot-Making Help
Post by: Schicko on April 01, 2016, 03:56:17 pm
MarvinMan, I tried to implement your suggestion for TI and here is what I came up with: https://www.dropbox.com/s/dw2a3hj2su2i7t1/bp_TI2?dl=0 . Was that what you meant?
Title: Re: Bot-Making Help
Post by: MarvinMan on April 01, 2016, 10:24:41 pm
I could'nt figure out exactly where the total lift thrust is set, but all the trig and square/root functions look right. Other than that, it just needs a bit of tuning.

Here's the blueprint for the wall driving bot. Just be careful not to drive off the edges of the map too fast.
https://www.dropbox.com/s/juttiq9uhei19xh/bp_downforcer?dl=0 (https://www.dropbox.com/s/juttiq9uhei19xh/bp_downforcer?dl=0)
Title: Re: Bot-Making Help
Post by: Schicko on April 01, 2016, 11:39:05 pm
Awesome, thanks! Yeah I wasn't really sure where I was supposed to plug the outputs of the pitch/roll vector calculations. They come out with really small values (around 1) so I wasn't sure if I did the calculations right. I thought it made sense to multiply it to the output of the pids so that's what I did. I will definitely make sure to check out your bot to see what I am actually supposed to do  ;D .

I've started work on the other hoverbot earlier as well, and I'll probably do some more tomorrow. I've replaced the motors with elbows like you suggested and finished linear velocity controls which are basically the same as TI's.

Working out the math for the angular velocity controls is still proving troublesome for me though, as maths isn't my strongest suit. I'm sure I'll get it soon enough though, just need to brush up on vectors and trig some. One thing that is really bugging me though is that I can't seem to get my head around how to make jets at the bottom/angled downwards have positive thrust value whilst those at the top/angled up have negative/0 as the jets' positions and roles are dynamic, what with them being vectored thrust jets after all.

Do I even need to ensure the bottom jets are positive and vice versa or am I approaching the issue with angular velocity controls all wrong? I feel like it's impossible to calculate the required thrust without knowing the correct angles, but also that it's impossible to know the required angles if the correct thrust isn't known. I think I am missing a variable or something.

Perhaps I'll sleep for now, try to clear my head and hopefully tomorrow I'll be able to better understand what I need to do  ;D.
Title: Re: Bot-Making Help
Post by: PressureLine on April 02, 2016, 11:12:55 am
One thing that may not have been mentioned in this topic is that angular velocity (and acceleration) values are in radians/second (and radians/second/second for accel) and FWIW a radian is ~60° (its actually 360/2pi) which may help with your maths a little :)
Title: Re: Bot-Making Help
Post by: Schicko on April 02, 2016, 01:13:01 pm
Thanks for the heads up PressureLine. I have a question: Isn't the sign function supposed to output a 0 if the input is 0? Mine is outputting a 1 for some reason.
Title: Re: Bot-Making Help
Post by: MarvinMan on April 02, 2016, 07:45:09 pm
I was wondering about that the other day too. I'm sure it used to output 0 when the input was exactly zero. In the end, I ended up adding -0.01 to the input to stop it outputting a 1 for zero input.
Title: Re: Bot-Making Help
Post by: PressureLine on April 02, 2016, 10:05:56 pm
Thanks for the heads up PressureLine. I have a question: Isn't the sign function supposed to output a 0 if the input is 0? Mine is outputting a 1 for some reason.

Here is the code:

Code: [Select]
public static float Sign(float f)
{
    return ((f < 0f) ? -1f : 1f);
}

So in theory you are correct, doing SIGN(0) should output 1. But, remember floating point math. XFM 0.5 shows 3 decimal places, but the maths runs at 6 decimal places, so there could be something there.