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
Jump to end

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

#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.