Author Topic: Hal interfacing to the outer world .....  (Read 8660 times)

baskot

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hal interfacing to the outer world .....
« on: October 31, 2005, 05:54:01 am »
Hello there :)

I am a new member in this forum. After more or less long time of only following the threats I decided to participate this forum actively to find answers for my questions. Maybe someone has the answers......
Let me start by telling by stating what I "have" and following later what I want to know :
I want Hal to exchange Data with it's environment via an input/output device.
This is pointing a bit into robotics or animatronics I think. I find it interesting an begun to investigate a bit....
By looking for a suitable (and payable) technical solution for the I/O-Interface I found the Velleman
K8055 interface (see http://www.velleman.be/common/product.Aspx?lan=1&id=351980 for a detailed description).
It has 8 digital and two analoge output channels( analog is usable for PWM, too), 4 digital and 2 analog inputs, it is cascadable (up to four units) and it is connected via USB to the computer. It comes with a dll for programming purposes, but not an ActiveX-Dll. That is (afaik) not easy to use it in VB-Script. But lately I found a wrapper called DynaWrapNT (see http://people.freenet.de/gborn/WSHBazaar/WSHBazaar.htm)
By using this Wrapper I can use the Interface now within VBS. First tests went ok and I am quiet happy. The technical open part seems to be done :))
The question I have is rather simple, but the answer is more the complicated kind I assume...
Of course, I'd like to use this interface now with Hal. First step I thought about is to give Hal the ability of facial expressions, because Hal has emotions and these could be usable easy with something like :

case hal emotion
   switch angry
      SetAllDataports (0)
      dataport 3 = "1"
   switch happy
      SetAllDataports (0)
      dataport 1 = "1"
      dataport 2 = "1"   
   switch neutral
      SetAllDataports (0)
   endswitch

Of course, this is only an example (this code doesnt really work), but the idea should be visible....
Where in the brain are these things settled best, and what is the best method to integrate this possibility ?
This is a mix of coding and "best way of implementation"-Tasks. I am not that deep into Hal to find the best way myself, and so I ask the
comunity for giving me a hint.

Or, maybe there is somebody out there interested like me to work out this idea more in depth. I will give all my knowledge (not that much) into a discussion. Every helpful remark is wellcome!! Maybe my english is not the best...I have to appologise myself for that, but my mother tongue is german and so I have sometimes a problem to choose the right subset of words.

Regards

Yours Baskot
« Last Edit: October 31, 2005, 06:08:22 am by baskot »
 

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3859
    • View Profile
Hal interfacing to the outer world .....
« Reply #1 on: October 31, 2005, 04:09:29 pm »
Welcome Baskot,

There was quite a discussion some time back where some users were using a program called GIRDER to control external devices with HAL (some were X-10 devices as well).

Click on the SEARCH feature at the top of the forum page and do a search for X-10 or Girder and you might find the threads in question.

The emotional thing may prove to be more difficult from an external control standpoint.

 Good luck!
In the world of AI it's the thought that counts!

- Art -

baskot

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hal interfacing to the outer world .....
« Reply #2 on: November 01, 2005, 12:31:02 am »
quote:
Originally posted by Art

Welcome Baskot,

There was quite a discussion some time back where some users were using a program called GIRDER to control external devices with HAL (some were X-10 devices as well).

Click on the SEARCH feature at the top of the forum page and do a search for X-10 or Girder and you might find the threads in question.

The emotional thing may prove to be more difficult from an external control standpoint.

 Good luck!




Hello Art,

thanks for welcoming me. I read about the X-10/Girder combination before and found it quiet interesting. I wanted to point out an additional usable and effortable alternative to people who are interested in that.
I agree that the software and implementation part is the challange. Particularly it is the most difficult part for me. I have to explore and understand the Hal.brn and it's logic and go through Medeksza's forum posts to understand better how to interface with Hal.
But...every helping hint is more than wellcome [8D]

Greets and regards

Baskot
 

Carl2

  • Hero Member
  • *****
  • Posts: 1220
    • View Profile
Hal interfacing to the outer world .....
« Reply #3 on: November 08, 2005, 08:31:47 pm »
baskot,
  Just read your post and checked out the k8055, it's reasonably priced and easily available. I've been interested in connecting hal to the outside world, video input would be my choice but it is to advanced for me. Earlier I was using Haptek Sandy and after putting in some scripting to change the moods, using trigger words to send mood haps to the Haptek engine, I just changed to the fullbody girl.  Just got scripting so she can change clothes. I'd probably start out by putting a temperature input into hal. Possibly a light sensor input.
Carl2
 

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
Hal interfacing to the outer world .....
« Reply #4 on: November 11, 2005, 10:44:47 am »
Hi Baskot, I read your post first time round, but don't know anything about Robotics or interfacing them, but that does interest me and I'd like to have a go at it sometime.

Anyway this is just a pointer as to what might be useable in Hal.

1) Hal 5 stores data in brain (.brn) files, sometimes this is updated. Further to that the XTF modified brain sifts through input and makes further .brn files based upon the topic.

2) Hal 6, the newest contender, alters things slightly and it uses a database to store the information.

So there you have two possible methods of storing information.

3) The Hal brain script can be modifed in many ways, such as triggering events from user input.  Most often with INSTR and IF/THEN type statements.

4) The brain script also has a method of interacting with the main control program through 'HalCommands', I mention this because one of the commands will run an external program, which may be useful to you.

5) Emotions are already handled within Hal to an extent and also through the Haptek Player, but you can add your own emotion handling script to employ further Hap files (the files that animate the models).  There are some variables which handle Hals mood too.

6) With regard to the methods of storing data mentioned above, Mr M has employed a variety of methods for searching the brain files in HAL 5, and for HAL 6 you have the use of the SQL(Lite?) database functions.

Hope thats of some help :) more detailed info is already on the forum too.
« Last Edit: November 11, 2005, 10:50:22 am by freddy888 »

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Hal interfacing to the outer world .....
« Reply #5 on: November 26, 2005, 01:49:45 am »
Hello Baskot,

To check my understanding of your question, I will paraphrase your question as follows:

"How can I trigger TRUE, FALSE, ANGRY, HAPPY, and other various states within Hal, and then pass those states outside of Hal's script so that an I/O board can use the information to trigger external hardware?"

Two ideas for doing this come to mind, as follows:

----------------------

Idea #1:  Using Hal's AppendFile function, you can add a new line to an external text file of your choice.  Then, you have to figure out a way to get your I/O board and its software to read the LAST LINE of the target file periodically, and pick up the "state."  The code within Hal's VBS script would look something like the following:

If Instr(OriginalSentence, "angry") > 0, Then HalBrain.AppendFile WorkingDir & "statefile.txt", "ANGRY"  

If Instr(OriginalSentence, "happy") > 0, Then HalBrain.AppendFile WorkingDir & "statefile.txt", "HAPPY"  

In everyday language, the above code says: "If the exact string of letters 'happy' is found in the variant called 'OriginalSentence,' then open a file named 'statefile.txt' and write a new line at the end of the file with the letters 'HAPPY' on it.

(HalBrain.AppendFile is a capability provided by Zabaware.  You can write files directly using VisualBasicScripting commands also, but unfortunately, doing so usually triggers false warnings from anti-virus software!  To my knowledge, Zabaware does not currently provide an easy method to erase a file or replace its contents from within Hal's script.  That's why my example uses append, rather than replace.)

Idea #2:

If you know of a way to get your I/O board & software to "read" variants directly from Hal's running script (I DON'T know how, but there might be a way), you can simply create a new variant within the script and change its state with code like the following:

If Instr(OriginalSentence, "angry") > 0, Then MySpecialVariant = "ANGRY"  

If Instr(OriginalSentence, "happy") > 0, Then MySpecialVariant = "HAPPY"    

In the VBS language, you don't need to declare the existence of a variant before you use it.  The code above would create a variant named MySpecialVariant if it didn't already exist, and assign the stated string-value to it.

(Note that due to the way VBS works, the values of all variants are erased each time the script finishes running, UNLESS you declare the variant AT THE TOP OF THE SCRIPT BEFORE THE GETRESPONSE FUNCTION BEGINS, as a GLOBAL VARIANT. The excellent book "VBS in a Nutshell," which I've recommended in many past postings, explains this issue.)  

-----------------------------

If it were my project, I would pursue Idea #1.  Passing the information-state outside the script to a text file, then "reading" it outside the script, seems like the cleanest way to go.  You would need to have your I/O board software read the file every few seconds and respond to the latest "state" corresponding to the last line.

You asked about the best place in the script to add your new code.  The code examples I've given would not interfere or interact with anything else in the script, so it should be possible to add it anywhere AFTER the contents of "OriginalSentence" are established, and BEFORE the end of the "GetResponse" function.

I hope this gives you some additional ideas, and I hope that it stimulates further ideas and help from others on the forum.  I hope that your project succeeds!  Please let us all know!

Sincerely,

Don      
« Last Edit: November 26, 2005, 02:25:32 am by Don Ferguson »
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274

les

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Hal interfacing to the outer world .....
« Reply #6 on: November 26, 2005, 01:48:42 pm »
Baskot,

I am thinking of doing the same my thought was to hook up the head from the 5' Santa. There is a group doing a robot called Leaf: http://members.cox.net/rbirac/

and one of their members hooked up a talking Moose Head (they say it is very funny looking!)

But to do it right it has to been along the lines you are going, so after my long babble I just want to say that I will be following this topic, not sure if I can be any help but I will try.

Les
 

d_vyn1

  • Newbie
  • *
  • Posts: 10
  • E. C. G. The Foundation
    • View Profile
    • PureTek Solutions
Re: Hal interfacing to the outer world .....
« Reply #7 on: October 25, 2010, 01:53:10 am »
I have just run across your post about using Hal as a programable controller and thought i would pass on, as food for thought, using autoit as your interface to your external device Hal maakes short work of running programs and autoit scripts are great for cross application communications.
I'm sure that you have found a solution by this time but I hadn't seen one posted and thought I would lend a hand feel free to contact me for psuedo code snipits I'm a C++ and Java programmer kinda new to Hal and VBS but the logic behind the "API" is making sence.
The future is now and every moment hereafter