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

rosserial Arduino not stopping while pressing ctrl +c or ctrl +z

asked 2019-09-25 02:45:05 -0500

kallivalli gravatar image

updated 2019-09-27 01:46:12 -0500

Hello ,i have raspberry pi model 3 b+ in which i run my launch file which contains rosserial commandrosrun rosserial_python serial_node.py _port:=/dev/ttyACM1 _baud:=115200,rplidar and my node a program for moving my robot forward ,while stopping means while i press ctlr+c or ctlr+z on terminal rosserial wont stop and robot moves continously . is there any solution for stopping rosserial as i see it is only which make robot moving

edit retag flag offensive close merge delete

Comments

Are you sure it's the only node staying alive ? After a CTRL+C (which send a SIGINT signal) if the node is still alive after 15 seconds (the default timeout) then a SIGTERM signal should be sent and the node should exit. Is this what happen ?

Delb gravatar image Delb  ( 2019-09-25 03:09:56 -0500 )edit

In addition to what @Delb has said, are you sure the robot isn't continuing to move because the hardware is stuck in a particular state and the rosserial node has actually been shut down. Or can you still see the rosserial node when you list running processes using the ps -A command?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-09-25 06:15:45 -0500 )edit

i have attached screenshot and its look like that ,sometimes it will print wrong topic id and msgs and sometimes it wont but my robot moves continously

kallivalli gravatar image kallivalli  ( 2019-09-26 23:50:01 -0500 )edit

Please don't use an image to display text. Images are not searchable and people cannot copy and paste the text from the image. Please update your question with a copy and paste of the text instead. See the support page

jayess gravatar image jayess  ( 2019-09-27 01:20:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-27 03:58:51 -0500

There is a good chance that your problem is caused because the code on your micro controller doesn't terminate when the nodes running on your raspberry pi are shutdown. This is causing your robot to continue moving at the final velocity it was commanded to.

There is a convention and a strong safety reason why you should write your micro-controller code so this is impossible. The serial connection could be lost for many reasons, computer crashes, serial cable unplugged, etc. In all these cases you want your robot to stop moving as quickly as possible.

This is achieved by writing code which sets the target velocity to zero if a cmd_vel message hasn't been received within a set period of time. If your cmd_vel topic usually runs at 100 Hz then a half second limit should allow it to ignore brief gaps in messages but also stop quickly enough if the serial connection is lost. Using this approach your robot will always stop whenever the rosserial node is closed.

Hope this helps.

edit flag offensive delete link more

Comments

im having teleop code which uses cmd_vel and which stops while target velocity is set to zero,i have wall following code using lidar thats the one which dont stop

kallivalli gravatar image kallivalli  ( 2019-09-27 23:10:10 -0500 )edit

Can you clarify two things. using ps -A can you check if any of your ROS nodes on the pi are not being shutdown? Does your micro controller code stop the robot if it doesn't receive a cmd_vel message after a certain period of time (if not this needs to be added)?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-09-28 05:01:57 -0500 )edit

ps -A doesn't contain rosserial but the machine is still moving and should I change my code in ros node to do that rather than in microcontroller? like if I press ctrl + c it should send the d signal to both motors as 0,0 pwm values ?

kallivalli gravatar image kallivalli  ( 2019-09-30 06:35:28 -0500 )edit

No you should change the code on the microcontroller so that if it doesn't receive a cmd_vel message within half a second it stops all motors. This is very important because you want it to fail safe in a range of situations, not just when you press ctrl + c

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-09-30 06:40:41 -0500 )edit

thank you very much ,i will check on that

kallivalli gravatar image kallivalli  ( 2019-09-30 06:54:18 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-09-25 02:45:05 -0500

Seen: 750 times

Last updated: Sep 27 '19