Ask Your Question
1

Publishing to speech topic on the Nao.

asked 2014-02-22 19:51:17 -0600

dnth gravatar image

I am trying to publish to the speech topic on using the nao_driver package. What did I miss out?

#! /usr/bin/env python

import rospy
from std_msgs.msg import String

from dynamic_reconfigure.server import Server as ReConfServer
from nao_driver.cfg import nao_speechConfig as NodeConfig
from nao_driver import NaoNode
from naoqi import (ALBroker, ALProxy, ALModule)
from std_srvs.srv import( Empty, EmptyResponse )
from nao_msgs.msg import( WordRecognized )

def talker():
    pub = rospy.Publisher('speech', String)
    rospy.init_node('talker')
    while not rospy.is_shutdown():
        str = "hello world %s" % rospy.get_time()
        rospy.loginfo(str)
        pub.Publish(String(str))
        rospy.sleep(1.0)

if __name__=='__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass

The output on the console:

No handlers could be found for logger "rosout"
edit retag flag offensive close merge delete

Comments

This is looking good. Is the nao_speech node running and volume turned up? Check that your node properly connects to nao_speech with `rqt_graph`. Afaik you can ignore the "No handlers can be found..." error.

AHornung gravatar image AHornung  ( 2014-02-24 02:59:32 -0600 )edit

I tried to do this but the robot takes a lot of time to respond. I created a loop for publishing hello world over the speech topic and the robot responds very late the the first few hello worlds. Can u please help me? http://answers.ros.org/question/171331/real-nao-robot-responding-very-slow-to-the-topic-published-with-ros/

uzair gravatar image uzair  ( 2014-06-17 16:05:41 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-02-24 12:38:43 -0600

dnth gravatar image

I got it working with the codes below. Hope this helps those who's trying to familiarize with programming the Nao on ROS

#!/usr/bin/env python
import rospy
from std_msgs.msg import String

def naotalker():
    pub = rospy.Publisher('chatter', String)
    rospy.init_node('naotalk')
    while not rospy.is_shutdown():
        str = "hello world"
        rospy.loginfo(str)
        pub.publish(String(str))
        rospy.sleep(1.0)

if __name__ == '__main__':
    try:
        naotalker()
    except rospy.ROSInterruptException:
        pass
edit flag offensive delete link more

Comments

shouldnt you be publishing over the topic "speech" instead of the "chatter"? Can you please help me with my question here? http://answers.ros.org/question/171331/real-nao-robot-responding-very-slow-to-the-topic-published-with-ros/

uzair gravatar image uzair  ( 2014-06-09 19:54:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-02-22 19:51:17 -0600

Seen: 457 times

Last updated: Feb 24 '14