Asked
Resolved Resolved by DJ Sures!

How To Store A Variable In Blockly

In conversation menu I'm trying to get the person to answer yes or no, and that would go into a variable. After it is in variable if it is equal to yes then make another variable = 150  but for some reason it is not working. Having it match a word rather than true or false would make it a more natural conversation. What is the proper way to do this in blockly? It works great when it is a numerical variable. Also is there a way to have jump down to option 4 if you didn't want to go through 1,2,3?


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
Synthiam
#1   — Edited

You can store a variable in Blockly like this...

User-inserted image

Also, keep in mind that variables starting with a $ are global. That information is documented on the Blockly support page here: https://synthiam.com/Support/Programming/block-coding/Blockly

User-inserted image

PRO
USA
#2   — Edited

tried out your storing Variable in Blockly, works well

User-inserted image

Also, I enjoyed the Blockly code to take a picture

Add Camera, script (take Picture), soudboard, if you like

Make script:

User-inserted image

Pictures are stored on your computer, my robot pictures

these are global variables

User-inserted image

#3  

Yes this is what I had, will start from scratch and redo it Probably had something to with the global/local variables. Some of the variables were not showing up in variables.  I liked learning about the local and global variables. My variable tracker was not changing. Thanks for the help!

#4  

For some reason I'm still having an issue. Here is the screen shot. It always says Zero from the PC.  These are all global variables and would think it would be fine. User-inserted image

PRO
Synthiam
#5   — Edited

Here's the manual for the WaitForSpeech command: https://synthiam.com/Support/javascript-api/Audio/waitForSpeech

It says the response is in lowercase.

I would also recommend adding an "else" condition to the IF so that you can handle anything unexpected. It's always good practice to have an ELSE when using an IF. 99% of the time, sound logic practice is to provide an ELSE. In the case above, if the WaitForSpeech times out, then a "timeout" would be returned, but it is not being handled in your condition.

Lastly, the Say PC Wait is good, but I recommend using the string append to combine the "I will be moving the base to" and $base_rotate rather than having two "wait" commands. It's just a bit cleaner. Here's an example screenshot...

User-inserted image

#6   — Edited

Lots of good advice and will implement them all.

Got it working and it's great- It was the uppercase that got me. The pc talking is cleaner now and the else is a catch all which was needed.

Thanks, Don

#7   — Edited

For the next step I think it may need a modification of the Auto Position to be a variable. Once you have selected locations for pickup and final destinations you will want to move that into a variable on the Auto Position so you can select multiple locations and actions as needed. You may have already figured out a way around this though. This seems like a simple but very powerful tool to have. Rather than picking a certain number to put into a variable you would be picking an action and thus picking multiple movements and locations that are done in the movement panel.

PRO
Synthiam
#8   — Edited

Id need more clarification to assist.

  1. Are you asking to programmatically define positions to an existing frame that exists in an action?

  2. or, programmatically create a new frame and add it to a new action, where all other frames are added programmatically as well.

  3. or, programmatically create a new frame and append it to an existing action that already contains frames.

  4. or, execute an existing action that had already been defined with predefined frames?

lastly, how many positions for the start and end of the Auto Position are there?

#9   — Edited

Number 4 seems to apply. My thoughts were since you already have actions already figured out in the Movement Panel now you have to selectively activate them. I use the Auto Position (wait) one after another in Blockly and it works great but when you use the conversation menu there needs to be a way to move the selected action into that Auto position(wait) move so that it will act the same way with one action happening after the other. If beer is response that would be an actual action which has many movements -location above it, then it lowers down, then it grabs it and moves up a bit. Now the beer has to go somewhere to "chair 3" which is another action. My thoughts were to have conversation menu fill in the variables of which action to use and have a nice clean Blockly have about 6 auto positions to run after the menu is filled out. The Command Control conversation menu (basically builds a menu or recipe of actions) would be on top of the Auto Position blocks and it all would not take much room on a single Blockly page. It would also help to have the ability to move frames as well as actions into Auto positions (variable) from the conversation menu. Thanks, Don

#10  

User-inserted imageHere is the jist of my thoughts on what I was trying to accomplish. I realize these are not variables but actions as of right now, but I was trying to simulate it.

PRO
Synthiam
#11  

The idea of using the conversation menu does not need variables. There’s a script for each selection. So you just launch the appropriate Auto Position in the conversation menu item script.

The conversation menu robot skill works like a phone menu. Where instead of press 1 to do this, you can use real phrases.

so you just add a menu option for each Auto Position action. And when someone selects that conversation menu item, launch the respective auto position

I believe what you’re doing is assigning a variable to each conversation menu level. But the issue with that is the conversation menu doesn’t block because it’s a different robot skill.

#12   — Edited

Ok understand, is there a way to have it execute only when all of the menu items have completed? This way it will all look simultaneous rather than start and stop after each answer.  Actually there is a way, just have the full conversation then assign the Auto Position wait one after another without dropping down and making new options. All of this is nice and clean within the conversation menu and I like it!! Thanks again, Don

#13  

Is there a way to have the startup script to be on the lookout for a certain word to get started, similar to Alexa or Siri. What would the blocky blocks look like to make that happen?

PRO
Synthiam
#14  

You would use one of the speech recognition engines for that. I would go with either the Bing or the Speech recognition robot skills

bing: https://synthiam.com/Support/Skills/Audio/Bing-Speech-Recognition?id=16209

speech recognition: https://synthiam.com/Support/Skills/Audio/Speech-Recognition?id=16118

The support section has a list of all robot skills that can be identified by their description here: https://synthiam.com/Support/Skills/Skills-Overview

#15  

Wow, that opened up a huge door. I was putting off learning some new skills like this till I totally understood other ones.  Thanks again, Don

PRO
Synthiam
#16  

Did you see the new movement blocks in the latest update? https://synthiam.com/Products/ARC/Releases/ARC-2022-09-03-00-Early-Access-Runtime-21295