ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Python-Code: voice control for navigate a turtlebot to a specific point on map

asked 2020-07-08 12:46:30 -0600

El_Presidente gravatar image

updated 2020-07-08 15:32:27 -0600

Hello,

I am a beginner in programming with ROS and Python. In my project I would to command a turtlebot in a hospital floor plan map (rviz) with voice control, so if I say: "go to room 7", the turtlebot drive to this specific point on map. I have two finished Python programs, voice_control_example.py (voice control with commands like "left", "right", "forward" and "back", but not for specific points on map) and go_to_specific_point_on_map.py (in the point variable I can define the x and y attribute for the point and the turtlebot start to drive to this point but without voice control). My plan is to make one Python program out of two and I call this one voice_control.py. If I start the program and test it with "rostopic pub -1 /kws_data std_msgs/String "go to room 7", than its working and it published in /kws_data. The issue is that the turtlebot do nothing and in the rqt_graph the rostopic kws_data is not integrated. Where is my mistake in the code?

#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
Copyright (c) 2015, Mark Silliman
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''

import rospy
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
import actionlib
from actionlib_msgs.msg import *
from geometry_msgs.msg import Pose, Point, Quaternion, Twist
from std_msgs.msg import String

class GoToPose():
    def __init__(self):

        self.goal_sent = False

        # initialize node
        rospy.init_node('asr_control', anonymous=False)
#        rospy.init_node("asr_control")

    # What to do if shut down (e.g. Ctrl-C or failure)
    rospy.on_shutdown(self.shutdown)

    # Tell the action client that we want to spin a thread by default
    self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
    rospy.loginfo("Wait for the action server to come up")

    # Allow up to 5 seconds for the ...
(more)
edit retag flag offensive close merge delete

Comments

Can you post the output of rqt_graph? Make sure it shows all nodes and topics, including disconnected topics.

Geoff gravatar image Geoff  ( 2020-07-08 18:47:19 -0600 )edit

Put a few debug lines in there so you can verify if the callback is being called and if the 'if' statement catches, and if the goto function is called, etc. Check to verify you're subscribed to the topic. Indentation before you subscribe has me a bit confused.

billy gravatar image billy  ( 2020-07-09 12:06:59 -0600 )edit

Have nobody a solution for the goto() function? :/

El_Presidente gravatar image El_Presidente  ( 2020-08-10 09:35:39 -0600 )edit

can you share the code that already done??

kia gravatar image kia  ( 2022-05-16 21:30:34 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-08-03 17:48:19 -0600

El_Presidente gravatar image

Sorry for the late answer, I find out that the voice commands were read in the rostopic, but the function goto() for the robot drive was not called. How can I called this function with the self, position and quaternion variable?

edit flag offensive delete link more

Comments

1

Please don't add additional information for your question in an answer. Make a comment on your question if you have additional information to add.

You're only calling goto() in one specific condition of your callback function:

detected_words.data.find("go to room 7") > -1 or detected_words.data.find("geh in Zimmer 7") > -1

Are you sure that condition is being matched?

Geoff gravatar image Geoff  ( 2020-08-10 18:39:33 -0600 )edit

Oh ok sorry, now I know it :D detected_words.data.find("go to room 7") > -1 or detected_words.data.find("geh in Zimmer 7") > -1 this one was an example call for goto() and it doesn#t work. If I simulate in the rostopic with the command "go to room 7", the program are reading this and with printf I check for every command and everything was read correctly. The goto() function was not called by check it with printf command, I need a function call for this with the self variable and doesn't know however I can realize it.

El_Presidente gravatar image El_Presidente  ( 2020-08-11 11:49:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-08 12:46:30 -0600

Seen: 469 times

Last updated: Jul 08 '20