Home   Help Search Login Register  

Author Topic: HeliCAS - a helicopter collision avoidance script (ACCEPTED)  (Read 7948 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:HeliCAS - a helicopter collision avoidance script
« Reply #15 on: 02 Mar 2005, 21:17:05 »
Yep.. too late... script already submitted. But providing default values would have made sense.

My only reservation about using NearestObject would be whether it would slow execution speed or not.
urp!

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:HeliCAS - a helicopter collision avoidance script
« Reply #16 on: 03 Mar 2005, 04:12:23 »
I dont think that makes a difference when you have delays greater or equal to about 0.05. Or thereabouts. Actually, thats a complete guess

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:HeliCAS - a helicopter collision avoidance script
« Reply #17 on: 07 Mar 2005, 15:37:00 »
I tried your suggestion Fragorl, but I get a zero divisor error from the _delay = _this Select 4 when I do not provide a value.  The code still works, but the display of the error message is unsightly.


1.) The calling bit requires lots of numbers that the user has to look up in the readme. Perhaps give them some 'default' values (the ones that u find work best) and so allow them the opportunity to put nothing in. So, from the main script:

Code: [Select]
;  I have found the following values to work best.
;  _dist = 10
;  _spd = 2
;  _dt = 1
;  _delay = 0.05

_heli = _this Select 0
_dist = _this Select 1
_spd = _this Select 2
_dt = _this Select 3  
_delay = _this Select 4  

?format["%1",_dist] == "scalar bool array string 0xfcffffef":_dist = 10
?format["%1",_spd] == "scalar bool array string 0xfcffffef":_spd = 2
?format["%1",_dt] == "scalar bool array string 0xfcffffef":_dt = 1
?format["%1",_delay] == "scalar bool array string 0xfcffffef":_delay = 0.05
« Last Edit: 07 Mar 2005, 15:42:13 by Mr.Peanut »
urp!

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:HeliCAS - a helicopter collision avoidance script
« Reply #18 on: 08 Mar 2005, 09:56:55 »
EDIT: no, scrap that, use this:
Code: [Select]

?count _this == 1 goto "defaultvalues"

_heli = _this Select 0
_dist = _this Select 1
_spd = _this Select 2
_dt = _this Select 3
_delay = _this Select 4
goto"starthelicas"

#defaultvalues
_dist = 10
_spd = 2
_dt = 1
_delay = 0.05

#starthelicas
...
That *should* work ;)
« Last Edit: 08 Mar 2005, 11:31:34 by Fragorl »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:HeliCAS - a helicopter collision avoidance script
« Reply #19 on: 08 Mar 2005, 16:18:51 »
Yes that should do it.  Now why didn't I think of that?  ???
« Last Edit: 08 Mar 2005, 16:19:47 by Mr.Peanut »
urp!

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:HeliCAS - a helicopter collision avoidance script
« Reply #20 on: 09 Mar 2005, 11:38:54 »
Don't you worry..... it took me 4 attempts over an entire week (i edited the others out, it was getting embarrasing) to simply remember something I'd already done before.  :P :-\ :-[ ;D

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: HeliCAS - a helicopter collision avoidance script
« Reply #21 on: 24 May 2008, 17:21:28 »
Re-attached this resource since it somehow disappeared from the ED in the past half year. Feel free to delete this post once it is back in so that the thread sinks to its proper place in time

OFPR, SMUC code is C, demo mission included. Text from script header to help for ED entry:


;======================================================================
;HeliCAS - A Helicopter Collision Avoidance System for AI pilots;
;by Mr.Peanut
;Version 1.0 : March 7, 2005
;
;SYNTAX:  [_heli] Exec "helicas.sqs"
;EXAMPLE: [[H1,H2,H3,H4,H5,H6,H7,H8,...,H?]] Exec "helicas.sqs"
;  where H1-H? are the helicopter names. In this case the default values will be used for the input parameters.
;
; OR for total control
;
;SYNTAX:  [_heli, _dist, _ spd, _dt, _delay] Exec "helicas.sqs"
;EXAMPLE: [[H1,H2,H3,H4,H5,H6,H7,H8,...,H?],10,2.0,1.0,0.05] Exec "helicas.sqs"
;  where H1-H? are the helicopter names
;
;INPUT VARIABLES:
; _heli = array of helicopters piloted by AI
; _dist = collision detection distance (m) 
; _spd = collision avoidance speed   (m/s)
; _dt = collision prediction time  (seconds)       
; _delay = collision detection delay  (seconds)
;
;FUNCTIONS USED:
;  The following functions must be declared in init.sqs
;  Distance3D = preprocessFile "distancepos3d.sqf"
;  Sign = preprocessFile "sign.sqf"
;
;DESCRIPTION:
;  This script works by predicting each helicopter's position _dt seconds from present.  If any of the helicopters are
;  closer to each other than distance _dist, then they are nudged apart from each other with a speed based on the value
;  of _spd. The _delay variable is the loop delay between collision checks.  The helicopters will not always successfully avoid
;  collision, but that is true of the real world too.
;
;  I have found the following values to work well and provided them as defaults:
;  _dist = 10
;  _spd = 2
;  _dt = 1
;  _delay = 0.05
;
; Increasing _delay above 0.1 is not advised if you have more than  three helicopters. Increasing _spd above 5
; will make the helicopters flit and bounce around unnaturally.  If you  decrease _dist, it is a good idea to increase _dt.
;
; For fewer helicopters, decrease _dist, decrease _spd, decrease _dt and increase _delay.
;
;WARNING:
;   There is no check for whether the array _hlist is a valid list of helicopters.  I did not want to hard code a list
;   of helicopter types.
;
« Last Edit: 01 Jul 2008, 16:27:08 by Mr.Peanut »
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: HeliCAS - a helicopter collision avoidance script
« Reply #22 on: 04 Jun 2008, 18:37:26 »
Finally got it working for ArmA too, did some changes for ArmA version: call format -> call compile format, preprocess -> compile preprocess, camCreate -> createVehicleLocal.

As it uses several scripts, before submission, please renamte them all using your tag first, or put them all in a subfolder named at your convenience. Check also how can this be made fully MP compatible as you are using setVelocity to avoid collisions, and this command requires local units as parameter. As everything is done with a single instance of a single script, the choppers in the array might have different localities and one might evade while the rest dont.

EDIT:
There is a situation I missed to test, where several choppers take off close to each other following the same direction.
« Last Edit: 07 Jul 2008, 17:32:40 by Mandoble »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: HeliCAS - a helicopter collision avoidance script
« Reply #23 on: 17 Jun 2008, 00:51:57 »
v 1.1
« Last Edit: 07 Jul 2008, 17:32:29 by Mandoble »
urp!