D.cochran's Teddy

CochranRobotics

USA
robot video thumbnail
robot video thumbnail
robot video thumbnail
robot video thumbnail
robot video thumbnail
robot video thumbnail

I am going to try to document this project because I think its pretty cool so far. It is also the beginning of a much larger project.

For the hardware right now, I am using a Teddy Ruxpin bought on ebay EZB V4 V4 Camera 2 rotational HD servos for shoulders 1 Rotational servo for neck 1 micro servo for mouth amplified speaker (used for phones) Scary Terry Audio servo Driver Board

For software EZ-Builder MSSQL EZ-DBMulti rssGetter RoboRealm

Project Description I wanted to design a robot for my grandchildren but also use this as a platform to test some things that I want to do with my InMoov project. The robot needs to be able to identify the user and then customize itself to what that user would use/need. For example, if I was using the robot, I want the robot to be able to read me the traffic, weather and news from RSS Feeds. If my granddaughter is using the robot, I want it to be able to tell nursery rhymes and sing songs that are for her age level. Because my granddaughter is a primary focus for this robot, I wanted the jaw to move reliably when the robot is speaking.

ROBOREALM CONFIGURATION To accomplish this, I had to have a way to identify which user is using the robot. RoboRealm has the ability to recognize faces and to be able to pass variables back to ARC. It also has the ability to use a feed from an http server for its camera source.

To make RoboRealm work, I added three modules to it. These are ReadHTTP, AVM Navigator and EZRobot_Variables. ReadHTTP is configured to access http://127.0.0.1:8010/CameraImage.jpg?c=Camera. I will get to the configuration of the webserver within ARC in a few moments. AVM Navigator is setup in Object Recognition mode with my face (and the other members of my family's face) trained. EZRobot_Variables is configured to pass the NV_ARR_OBJ_NAME variable back to ARC on host 127.0.0.1 port 6666 with a prefix of RR_.

EZ-BUILDER HTTP Custom Server The HTTP Custom Server is configured to run on TCP Port 8010. This is because I am already using 80 and 8080 for other development projects.

EZ-BUILDER Startup script


$rsstext = ""
$rssLocation = ""
$feedDescription = ""
ControlCommand("HTTP Custom Server", StartServer)
Sleep(2000)
ControlCommand("Script Manager", ScriptStop, "Monitor")
ControlCommand("Script Manager", ScriptStart, "Monitor")
ControlCommand("Sound Servo", PauseOn)
Exec("c:\RoboRealm\RoboRealm.bat")
ControlCommand("Script Manager", ScriptStart, "WhoAmI")
Sleep(5000)
ControlCommand("Script Manager", ScriptStart, "GetDatabaseInfo")

This script prepares a couple of variables for later use, then starts the HTTP Custom Server so that RoboRealm can use the V4 camera feed through the HTTP Custom Server. It then starts a monitor script and then pauses the Sound servo control. It then launches RoboRealm and runs a WhoAmI script before going to the database server to retrieve information for the user that is using the robot.

MONITOR SCRIPT


:MonitorFunction
$connected = IsConnected( 0 )
if($connected = 0)
  ControlCommand("Script Manager", ScriptStart, "CheckConnection")
endif
$CPUTemp = GetCPUTemp()
if($CPUTemp > 30)
   ControlCommand("Sound Servo", PauseOn)
   sayezb("The temp of the process has exceeded safe parameters")
endif
$CurrentVoltage = GetVoltage()
if ($CurrentVoltage < 6.6)
   ControlCommand("Sound Servo", PauseOn)
   sayezb("You will have to charge me soon")
endif
sleep(5000)
Goto(MonitorFunction)

This script first checks to see if there is a connection to the EZ-B on the robot. If one doesn't exist, it then runs a script called CheckConnection. It then checks the temp of the CPU in the robot and warns if there appears to be a pending issue. It then checks the voltage of the battery and warns the user if they will need to charge the battery soon. It then waits 5 seconds and the loops to the start of the script again. This monitor keeps running while ARC is connected to the robot.

CHECKCONNECTION


$connected = IsConnected( 0 )
REPEATUNTIL($connected = 1)
  If($connected = 0)
    $Connection=0
  Else
    $Connection = 1
  EndIf
 if($connection = 0)
   ControlCommand("Connection", Connect0)
   sleep(3000)
   $connected = IsConnected( 0 )
 endif
EndRepeatUntil 

This script is called by the monitor script and first checks to see if the connection is made to the robot. If there is not a connection, it tries to establish the connection and waits 3 seconds for the connection to be established. If it isn't established, the script tries again.

ROBOREALM.BAT


D:
CD\Program Files (x86)\RoboRealm
RoboRealm

This just simply executes the RoboRealm application.

WhoAmI


SayEZB("Let me have a good look at you.")
controlcommand("Script Manager", scriptStart, "GreetuserRich")

This is a very simple script that just says "Let me have a good look at you." and then launches the GreetUserRich. This could be combined with the GreetUserRich script and this one could be eliminated completely.

GREETUSERRICH


$user0 = "null"
IF ( $RR_NV_ARR_OBJ_NAME[0] != "" )
    $user0 = $RR_NV_ARR_OBJ_NAME[0]
    SayEZB("You are " + $user0 + ".  It is great to see you!")
EndIf

This script was greatly reduced from what I had before. RoboRealm is very fast and very good at facial recognition. Because of this, I was able to reduce the amount of code here for checking things. If it becomes unreliable with many faces learned in RoboRealm, I will start adding in more checking. When RoboRealm is called, and a face is recognized from the HTTP camera feed from EZ-Robot, the $RR_NV_ARR_OBJ_NAME[0] is passed back to ARC as a variable. This script takes the value of this variable and assigns it to $User0 and then says "You are [the persons name]. It is great to see you!"

GETDATABASEINFO


#Starting variables for EZ-DB
$UserName = ""
$UserName = $user0
$SqlReturn = " "
$SqlCommand = ""
$FatherName = ""
$MotherName = ""
$GrandmaName = ""
$GrandpaName = ""
$NumberOfVariablesToStore = 2
$RobotName = "Teddy"
$RobotID = ""
ControlCommand("Script Manager", ScriptStart, "GetRobotIDFromDatabase")
Sleep(1000)
ControlCommand("Script Manager", ScriptStart, "GetGrandpaFromDB")
Sleep(1000)
ControlCommand("Script Manager", ScriptStart, "GetGrandmaFromDB")
Sleep(1000)
ControlCommand("Script Manager", ScriptStart, "GetFatherFromDB")
Sleep(1000)
ControlCommand("Script Manager", ScriptStart, "GetMotherFromDB")
Sleep(1000)

A lot of variables are initialized here, and the $user0 variable value is then assigned to $UserName. The $RobotName variable is also set. This script then calls 5 other scripts that are all similar. All of these connect to a database through EZ-DBMulti to pull specific data back with 4 of them pulling back specific data about the current user based on the facial recognition that has taken place.

GETROBOTIDFROMDATABASE


$SqlCommand = "EXEC usp_GetRobotIDFromName '"+$RobotName+"'"

FileWrite("C:\EZ-DBMulti\Query.txt",$SqlCommand)
FileWrite("C:\EZ-DBMulti\Robot.txt",$RobotName)

EXEC("C:\EZ-DBMulti\EZ-DBMulti.exe", "In")
Sleep(1000)
$RobotID = $SQLReturn

This script prepares a sql command which executes a stored procedure on a MSSQL database called usp_GetRobotIDFromName and passes in the $RobotName variable value into the stored procedure as a parameter. It stores this information in 2 files. The first of these is called Query.Text (containing the command that is going to execute. The second is called Robot and contains the $RobotName value (really not used by this stored procedure, but EZ-DBMulti's database houses information for multiple robots.) It then calls EZ-DBMulti passing in whether EZ-DBMulti is supposed to retrieve data from the database (In) or pass data to be stored in the database (Out). After the query executes, the result from the execution of the stored procedure in the database is stored in the $SQLReturn variable in ARC so I then assign the $RobotID variable value to the value of the $SQLReturn variable.

SQL Server usp_GetRobotIDFromName


USE [robot]
GO
/****** Object:  StoredProcedure [dbo].[usp_GetRobotIDFromName]    Script Date: 1/26/2015 8:00:51 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Cochran
-- Create date: 01/25/2015
-- Description:	Get Robot ID from its name
-- =============================================
ALTER PROCEDURE [dbo].[usp_GetRobotIDFromName] 
	-- Add the parameters for the stored procedure here
	(@RobotName VARCHAR(50))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT 
		RobotID
	FROM
		Robots
	WHERE 
		RobotName = @RobotName
END

This one is really unspectatular, but I wanted to show what the USP is doing. It simply is looking into the Robots table, and is returning the RobotID where the RobotName matches the $RobotName variable value from ARC (it was passed in when the USP was called through EZ-DBMulti.)

SQL SERVER USP_GRANDPADATA


USE [robot]
GO
/****** Object:  StoredProcedure [dbo].[usp_GrandpaData]    Script Date: 1/26/2015 8:03:57 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Cochran
-- Create date: 01/25/2014
-- Description:	Returns Grandfathers data for a named user
-- =============================================
ALTER PROCEDURE [dbo].[usp_GrandpaData]
	(@username Varchar(50))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	SELECT 
		GParentDetails.[UserFamilyName]
	FROM
		[dbo].[Users]
		INNER JOIN [dbo].[UserInfo] ON [dbo].[Users].UserID = UserInfo.UserID
		INNER JOIN [dbo].[FamilyTree] ON [dbo].[Users].UserID = [dbo].[FamilyTree].[UserID]
		INNER JOIN [dbo].[Family] ON [dbo].[FamilyTree].[FamilyID] = [dbo].[Family].[FamilyID]
		INNER JOIN [dbo].[FamilyTree] as Parents on 
			[dbo].[FamilyTree].[FamilyID] = Parents.FamilyID 
			AND FamilyTree.Parent = Parents.UserID
		INNER JOIN [dbo].[FamilyTree] as GParents on 
			[dbo].[FamilyTree].[FamilyID] = GParents.FamilyID 
			AND Parents.Parent = GParents.UserID
		INNER JOIN dbo.Users as GParentDetails ON 
			GParents.UserID = GParentDetails.UserID
		INNER JOIN dbo.UserInfo AS GParentDetail ON
			GParents.UserID = GParentDetail.UserID 
			AND GParentDetail.Gender = 'M'		
	WHERE dbo.Users.Username = @username
	Group By
		GParentDetails.[UserFamilyName]
END

This USP is a bit more complex. Gets the UserFamilyName for the male grandparent of the user. The joins are used to map the relationship from the user up to the parent and then the grandparent of the user.

SQL SERVER USP_GETMOTHERDATA


USE [robot]
GO
/****** Object:  StoredProcedure [dbo].[usp_MotherData]    Script Date: 1/26/2015 8:07:11 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Cochran
-- Create date: 01/25/2014
-- Description:	Returns Mother data for a named user
-- =============================================
ALTER PROCEDURE [dbo].[usp_MotherData]
	(@username Varchar(50))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
		SELECT 
		CASE when DATEDIFF(YYYY,[dbo].[UserInfo].[Birthday],GETDATE()) < 6
		THEN
			ParentDetails.[UserFamilyName]
		ELSE
			ParentDetails.[UserName]
		END AS ParentName
	FROM
		[dbo].[Users]
		INNER JOIN [dbo].[UserInfo] ON [dbo].[Users].UserID = UserInfo.UserID
		INNER JOIN [dbo].[FamilyTree] ON [dbo].[Users].UserID = [dbo].[FamilyTree].[UserID]
		INNER JOIN [dbo].[Family] ON [dbo].[FamilyTree].[FamilyID] = [dbo].[Family].[FamilyID]
		INNER JOIN [dbo].[FamilyTree] as Parents on 
			[dbo].[FamilyTree].[FamilyID] = Parents.FamilyID 
			AND FamilyTree.Parent = Parents.UserID
		INNER JOIN dbo.Users as ParentDetails ON 
			Parents.UserID = ParentDetails.UserID
		INNER JOIN dbo.UserInfo AS ParentDetail ON
			Parents.UserID = ParentDetail.UserID 
			AND ParentDetail.Gender = 'F'		
	WHERE dbo.Users.Username = @username

END

This one is similar to the previous one in that it identifies the female parent of the current user. It also uses a CASE statement that checks to see what the age of the current user is. If the current user is less than 6 years old, it returns a family name (such as Mommy) for this parent. If the user is older than 6, it grabs the username for the mother. This can be extended much further than I currently have, but currently, when the user of this robot reaches age 6, the value returned changes and the robot automatically changes because of the change in age of the user.

I will be adding additional things like getting the birthday of the user or anniversary, or holidays such as Christmas, Easter and many more so that different phrases can be said based on the age of the user and the day of the year. I also plan to add things like the last time that something happened (for example a nursery rhyme was said) for a user and limit the robots activity based on this. It could be a song was played, or news was read, or whatever. I might also have a game for my granddaughter and knowing what questions were asked last time or previously, I could then ask other questions that were not asked yet or have been asked less frequently. Anyway, I will be posting the project file on the cloud if anyone wants to use anything that I have done.

There is more in there, I am just worn out on typing this right now. I will probably add more and a video later, but I wanted to start documenting. If you are still reading this and have any questions, please let me know.

By — Last update

ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

#1  

I'm gonna read all your posts. All I want to do is possibly mount a talking head on top of a Roomba with an attitude.

#3  

Very impressive. Is Roborealm's recognition significantly better than what DJ built into object recognition in the camera control (which I realize is still Beta)? EZ-B seems kind if hit and miss with object recognition. Rather than different people, I am trying to recognize the cat, and some of her toys and react accordingly (if cat, say her name, turn on laser mounted on the camera pan/tilt and start a "play pattern", if toy, pick it up and either throw it if cat recently seen, put in storage to bring to me if cat not recently seen). I can recognize the cat if her face is in just the right positions, and toy recognition is barely working. If Roborealm would do better, it might be worth the investment rather than waiting for DJ to improve built in recognition. (I still need to upgrade my server from 2003 to 2008 and get SQL Server installed too, but one thing at a time).

Alan

#4  

Very nice David.... Wish I had your Windows programing skills dude... Anyway, I was just wondering if there is any chance you can do a tutorial of some sort on how to pass simple values or information back and forth from Roborealm and ARC?... I mean how the roborealm works and how it and ARC would interact with each other....

I have been tempted in the past to buy roborealm but because of not quite understanding how it worked and how to interface it with my robotics projects kept my credit card in my pocket....

#5  

RoboRealm is impressively fast at object recognition. The issue that I see you coming into is that the cat can be in a lot of shapes (curled up, sitting, lying down, about to pounce, standing, just the face, just the back end) so you would have to train it in for a lot of situations. RoboRealm is really good though and I have been very impressed. You will also have to get the AVM module which allows the object recognition I use, but its really good.

My logic is to use the best thing that I can find for a job. Its the reason that I had a cable company for TV and internet and a phone company for my phones. Its becoming more blurred in that area, but It still works in robotics. The EZ-B and ARC is the best I could find. RoboRealm (now that it has a module to pass parameters to and from ARC) is the best I could find. The sound servo board is the best I could find for the size I needed (I don't have it yet, but reviews and videos are really good). There is also the comfort factor as to already knowing C# and MSSQL so it is the best for me.

One other thing that I do is try to section my code out. One script, usp, function does one thing. I find it easier to test and know it is good instead of writing long scripts or code that does many things, and then you change one thing that you think won't affect other things, but because it is in one large script, you don't know or forgot you used that variable or parameter somewhere else, and the script starts failing.

Back to the question, yes, I believe RoboRealm is worth the cost and it can be pretty seamlessly integrated into ARC. Its really good.

#6  

I will do it richard and it will be very short because it is very easy.

#8  

Video is uploading. I threw myself for a loop at the end of the video and don't feel like editing it, but it will be up after it loads and is processed. I will do another one later showing me adding the components in RoboRealm.

I just had to chuckle. Hopefully you will too :)

#9  

I will make a new thread with this when I have a video that is good enough to post as a tutorial :)

United Kingdom
#10  

David, this is absolutely brilliant work! I never knew that RoboRealm had face recognition?

Tony

#11  

Tony, Thank you for the kind words. You do have to have the AVM Navigator Module ($9.00 US) to be able to do the object recognition. It really doesn't care if it is an object or a face so the same module can be used for all recognition.

Anyway, I hope this helps some others. It is worth documenting IMHO.

#12  

Hey David... I have a trial version of Roborealm installed and I watched your video on capturing the camera feed from ARC. I have everything set up as per your video but I can't get the ezb camera to display... The only camera that displays is the one on my pc? How do substitute the pc camera and show the ezb camera in it's place...?

Thanks

#13  
  1. Setup the Custom HTTP Server in EZ-Robot (define the port to use to 8010 in this example)

  2. Start the custom http server by clicking the Start button (can be scripted)

  3. In roborealm type HTTP in the Search window at the top left of the screen.

  4. Double click the Read_HTTP list that is dropped down.

  5. In the dialog box that pops up, type in http://127.0.0.1:8010/CameraImage.jpg?c=Camera

  6. Click Start

That should get your feed going.

#14  

once all of that is done, try closing it and reopening RoboRealm if you still cant see it.

#15  

Duh... I had the wrong control... Working now.... I had HTTP instead of Read_HTTP... Ok, now so far so good. I can now continue with your video...

Thanks Richard

#16  

Im adding another video that shows the Teddy doing things based on the age of the recognized user. All of this is now database driven which allows me to then log what has happen with a robot for a user to the database. The robot can be shut off and the computer rebooted or whatever, but the activity log stays. These tables and stored procs pass the next activity that the robot is to perform for a user to ARC. Once the task is completed in ARC, the activity is logged in the database. Activities are repeated for a user based on a time allowance in the Activity table. For example, I won't hear the news again today, but the weather I could hear every hour, or however you want to configure the activities in the tables.

Anyway, check out the video. I am pretty wiped out today and just want to veg the rest of the evening.

When time permits, I will change EZ-DB Multi to return multiple values at one time instead of making multiple passes at the database. That is the next modification I want to make, but Arrays scare me:) Just kidding. Its just a bit of a rewrite.

PRO
Belgium
#17  

d.cohran

cant see the video.

PRO
Belgium
#20  

thanks d.cohran

aldo i dont understand any off this.i like seeing these video's. its stunning what people can do.

#21  

This is my "BrainFunctions" script currently. This is an attempt to do what many programmers do with business applications. The front end or user interface of an application is normally very light. The processing of data happens at the database and there is normally an layer between the front end and the data. That layer is a bit more difficult but could be built using the SDK. Right now, both the front end and the data layer handle this logic. I try to push as much of it to the data layer as possible.

This script handles the logic as to what to do with the information that is retrieved from the database. The database handles what to feed to the front end and when it can be fed. This script just checks every minute to see what the database is going to feed to it and then handles what it receives back.

This script doesn't know the details for most things on what to do with a specific recieved request, but looks at what is being passed back and passes this off to other scripts based on what it gets back from the Database layer.

BRAINFUNCTIONS


:Beginning
$UserActivity = ""
$SQLResult = ""
$SQLReturn = ""
#Identify next thing to tell the user from the database based on 
#who is using the robot and what has been told to the user within timmers
ControlCommand("Script Manager", ScriptStart, "GetUserActivityFromDB")
SLEEP(2000)
#Based on what came back from the database call one of the following or say that there is nothing new for them at this time.

#Holiday
IF($SQLReturn = "Check Dates")
  Sleep(2000)
  ControlCommand("Script Manager", ScriptStart, "GetPersonalHolidayFromDB")
  SLEEP(2000)
  IF(LENGTH($SQLReturn) > 0)
    SayEZB("Today is your " + $SQLReturn + ".") 
  ENDIF
  SLEEP(2000)
  ControlCommand("Script Manager", ScriptStart, "GetHolidayFromDB")
  SLEEP(2000)
  IF(LENGTH($SQLReturn) > 0)
    SayEZB("Today is  " + $SQLReturn + ".") 
  Endif
  ControlCommand("Script Manager", ScriptStart, "LogEvent")

ELSEIF($SQLReturn = "Reminders")
  SayEZBWait("Add code for reminders like Rhymes")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
#Run the reminder query
#Say the information provided from the query
#Log Reminders event if called
ELSEIF($SQLReturn = "News")
  ControlCommand("Script Manager", ScriptStart, "ReadNews")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Weather")
  #SayEZB("Here I would read the weather")
  ControlCommand("Script Manager", ScriptStart, "ReadWeather")
  Sleep(2000)
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Traffic")
  ControlCommand("Script Manager", ScriptStart, "ReadTraffic")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Timers")
  SAYEZB($UserActivity + " Checked every minute.")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
#Timers
#Get Timers from the database
#Speak the next timer
#Log Timers event if called

#Rhymes
#Move rhymes to database and use it to track which rhyme has been sent and when
ELSE
  SAYEZBWAIT($SQLReturn)
ENDIF
Sleep (60000)


When news is requested, the BRAINFUNCTIONS script runs this script which sets some parameters that are specific for news and then calls the readRSS script. There are multiple RSS feads so, writing the readRSS script one time and calling it from scripts like this allows the readRSS script to be written and tested and once known to be good, it doesnt need to be messed with again and will work with any of the RSS feeds in this manner.


$feedDescription = "News"
$rssLocation = "http://feeds.skynews.com/feeds/rss/uk.xml"
ControlCommand("Script Manager", ScriptStart, "readRSS")

This is the ReadRSS script.


#Run the app to get the poem
ControlCommand("Sound Servo", PauseOff)
Exec("c:\rssfeeds\rssGetter.exe", $rssLocation)
$sent = "Retrieving the "+ $feedDescription + " feed for you sir."
sayEZBWait($sent)

$rsstext = filereadline("C:\rssfeeds\rssfeed.txt")
#Read the News
  sayEZBWait($rsstext)
#close the file that was read
filereadclose("C:\rssfeeds\rssfeed.txt")
#Delete the text and prepare for the next one
filedelete("C:\rssfeeds\rssfeed.txt")
#dump memory
$rsstext = ""
$rssLocation = ""
$feedDescription = ""
ControlCommand("Sound Servo", PauseON)
Servo(d1,130)

This is the LogEvent script


$SqlCommand = "EXEC usp_UpdateActivityLog '"+$UserName+"', '"+$UserActivity+"', "+$RobotID

FileWrite("C:\EZ-DBMulti\Query.txt",$SqlCommand)
FileWrite("C:\EZ-DBMulti\Robot.txt",$RobotName)

EXEC("C:\EZ-DBMulti\EZ-DBMulti.exe", "In")
Sleep(1000)

The need for the in and out parameter for EZ-DBMulti is becoming less needed and may be removed soon. If you call a stored proc in the database, you dont need to specify if the data is coming in or going out of ARC. Anyway, this is the script that calls EZ-DBMulti to log the event in the activitylog table.

USP_UPDATEACTIVITYLOG


USE [robot]
GO
/****** Object:  StoredProcedure [dbo].[usp_UpdateActivityLog]    Script Date: 1/29/2015 8:17:51 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Cochran
-- Create date: 01/28/2025
-- Description:	Logs the activity that has just been performed by the user and robot
-- test syntax usp_UpdateActivityLog 'David','Reminders', 1
-- =============================================
ALTER PROCEDURE [dbo].[usp_UpdateActivityLog]
	-- Add the parameters for the stored procedure here
	(
		@username VARCHAR(50),
		@activity VARCHAR(50),
		@robotID int
	)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    DECLARE @RecordFound int
	SET @RecordFound = 0
	DECLARE @UserID INT
	DECLARE @ActivityID INT 

	SET @RobotID = 1 

	SET @UserID = (SELECT [dbo].[Users].[UserID] FROM [dbo].[Users] WHERE [dbo].[Users].[UserName] = @username)

	SET @RecordFound = (
	SELECT 
		ActivityLog.ActivityID
	FROM
		[dbo].[ActivityLog] 
		INNER JOIN
		[dbo].[Activity] ON [dbo].[ActivityLog].ActivityID = [dbo].[Activity].ID
	WHERE
		[Activity] = @Activity
		AND [dbo].[ActivityLog].[UserID] = @UserID)

	IF @RecordFound > 0
		BEGIN
			UPDATE 
				ActivityLog
			SET 
				ActivityDateTime = GETDATE()
			WHERE
				ActivityID = @RecordFound
				AND
				UserID = @UserID
		END

	ELSE

		BEGIN
			SET @ActivityID = (SELECT ID FROM Activity WHERE Activity = @Activity)

			INSERT INTO 
				[dbo].[ActivityLog]
			(
				[UserID],
				[RobotID],
				[ActivityID],
				[ActivityDateTime] )
			VALUES
			(
				@userID,
				@RobotID,
				@ActivityID,
				GETDATE()
			)

	END


END

This is the stored procedure in the database that updates the activity log. It checks to see if an entry for that activity already exists in the activitylog table and updates it if it does exist. If the activity doesn't exist, it inserts a new log entry to log that activity.

USP_GETNEXTACTIVITY


USE [robot]
GO
/****** Object:  StoredProcedure [dbo].[usp_GetNextActivity]    Script Date: 1/29/2015 8:20:49 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Cochran
-- Create date: 01/28/2015
-- Description:	Gets an activity that hasnt been performed yet by the robot for the age group and activity time period for the user.
-- [usp_GetNextActivity] 'David'
-- =============================================
ALTER PROCEDURE [dbo].[usp_GetNextActivity] 
	(@username VARCHAR(50))
AS
BEGIN
	
	SET NOCOUNT ON;
	DECLARE @activity varchar(50)

    SET @activity = (SELECT TOP(1)
		[Activity]
	FROM
		[dbo].[Users]
			INNER JOIN 
				[dbo].[UserInfo] ON [dbo].[Users].[UserID] = [dbo].[UserInfo].[UserID]
			LEFT JOIN
				[dbo].[Activity] ON DATEDIFF(YEAR,[dbo].[UserInfo].Birthday,GETDATE()) < [dbo].[Activity].[AgeStop] AND DATEDIFF(YEAR,[dbo].[UserInfo].Birthday,GETDATE()) > [dbo].[Activity].[AgeStart]
			LEFT JOIN
				[dbo].[ActivityLog] ON [Activity].[ID] = [dbo].[ActivityLog].[ActivityID]
	WHERE
		[dbo].[Users].[UserName] = @username
		AND 
		(DATEDIFF(Minute,ActivityLog.ActivityDateTime,GETDATE()) > [dbo].[Activity].[ActivityPeriod]
		OR 
		ActivityLog.ActivityDateTime IS NULL))

	IF @activity = 'Rhymes'
	BEGIN
		
		DECLARE @UserID int
		SET @UserID = (SELECT UserID FROM USERS WHERE UserName = @username) 

		DECLARE @RhymeID INT
		SET @RhymeID = (SELECT 
			TOP(1) Rhymes.RhymeID
		FROM 
			Rhymes
			LEFT JOIN RhymeLog ON RhymeLog.RhymeID = Rhymes.RhymeID AND RhymeLog.UserID = @userID
		ORDER BY
			RhymeLog.LastReading)

		EXEC usp_UpdateRhymeLog @RhymeID,@UserID

		SELECT 
			Rhymes.RhymeText
		FROM 
			Rhymes
		WHERE RhymeID = @RhymeID
		

	END
	ELSE
	Begin
	SELECT @activity
	End
END


This stored procedure gets the next activity for the user of the robot. It contains the logic of what can be grabbed next based on the age of the user and the last time that activities were performed for that user.

With multiple robots whether left on or turned off, the user (once recognised by the robot) would not be told the same information by all of them. The multiple robots would use this script to be able to know what that user has already been told.

The Rhymes section of this stored procedure needs to be updated to allow the rhymes to tell the last time a rhyme was told so that it uses the timer in the Activity table instead of telling a new rhyme every minute.

Reminders would be things that you want to be told daily like when my daughter is recognized, it will tell her to put her homework on my desk to check. If I am recognized, it would tell me to take my meds and call my mom or something.

I am thinking about how I would implement the activity timers. The logic for timers is that the user would be able to tell the robot to remind them to do something at X time today. The robot would verify the request and then update the database. Every minute, the robot would check to see if there are any timers coming up to remind the user of. It would log when the timer was told to the user so that if the robot was off or if the user was not around at the time of the event, the next time that the user was recognized by the robot, they would be reminded.

Let me know if you have any questions.

#22  

I almost spit out my water when you said "give me a call....no Don't call me!" haha

Awesome video through, I could follow along well and I understand the DB design. Its very neat to see your design.

#23  

Jeez... David, your coding is stellar... I would love to loan my inMoov out to you for a few weeks just to see what you can do with him.... :)

#24  

Awesome Justin. I thought it was pretty funny, but DONT CALL ME :)

The path I am going down for this project definitely isn't for everyone or even most people. It requires some understanding of relational databases and how they work. It is for those who understand databases and want to have multiple robots work together or understand what each other is doing. For example, I would love for there to be a robot at the opening of a school year that could help new students by knowing their class schedule of directing them to the room they need to go to.

The inmoov that I am going to start in March (finances ya know) will be driven this way. I think it would be cool. Also, the AVM nav stuff in RoboRealm looks really cool. I want to mess with that so that the robot understands what a doorway (gate) is and allow it to do better navigation.

The ultimate goal is to have my current students be able to build an intelligent robot by the time they graduate that they can take with them. I want them to be able to Use ARC to its fullest potential Develop applications in C# that can tie into ARC Develop databases that can be used to store data for their robots. Develop interfaces to update the data in their databases 3D Model and print Understand and build the robot with an understanding of what components they are using and why, along with how they are powering the robot and why they choose that method.

Currently, 1/2 of my students are just being introduced to robotics through revolution robots. The other 1/2 are designing a robot (a car for JD) and we will be 3d printing it and building it. Next year we will take these students deeper into scripting and modeling. The next year it will be programming and database. So on and so forth. There will be new students every year from 4th grade. The potential becomes pretty huge.

I want to develop telepresence robots for students who have to be away from school. In one class we had 1 kid with open heart surgery, an injury to another that has caused her to have to be home schooled due to the discomfort of sitting in a classroom and another that has stomach issues and has missed a lot of school. In a class of 25, thats a lot of missed days that could have been solved with a telepresence robot. Multiple of these being able to communicate, and not caring which robot is used by which student is a big deal. Being database driven accomplishes a lot here. Also, having an application that the teacher can use to post assignments for each student is big. all of this leads into what I am doing here.

Anyway, Thanks for watching. I am glad you enjoyed the video. It seems to be becoming a trend for me to sign off with some sort of mess up :)

#25  

Thanks Richard. Once I get the inmoov going, I am sure that we will be sharing a lot of code. There are certain things about coding that I am trying to share, but its not my main focus. Together this forum will bring inmoov to its full potential.

#26  

ARC project

I will be updating this as I make changes.

I also placed a build script for the database here

I will update this as I make changes to the database.

Parts for the robot build should be here tomorrow so that part will be my focus over the weekend. One of the parts that is coming in is the board to make the mouth work. I will let you all know how that goes and how it gets wired in.

The rhymes timer wasn't working because I wasn't telling telling ARC to update the activity log table when rhymes were read.

fixed Brainfunction script below.


:Beginning
$UserActivity = ""
$SQLResult = ""
$SQLReturn = ""
#Identify next thing to tell the user from the database based on 
#who is using the robot and what has been told to the user within timmers
ControlCommand("Script Manager", ScriptStart, "GetUserActivityFromDB")
SLEEP(2000)
#Based on what came back from the database call one of the following or say that there is nothing new for them at this time.

#Holiday
IF($SQLReturn = "Check Dates")
  Sleep(2000)
  ControlCommand("Script Manager", ScriptStart, "GetPersonalHolidayFromDB")
  SLEEP(2000)
  IF(LENGTH($SQLReturn) > 0)
    SayEZB("Today is your " + $SQLReturn + ".") 
  ENDIF
  SLEEP(2000)
  ControlCommand("Script Manager", ScriptStart, "GetHolidayFromDB")
  SLEEP(2000)
  IF(LENGTH($SQLReturn) > 0)
    SayEZB("Today is your " + $SQLReturn + ".") 
  Endif
ControlCommand("Script Manager", ScriptStart, "LogEvent")

ELSEIF($SQLReturn = "Reminders")
  SayEZBWait("Add code for reminders like Rhymes")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
#Run the reminder query
#Say the information provided from the query
#Log Reminders event if called
ELSEIF($SQLReturn = "News")
  SayEZB("Here I would read the news")
#  ControlCommand("Script Manager", ScriptStart, "ReadNews")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Weather")
  SayEZB("Here I would read the weather")
#  ControlCommand("Script Manager", ScriptStart, "ReadWeather")
  Sleep(2000)
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Traffic")
  SayEZB("Here I would say the traffic")
#  ControlCommand("Script Manager", ScriptStart, "ReadTraffic")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ELSEIF($SQLReturn = "Timers")
  SAYEZB($UserActivity + " Checked every minute.")
  ControlCommand("Script Manager", ScriptStart, "LogEvent")

#Timers
#Get Timers from the database
#Speak the next timer
#Log Timers event if called

#Rhymes
#Move rhymes to database and use it to track which rhyme has been sent and when
ELSE
  SAYEZBWAIT($SQLReturn)
  ControlCommand("Script Manager", ScriptStart, "LogEvent")
ENDIF
Sleep (10000)

GOTO(Beginning)

#27  

I have added the ability to tell the robot to remind you of something using voice. It works but training your voice is important. You tell it the date and time and it will remind you 10 minutes before that date and time. You can only do the current year and the next year, but this should be good enough for now. It first asks you if you want to set a reminder for today, and if you say yes, it uses the current date, and then will ask you the time (once I finish getting that part developed). This is database driven as is the rest of the project. When you are reminded of the event, it logs that it has told you so that you wont be reminded again by any robot using the database.

Also, I have wired in the Scary Terry servo sound board and have a demo video of that. I will add a demo video of the event scheduling and reminders sometime this weekend. Video is posting to YouTube now and I will post here when it is complete.

#29  

hey David I've been following this post I would like to use it I going to look at your videos later to see if I can get your program working I don't have SQL I don't know if I need that but anyway, on a scary Terry board on the notes it says that any noise will make the mouth or job move just like the eb sound servo. at least that's what it says on the introduction of the instructions from the teri scary board document.

I am going to watch both your videos tonight or tomorrow morning to see if I can get your database running I think it's a great idea.

#30  

This is a video showing me using ARC to set reminders in a database and then retrieving those reminders from the database. I will add more into this ability as time goes on. This is the core functionality of this at this point but it is pretty cool to see happen.

#31  

Merne, you are correct. The solution is to pass things in dual channel. For example, the left channel would be for audio files and the right channel would be for speech. The board can be setup to only watch one of the two channels. I dont know of a way to do this yet with the EZ-B but my brain is working on it.

This robot will be largely just speaking like what I plan on doing with my Inmoov so I dont really have an issue with it, but if you were going to play songs and the like, you would want to break out the channels.

To use this you would need the following EZ-DBMulti from cochranrobotics.com rssGetter from cochranrobotics.com MSSQL Server (the express version is fine) MSSQL Server management tools Scary-Terry servo driver board if you want to make it just like this. The Database scripts from cochranrobotics.com RoboRealm and AVM Navigator

I also will need to update the scripts and the project file. I havent made any changes to EZ-DBMulti or rssGetter so you should be good there.

#32  

David thank you very much. I will give that a try probably tomorrow I just got off work actually so I'm kind of brain dead.

#33  

@Merne

I just uploaded the latest build script for the database to my website. I also updated the project in the cloud. I will be away most of today, but if you need any help getting things setup, let me know.

Thanks David

#34  

Okay, so I have decided to make an application that will allow someone to use this database easier. It will allow someone to populate the database with information instead of having to use SQL Server Management Studio to populate it. This app will allow your robot to do the following once complete.

Setup activities for your robot to perform on a timed basis. Add dates for holidays for the robot to tell you about. Add dates for personal holidays like birthdays, anniversaries or other dates that are important to you. Setup Rhymes (really could be anything that you want the robot to tell you without repeating itself) Setup reminders such as "Take your Meds" or "Call your mom or children" Allow you to setup timers that the robot will use to remind you of events such as meetings, phone calls, food in the oven or whatever the end list comes out to be.

It will also walk you through the steps to setup a robot and a user.

If I get really motivated, I might even build an install package and have it handle the install of MSSQL express for you. Once complete, this should give everyone who wants these types of features to be able to run some of their robot activities off of a database. Once I have the app built I will start a new thread. This is just to say that this robot is pretty much complete and I am using it as a platform to test what I am doing with the application I am developing. Now I need to come up with a cool name for it. That is always the hardest part for me as you can tell by the names rssGetter and EZ-DBMulti.:) Suggestions are welcome.

#35  

hi David I don't believe I'm going to be able to follow your post because I have USB cameras in the eyes of my inmoov, unless you know a workaround to enable me to use my USB cameras.

I don't believe ez-face will be able to use your database? I tried RoboRealm but I could not figure it out to use USB cameras because when I used Robo realm and tried using ezb's it would allow me to run both scripts are both programs at once using the USB cameras. I'm sure it was because I could not use the http because my cameras are USB.

do you or anybody else on this forum know a workaround for that thank you

#36  

There are a couple of modifications that you will need to make to use ez - face with it but it will work. You wouldn't need the custom http server in the project with ez - face and USB cameras (he is making changes to EZ-Face right now so this might change in the future) and you would have to format the string coming back from ez - face to remove the comma and space from the end of the variable ez - face uses. You would set the $UserName variable to a this.

If you have two cameras, you would be able to use one for the facial recognition and the other for ARC. If you don't have two, you would simply disable the ARC camera before you launch EZ-Face (which can be setup to automatically use a specific camera and automatically start facial recognition). You would then close EZ-Face and start up the camera again in ARC. Justins sample project does all of this so it would be a good reference to use.

There is no tie that links RoboRealm or ez - face directly to ez-dbmulti. ARC is linked to both of them so it is very doable.

#37  

Also, RoboRealm can be setup to use your usb camera and no modifications would need to be made to the project. You could just make some changes to what I did in RoboRealm and you would be good.

The reason RoboRealm was used is that EZ-Face cant recognize IP cameras at this point. Justin is working on changing EZ-Face to be able to do this. Once completed, I will make a version that uses EZ-Face instead of RoboRealm. I might even get creative and make one that you specify a variable as to which facial recognition software you are using and then it will use that one. One project to rule them all :)

Let me know which path you want to take and I will help you out.

#38  

The first part of the app is complete. Now to focus on an install that will install the needed components. This is actually the tough part. I am calling the app EZ-AI. More to come soon.

#39  

Teddy went out into the public today and was seen by about 300 people. The general feedback that I got was the he was awesome except for the one eye I put the camera it. Because it looked different than the other eye (which was unmodified, some people were a little freaked out by him.

I also showed off six, JD and Roli, along with another robot from the class that uses the ez robot developer kit. This was for an open house for the school that I help by teaching their elementary robotics course. Everyone was impressed by what these robots can do. They have allowed us to have a unique program in this area which attracts more students. EZ robot was defiantly the hit of the open house.

The head master said that he got many great comments about the program and the forward thinking of the school in this area. It is nice to be able to offer a program to students so eager to learn about robotics and ez-robot makes it possible. Thank you.

I have just a little bit more to do with Teddy before truly having him complete but I will video what I have completed soon and share.

PRO
Belgium
#40  

david

great to hear it was a sucses.

#41  

d.cochran, That is great the feedback was positive at the school open house. I look forward to the A.I. app you are working on, especially if can be simple to install and use. I attempted a program in Basic about 16 yrs ago that remembered the last time it interacted w someone, and different items about them, but nothing like what you are doing. It will be great to use Justins EZ Face along with A.I. together eventually. Thank you sharing your cool work. Steve S ;)

#42  

Thanks for the kind words Steve. I am trying to put a video out that shows the completed Teddy and the EZ-AI application as it stands now. It is going to be a long video so I am looking at ways to publish it. Just recorded it today, so its hot off the press.

If successful through youtube, it will be published to http://youtu.be/ODrbxVD9BdE

It looks like it will take a couple of hours to upload and process before I know if it was successful or not.

#43  

This is a long video showing Teddy and EZ-AI at this point. Grab some popcorn and a soda if your gonna watch it. Teddy is what I use to test EZ-AI right now. Please let me know if there are any other things that you can think of like what is in the video so that I can try to add them.

My time and energy is going to go into combining EZ-AI, EZ-DBMulti, rssGetter and maybe EZ-POP into one application. EZ-POP will be the last to be added. I will then focus on a good installer for the EZ-AI. Right now, these components are downloadable from CochranRobotics.com. I personally would advise waiting to download these until I have a chance to combine them into one application. If you feel adventurous, dive in and get them. EZ-AI was just placed on the site for download. There are STEP BY STEP instructions on getting this installed and configured to run in your environment. Also, the project is available here

As far as my coding style in the project, I try to have a script do one thing and one thing only. This allows me to debug the scripts easier, but also makes for a lot of scripts. If you want to combine some of them, feel free to. It may make it easier for you if you are not used to jumping all over when trying to follow what is happening in a script. You also will need EZ-DBMulti which doesn't have great instructions at the moment.

#44  

Hi David, you have written a very nice project. Very nice talent you have! Over my head confused but with your new EZ-AI and watching your video I have gotten everything setup except AVM navigator. I can not seem to find the software or plugin.

I have installed your EZ-AI and I think I have it setup correctly, but I need AVM Navigator and can't seem to find it, to follow your video setting up roborealm, do you mind helping out?

I plan to use the two USB cameras as you suggested. One for Roborealm and one for my robot since I have one camera in each eye.

Thank you!

#45  

AVM Navigator is on the RoboRealm site

http://www.roborealm.com/

Glad it's running. Let me know if you have any issues. I'll do what I can to help you use EZ-AI.

Also, I would love to see a video of it with one of your inmoovs.

You will want to setup information. In the EZ-AI tables. Specifically, you will need to setup users, userinfo , family and the familyTree. Also, you will need to add some activities. I will build a batch file for you to run to populate the activity table. I will do it tomorrow morning.

#46  

I have fixed the install process to handle adding activities to the Activity table as a part of the install so going forward this isnt an issue for those that install EZ-AI..

If you have already installed EZ-AI prior to the date of this message, you have one of two options Option 1. You will need 2 files to run a patch to do this for you.

you will need to grab these two files and place them in the correct location.

PopulateActivityTable.BAT can be placed in the C:\EZ-AI directory

SetupActivityTable.SQL can be placed in the C:\EZ-AI\Install directory.

Once these two files are in place, start the PopulateActivityTable.BAT by double clicking on it. Your Activity table will be populated with the the values that are listed in Option 2.

Option 2 An alternative to doing this process is to manually make these entries using the EZ-AI interface.

Check Dates 1440 1 120 Timers 1440 10 120 News 1440 14 120 Weather 60 14 120 Traffic 60 16 120 Reminders 1440 1 120 Rhymes 10 0 6 Songs 5 1 120

#48  

@d.cochran Thank you so much for sharing such detailed instructions. I too am working on a Teddy Ruxpin and am planning on following your instructions from the beginning so I can use the same settings, etc.

#49  

If you are going to use EZ-AI, I would be happy to help you out. It is a lengthy install. It has also come a long way since these posts.

#50  

Yes, I am planning on using your EZ-AI. I am excited about all it can do. I know several children who will want to play with Teddy and having it remember them is amazing. Thank you for your offer to help! I will take you up on that! I was following the thread for that as well.

#51  

Hello i'm interested by EZ-DBMulti (not EZ-AI for the moment) but i can't find it and this link is dead : http://cochranrobotics.com/Portals/0/EZ-DB%20Multi%20Source.zip Can you help me? Thanks

#52  

Hello wofty.

This was rolled into EZ-AI and is one of the core pieces that made that version of EZ-AI work. Because of this, and because there really were not many downloads of this app, I ended up killing it off in favor of people using EZ-AI.

In order to try to know how to help you, can you tell me what you are looking for? Also, can you tell me if you have any programming experience with C#? This should give me the information that I need to try to figure out the best way to assist.

If you have experience with C#, I would be happy to let you know what this did and how it did it. It would be possible to develop a plugin that does what EZ-DBMulti did but may take some time for me due to other obligations. If I were rewriting it with what is now available, I would definitely make it a plugin.

Thanks David