Author Topic: DCS: change heading while in flight  (Read 2876 times)

Jan27!

  • Newbie
  • *
  • Posts: 12
DCS: change heading while in flight
« on: August 16, 2020, 05:12:46 AM »
Hello,

Inspired by this question https://forum.voiceattack.com/smf/index.php?topic=3371.msg15429#msg15429 (Enter coordinates using voice: What is the best way), I"ve tried something but without success.
Let me first explain what I want to do. I'm flying the F18 in DCS and want to change heading while in flight by changing the position of the heading switch indicator
1. Connect with the autopilot by pressing Right Shift + K (A/P button on the UFC)
2. Engage Attitude Hold mode by pressing Right Shift + Z
3. Select heading switch left by pressing Right Shift N during 3 seconds
4. Type in a 3 digit number in the UFC. Programmed my numerical keys on the UFC with the numpad keys
5. Press enter on the UFC (also programmed with the enter button om the numpad keyboard)
6. Connect again with the autopilot by pressing Right Shift + K
7. Press Heading select on the UFC by pressing Left Shift + 2

I Used {CMD} as variable but I do not know if this is correct (Don't know if I've set it elsewhere in a command). I used a loop but also don't know if this is correct. This is what it looks like:
Sproken command: change heading in [0..9]

Press Right Shift+K keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+Z keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+N keys and hold for 3 seconds and release
Pause 0.1 seconds
Play sound, 'C:\Windows\Media\notify.wav'
Wait for spoken response: '[0..9]'
Play sound, 'C:\Windows\Media\notify.wav'
Wait for spoken response: '[0..9]'
Play sound, 'C:\Windows\Media\notify.wav'
Wait for spoken response: '[0..9]'
Start Loop While : [{CMD}] Equals 0
    Begin Integer Compare : [{CMD}] Equals 0
        Press NumPad 0 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 1
        Press NumPad 1 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 2
        Press NumPad 2 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 3
        Press NumPad 3 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 4
        Press NumPad 4 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 5
        Press NumPad 5 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 6
        Press NumPad 6 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 7
        Press NumPad 7 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 8
        Press NumPad 8 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 9
        Press NumPad 9 key and hold for 0.1 seconds and release
    End Loop
    Press NumPad Enter key and hold for 0.2 seconds and release
    Pause 0.1 seconds
    Press Right Shift+K keys and hold for 0.2 seconds and release
    Pause 0.1 seconds
    Press Left Shift+2 keys and hold for 0.2 seconds and release
    Say, 'New heading selected'  (and wait until it completes)
End Condition

Any tip will do. In the mean time i am trying to do a course C# on the microsoft website to learn much more about Voice Attack!

Sincere greetings

Jan27!


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: DCS: change heading while in flight
« Reply #1 on: August 16, 2020, 06:44:28 AM »
"{CMD}" is a token, not a variable (tokens are not variables).

Tokens always, without exception, return literal text; They cannot be used directly in fields that expect variable names and don't also explicitly accept tokens.

"{CMD}" returns the phrase that was recognized to execute the command; With a phrase of "change heading in [0..9]", the output can never equal a single digit (E.G. "change heading in 0" does not, and will never equal "0").
In addition, even if you removed the other characters, the literal text "0" is not a number, it is a text character that just happens to represent a number.

Your while loop will not run because of the above, however even if it did, it would either run infinitely, provided the value spoken is zero, or again not run at all if the value is anything but zero.

As your command is currently set up, the loop also serves no purpose, as you can only input a single digit, rather than the intended three digit number.


If you predefine three separate digits, you can use the "{CMDSEGMENT:}" token to get each digit separately, without having to manually split them (and without needing a loop).

You could also combine that with the "Quick Input" action, instead of those conditions, E.G.
Code: [Select]
Quick Input, '[NUM{CMDSEGMENT:1}]'
As mentioned, tokens return literal text, which means they can be used as a substitute for other literal text (E.G. the above example, assuming your spoken phrase is "change heading in 0", would be the equivalent of typing in "[NUM0]") in fields that parse tokens.

Jan27!

  • Newbie
  • *
  • Posts: 12
Re: DCS: change heading while in flight
« Reply #2 on: August 17, 2020, 11:16:47 AM »
Hello,

Thanks for your response, Pfeil.

But I don't understand it. I just don't get the clue. So my voice command can be the same (change heading to [0..9]). And in the action screen I have to put:  Quick Input, '[NUM{CMDSEGMENT:1}]' . But that is not working. Where do I have to put the keystrokes? And must this be done for all the keystrokes? And must all the keystrokes have the Quick input command as described above?

I wish I could learn more "Basic Advanced Options". There is a lot on you tube and on the discord channel, but where to begin to learn the advanced stuff from the beginning

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: DCS: change heading while in flight
« Reply #3 on: August 17, 2020, 12:08:14 PM »
So my voice command can be the same (change heading to [0..9]).
It depends on what you're trying to do.

Currently you are requesting four digits from the user: One through the initial spoken command, and three using "Wait For Spoken Response" actions.

You need to decide where you're going to get your input from, either just using the spoken command (using a phrase with three separate digits), just using the "Wait For Spoken Response" actions, or a combination of both (E.G. the first digit as part of the spoken command, then the remaining two using the "Wait For Spoken Response" action).
The former would generate a relatively large number of command phrases, the latter will generate none. Using a combination of both (especially if you only make the first digit part of the spoken command) will reduce the amount of generated phrases.
The more command phrases in your profile, the longer the load times.


Code: [Select]
Quick Input, '[NUM{CMDSEGMENT:1}]'can replace the entirety of
Code: [Select]
    Begin Integer Compare : [{CMD}] Equals 0
        Press NumPad 0 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 1
        Press NumPad 1 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 2
        Press NumPad 2 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 3
        Press NumPad 3 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 4
        Press NumPad 4 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 5
        Press NumPad 5 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 6
        Press NumPad 6 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 7
        Press NumPad 7 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 8
        Press NumPad 8 key and hold for 0.1 seconds and release
    Else If Integer Compare : [{CMD}] Equals 9
        Press NumPad 9 key and hold for 0.1 seconds and release
    End Condition
(I notice you have the "Loop End" action where the "End a Conditional Block" should be, and vice-versa, which won't work correctly either)

However, typing in the numbers can be done in a single action, provided you gather all the data ahead of time (without requiring a loop at all), E.G.
Code: [Select]
Quick Input, '[NUM{TXT:~digit1}][NUM{TXT:~digit2}][NUM{TXT:~digit3}]'(assuming you're using the "Wait For Spoken Response" action, otherwise you'll want to substitute the "{CMDSEGMENT:}" token)


If you're going to use the "Wait For Spoken Response", read the documentation on that feature, and gain an understanding of how to set and get variable values.


Copying existing examples will only get you so far; You need to understand why the actions in the examples were used, and how they work.

Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

Jan27!

  • Newbie
  • *
  • Posts: 12
Re: DCS: change heading while in flight
« Reply #4 on: September 25, 2020, 02:24:09 PM »
Hello Pfeil,
For more than a month I am trying to figure out how to set the heading while in flight, in just one VA command. I've read your reactions 10 times, studied the manual, took some basics C# intro tutorials, studied al lot of YouTube movie, but with no success.
I’ve studied Confirmation and Basic Responses from Gary, and tried it to modify it, so it will put in the heading I’ve selected! Also with no success. My goal is to make one VA command (and understand the flow of the command) in which I can set the heading select button to a direction, with three digits.

The good news is that I managed to do it with three different commands
Command 1: Set      (This command sets to autopilot in attitude hold mode)
Press Right Shift+K keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+Z keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+N keys and hold for 2 seconds and release
Say, 'say direction'  (and wait until it completes)


Command 2: [0..9]   (This command let me set three digits on the autopilot)
Quick Input, '[NUM{CMDSEGMENT:0}]'

Command 3: Go   (This command sets the autopilot to the new heading)
Press NumPad Enter key and hold for 0.1 seconds and release
Press Right Shift+K keys and hold for 0.1 seconds and release
Press Left Shift+2 keys and hold for 0.1 seconds and release
Say, 'New heading selected'  (and wait until it completes)

But is it possible to do it with 1 command? Can it be done?

Another point is this: In your third reply  you suggested this:
"However, typing in the numbers can be done in a single action, provided you gather all the data ahead of time (without requiring a loop at all), E.G.
Code: [Select]
Quick Input, NUM{TXT:~digit1}][NUM{TXT:~digit2}][NUM{TXT:~digit3}]'
(assuming you're using the "Wait For Spoken Response" action, otherwise you'll want to substitute the "{CMDSEGMENT:}" token)".

First Question: ~digit1, ~digit2 and ~digit3  is that one variable?

Second question: Wait for spoken Response: I assume that it should be: [0..9]? And that the corresponding variable is ~digit1 or ~digit2 or ~digit3? Is that correct? But what should I fill in as variable?

Third Question: What do you mean with “substitute the "{CMDSEGMENT:}"?

Fourth Question: Why can I say three numbers in the :Quick Input, '[NUM{CMDSEGMENT:0}]', without ending this command?, i.e. how do you read that command in human language.

Hope you can shed some light on this questions!



Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: DCS: change heading while in flight
« Reply #5 on: September 25, 2020, 02:47:32 PM »
First Question: ~digit1, ~digit2 and ~digit3  is that one variable?
No...as the fact that they are three different names alludes to...

Do you understand what a variable is?

Second question: Wait for spoken Response: I assume that it should be: [0..9]? And that the corresponding variable is ~digit1 or ~digit2 or ~digit3? Is that correct? But what should I fill in as variable?
The variable the "Wait For Spoken Response" actions (one per digit) would need to set is one of the three you've just listed

Third Question: What do you mean with “substitute the "{CMDSEGMENT:}"?
To use the "{CMDSEGMENT:}" token rather than the "{TXT:}" token if you're speaking your numbers as part of the command phrase directly, rather than getting it through other means afterward, like from the "Wait For Spoken Response" action

Fourth Question: Why can I say three numbers in the :Quick Input, '[NUM{CMDSEGMENT:0}]', without ending this command?, i.e. how do you read that command in human language.
Using a "Quick Input" action doesn't end a command (unless it happens to be the last action in the action list); What are you asking?



To consolidate your commands into a single command, you can speak the numbers in the command phrase, E.G.
Altitude hold [0..9] [0..9] [0..9]
Code: [Select]
Press Right Shift+K keys and hold for 0,1 seconds and release
Pause 0,1 seconds
Press Right Shift+Z keys and hold for 0,1 seconds and release
Pause 0,1 seconds
Press Right Shift+N keys and hold for 0,1 seconds and release
Quick Input, '[NUM{CMDSEGMENT:1}][NUM{CMDSEGMENT:2}][NUM{CMDSEGMENT:3}]'
Press NumPad Enter key and hold for 0,1 seconds and release
Press Right Shift+K keys and hold for 0,1 seconds and release
Press Left Shift+2 keys and hold for 0,1 seconds and release
Say, 'New heading selected'  (and wait until it completes)

or, you can speak them using "Wait For Spoken Response" actions, E.G.
Altitude hold
Code: [Select]
Press Right Shift+K keys and hold for 0,1 seconds and release
Pause 0,1 seconds
Press Right Shift+Z keys and hold for 0,1 seconds and release
Pause 0,1 seconds
Press Right Shift+N keys and hold for 0,1 seconds and release
Wait for spoken response: '[0..9]'
Play sound, 'internal:Frrrp'
Wait for spoken response: '[0..9]'
Play sound, 'internal:Frrrp'
Wait for spoken response: '[0..9]'
Play sound, 'internal:Frrrp'
Quick Input, '[NUM{TXT:~digit1}][NUM{TXT:~digit2}][NUM{TXT:~digit3}]'
Press NumPad Enter key and hold for 0,1 seconds and release
Press Right Shift+K keys and hold for 0,1 seconds and release
Press Left Shift+2 keys and hold for 0,1 seconds and release
Say, 'New heading selected'  (and wait until it completes)

The former can be spoken more naturally, as there is no need to pause between the command phrase and the individual digits, but it generates 1000 phrase variations.
If you don't need all three digits to go up to 9, adjust them to reduce the amount of generated phrases; E.G. if the maximum altitude is 200, go with "[0..2] [0..9] [0..9]" instead.

The latter does require pauses, but generates only one phrase. I like to use "Play a Sound" actions to indicate the input was recognized, as there will be no notification of that by default.

Jan27!

  • Newbie
  • *
  • Posts: 12
Re: DCS: change heading while in flight
« Reply #6 on: September 27, 2020, 05:59:25 AM »
Thank you very much for the quick reaction. I will give these solutions a try

Jan27!

  • Newbie
  • *
  • Posts: 12
Re: DCS: change heading while in flight
« Reply #7 on: October 02, 2020, 10:28:36 AM »
Well, after trying the above solutions from Pfeil, there were still some problems. Both solutions gave some strange behavior in DCS (fuel probe extends, wings unlooked). So I tried something else. With lots of help from Bailey (check out  Bailey’s profiles for DCS) I was able to create three commands. The flow is as follows. Command one, the heading command, puts the autopilot of the DCS F18 Hornet on and in attitude hold mode. Then it selects the heading mode, followed by a response from VA: “Say Direction”, immediately followed by a pause of 6 seconds in which you call three numbers (the heading in degrees). In the log file you can see the numbers if correct spoken. These numbers are typed by the [NUM{CMDSEGMENT:0}] in the UFC of the F18 and after the pause the Go command is automatically executed. This ends with the sproken frase: “New Heading Selected”. All in very quick succession. These are my commands

1.   Command: “heading”

Press Right Shift+K keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+Z keys and hold for 0.1 seconds and release
Pause 0.1 seconds
Press Right Shift+N keys and hold for 2 seconds and release
Say, 'Say direction'  (and wait until it completes)
Pause 6 seconds
Execute command, 'Go' (and wait until it completes)


2.   Command: “[0..9]”
Quick Input, '[NUM{CMDSEGMENT:0}]'
Set text [saidHeadingTxt] to '{CMD}'
Set text [saidHeadingDigitsText] to '{TXTNUM:saidHeadingText}'
Set text [saidHeadingDigit1] to '{TXTSUBSTR:saidHeadingDigitsTxt:0:1}'
Set text [saidHeadingDigit2] to '{TXTSUBSTR:saidHeadingDigitsTxt:1:1}'
Set text [saidHeadingDigit3] to '{TXTSUBSTR:saidHeadingDigitsTxt:2:1}'
Write [Purple] 'I heard {TXT:saidHeadingTxt}' to log
Write [Purple]  'You asked for heading {TXT:saidHeadingTxt}' to log


3.   Command: “Go” (voice disabled)
Press NumPad Enter key and hold for 0.1 seconds and release
Press Right Shift+K keys and hold for 0.1 seconds and release
Press Left Shift+2 keys and hold for 0.1 seconds and release
Say, 'New heading selected'  (and wait until it completes)


Hope it will help some other VA users

And Thanks again to Pfeil and Bailey

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: DCS: change heading while in flight
« Reply #8 on: October 02, 2020, 10:34:15 AM »
You don't need separate commands...

The only thing the single command does differently, from the game's perspective, is timing. You may need to add pauses and increase hold times/times between keypresses (in the "Quick Input" action as well).

wakevortex

  • Newbie
  • *
  • Posts: 15
Re: DCS: change heading while in flight
« Reply #9 on: July 29, 2021, 01:22:53 AM »
Just came across this which looks interesting
how do I paste entire blocks of text into a command..is that actually possible or do we have to type it all out again (hopefully not ! )

cheers

Bill P

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: DCS: change heading while in flight
« Reply #10 on: July 29, 2021, 06:58:00 AM »
Those "blocks of text" are what you would see in the action list of your command, after you've added the relevant actions and set them up, like any VoiceAttack command is built.


You'll want to read the documentation (press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer)

These topics may also be of use, in addition to the official documentation:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up