Ask Your Question
0

move_base and arduino interaction

asked 2018-03-06 11:51:14 -0500

abdelkrim gravatar image

updated 2018-03-07 08:30:51 -0500

gvdhoorn gravatar image

hello i have an issue in my move_base and my arduino interaction ( robot description : robot with four wheels drive controlled by arduino i subscribe by arduino node to cmd_vel and controll the 4 motors ) I gave a goal to the robot , the robot navigate autonomously, when it reached the goal pub { 0 0 0 0 0 0 } and stopped publishing into /cmd_vel but my robot keep moving it didn't sub to the last msg in /cmd_vel and keep moving with the before last /cmd_vel data when i use keyboard it stoppet arduino code :

messageCb( const geometry_msgs::Twist& t)
 { 
.....
 } 
ros::Subscriber<geometry_msgs::twist> sub("/cmd_vel", &messageCb ); 
void setup() 
{
 ... 
nh.initNode();
 nh.subscribe(sub);
 } 
void loop() 
{ 
 nh.spinOnce(); delay(50);
}
edit retag flag offensive close merge delete

Comments

May I suggest a title chance? Your question seems to be more about how to deal with missed messages and robots that are controlled by velocity inputs. move_base and drivers that accept Twist are just one example of such a setup, and the question is therefor much broader.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-07 04:11:20 -0500 )edit

thank you yes i see :)

abdelkrim gravatar image abdelkrim  ( 2018-03-07 04:50:24 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-07 04:09:30 -0500

gvdhoorn gravatar image

updated 2018-03-07 08:37:14 -0500

Your question is a bit implied, but what you noticed (your robot not stopping after the last command input has been given) is typically addressed by adding a time-out mechanism to your driver.

Keep track of when the last Twist was received and if dt becomes too large, automatically stop.

That way even missed 'stop' commands won't lead to your robot continuing on forever, as it will have timed out long before.

Note that adding such a time-out mechanism to your base driver (ie: the code running on your Arduino) will require your Twist producer to keep publishing new messages at a rate at least as high as the inverse of the time-out you've configured your driver to use.


Edit: thanks for the code, but I don't see any timeout -- or at least, not implemented in a way I would expect given your initial question.

I'm also rather uncertain as to what your question now is: what is it that you feel is not working now / not appropriate to do? I only see a single Subscriber (good). Are you saying there is a 0.5 second delay between publishing a Twist and receiving it in your callback?

edit flag offensive delete link more

Comments

thank you for reply yeah i have a time-out in the running on my Arduino at least it keep 0.5 seconde to subscribe to new twist msgs so the new question is how i can reduce the rate of twist msg published by my move_base ? it is controller frequency parameters which i have to modify !!

abdelkrim gravatar image abdelkrim  ( 2018-03-07 04:47:17 -0500 )edit

it keep 0.5 seconde to subscribe to new twist msgs

are you re-subscribing to the topic in a loop?

gvdhoorn gravatar image gvdhoorn  ( 2018-03-07 05:29:49 -0500 )edit

yes at least 0.5 seconde because there are some instructions to control the 4 wheels inside messageCb no at the end of messageCb ros::Subscriber<geometry_msgs::twist> sub("/cmd_vel", &messageCb );

abdelkrim gravatar image abdelkrim  ( 2018-03-07 05:40:21 -0500 )edit

It's up to you, but I would rethink your implementation. Can you explain why you unsubscribe? This is a rather unusual thing to do.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-07 07:51:00 -0500 )edit

unsubscribe i didn't :o if i increase controller frequency that will confused something other ??

abdelkrim gravatar image abdelkrim  ( 2018-03-07 07:53:55 -0500 )edit

can you please add some parts of your code to your question? If you don't unsubscribe, why do you create new ros::Subscriber instances then? You typically only need one?

gvdhoorn gravatar image gvdhoorn  ( 2018-03-07 08:02:17 -0500 )edit

I cannot say whether changing controller frequency will affect the rest of your system. But I'm also not sure whether it's really needed.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-07 08:02:54 -0500 )edit

i fixed i set controller frequency to 0.5 and its good now thank you so much

abdelkrim gravatar image abdelkrim  ( 2018-03-07 08:43:40 -0500 )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: 2018-03-06 11:51:14 -0500

Seen: 324 times

Last updated: Mar 07 '18