ALEXA ROS VOICE COMMAND TURTLEBOT
I have been able to integrated alexa to ROS, and in general terms it works, the problem is that when I send a command to alexa and it publishes a topic, turtlebot keeps listening to it, and for example, when I say forward, that is not a big deal because I can simply tell turtlebot to stop, but I find it kind of a problem when I say turn left or turn right, because it keeps going left or right, I am not sure how to solve this.
Type of messages I am publishing= geometry messages/ twist
My ideas:
1- Create a subscriber that subscribes just for a certain time then close and subscribes when a new command is publish.
Disadvantage: To go forward would required a longer time than going for the sides, so maybe would not solve the problem
2- Create a subscriber that subscribes gets only one message closes and subscribes when a new message is publish.
Disadvantage: to go forward just one time, would not solve this problems but would just create the exact opposite problem
I saw that for the second case I can use this but I am not sure how to.
ros::topic::waitForMessage(..)
The code I have for the subscriber at the moment is this.
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd)
{
ROS_INFO("I heard: [%f]", vel_cmd.linear.y);
std::cout << "Twist Received " << std::endl;
}
int main( int argc, char* argv )
{
ros::init(argc, argv, "turtl" );
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/cmd_vel", 1000, cmd_vel_callback);
while( n.ok() )
{
ros::spin();
}
return 1;
}
alexa ros voice
add a comment |
I have been able to integrated alexa to ROS, and in general terms it works, the problem is that when I send a command to alexa and it publishes a topic, turtlebot keeps listening to it, and for example, when I say forward, that is not a big deal because I can simply tell turtlebot to stop, but I find it kind of a problem when I say turn left or turn right, because it keeps going left or right, I am not sure how to solve this.
Type of messages I am publishing= geometry messages/ twist
My ideas:
1- Create a subscriber that subscribes just for a certain time then close and subscribes when a new command is publish.
Disadvantage: To go forward would required a longer time than going for the sides, so maybe would not solve the problem
2- Create a subscriber that subscribes gets only one message closes and subscribes when a new message is publish.
Disadvantage: to go forward just one time, would not solve this problems but would just create the exact opposite problem
I saw that for the second case I can use this but I am not sure how to.
ros::topic::waitForMessage(..)
The code I have for the subscriber at the moment is this.
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd)
{
ROS_INFO("I heard: [%f]", vel_cmd.linear.y);
std::cout << "Twist Received " << std::endl;
}
int main( int argc, char* argv )
{
ros::init(argc, argv, "turtl" );
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/cmd_vel", 1000, cmd_vel_callback);
while( n.ok() )
{
ros::spin();
}
return 1;
}
alexa ros voice
add a comment |
I have been able to integrated alexa to ROS, and in general terms it works, the problem is that when I send a command to alexa and it publishes a topic, turtlebot keeps listening to it, and for example, when I say forward, that is not a big deal because I can simply tell turtlebot to stop, but I find it kind of a problem when I say turn left or turn right, because it keeps going left or right, I am not sure how to solve this.
Type of messages I am publishing= geometry messages/ twist
My ideas:
1- Create a subscriber that subscribes just for a certain time then close and subscribes when a new command is publish.
Disadvantage: To go forward would required a longer time than going for the sides, so maybe would not solve the problem
2- Create a subscriber that subscribes gets only one message closes and subscribes when a new message is publish.
Disadvantage: to go forward just one time, would not solve this problems but would just create the exact opposite problem
I saw that for the second case I can use this but I am not sure how to.
ros::topic::waitForMessage(..)
The code I have for the subscriber at the moment is this.
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd)
{
ROS_INFO("I heard: [%f]", vel_cmd.linear.y);
std::cout << "Twist Received " << std::endl;
}
int main( int argc, char* argv )
{
ros::init(argc, argv, "turtl" );
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/cmd_vel", 1000, cmd_vel_callback);
while( n.ok() )
{
ros::spin();
}
return 1;
}
alexa ros voice
I have been able to integrated alexa to ROS, and in general terms it works, the problem is that when I send a command to alexa and it publishes a topic, turtlebot keeps listening to it, and for example, when I say forward, that is not a big deal because I can simply tell turtlebot to stop, but I find it kind of a problem when I say turn left or turn right, because it keeps going left or right, I am not sure how to solve this.
Type of messages I am publishing= geometry messages/ twist
My ideas:
1- Create a subscriber that subscribes just for a certain time then close and subscribes when a new command is publish.
Disadvantage: To go forward would required a longer time than going for the sides, so maybe would not solve the problem
2- Create a subscriber that subscribes gets only one message closes and subscribes when a new message is publish.
Disadvantage: to go forward just one time, would not solve this problems but would just create the exact opposite problem
I saw that for the second case I can use this but I am not sure how to.
ros::topic::waitForMessage(..)
The code I have for the subscriber at the moment is this.
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd)
{
ROS_INFO("I heard: [%f]", vel_cmd.linear.y);
std::cout << "Twist Received " << std::endl;
}
int main( int argc, char* argv )
{
ros::init(argc, argv, "turtl" );
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/cmd_vel", 1000, cmd_vel_callback);
while( n.ok() )
{
ros::spin();
}
return 1;
}
alexa ros voice
alexa ros voice
asked Nov 14 '18 at 13:02
강천사강천사
64
64
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your problem is you cannot just stop subscribing and subscribe again which is not optimal.
there's 2 way you can do this :
you can remove
ros::spin()
and useros::spinOnce()
ask subscriber to get new data after your previous task is done (You said for forward moving it takes longer and for sides takes shorter) you can call it after you can verify the task is done anywhere in the code.get output from subscriber and store it inside another variable and add another control function inside your
while(n.ok())
to act on the previous data or to change to new data came from subscriber.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300885%2falexa-ros-voice-command-turtlebot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your problem is you cannot just stop subscribing and subscribe again which is not optimal.
there's 2 way you can do this :
you can remove
ros::spin()
and useros::spinOnce()
ask subscriber to get new data after your previous task is done (You said for forward moving it takes longer and for sides takes shorter) you can call it after you can verify the task is done anywhere in the code.get output from subscriber and store it inside another variable and add another control function inside your
while(n.ok())
to act on the previous data or to change to new data came from subscriber.
add a comment |
Your problem is you cannot just stop subscribing and subscribe again which is not optimal.
there's 2 way you can do this :
you can remove
ros::spin()
and useros::spinOnce()
ask subscriber to get new data after your previous task is done (You said for forward moving it takes longer and for sides takes shorter) you can call it after you can verify the task is done anywhere in the code.get output from subscriber and store it inside another variable and add another control function inside your
while(n.ok())
to act on the previous data or to change to new data came from subscriber.
add a comment |
Your problem is you cannot just stop subscribing and subscribe again which is not optimal.
there's 2 way you can do this :
you can remove
ros::spin()
and useros::spinOnce()
ask subscriber to get new data after your previous task is done (You said for forward moving it takes longer and for sides takes shorter) you can call it after you can verify the task is done anywhere in the code.get output from subscriber and store it inside another variable and add another control function inside your
while(n.ok())
to act on the previous data or to change to new data came from subscriber.
Your problem is you cannot just stop subscribing and subscribe again which is not optimal.
there's 2 way you can do this :
you can remove
ros::spin()
and useros::spinOnce()
ask subscriber to get new data after your previous task is done (You said for forward moving it takes longer and for sides takes shorter) you can call it after you can verify the task is done anywhere in the code.get output from subscriber and store it inside another variable and add another control function inside your
while(n.ok())
to act on the previous data or to change to new data came from subscriber.
answered Nov 21 '18 at 15:53
Mohammad AliMohammad Ali
34029
34029
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300885%2falexa-ros-voice-command-turtlebot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown