Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inactivity timer: if no activity after timeout, zero twist #25

Open
wants to merge 1 commit into
base: indigo-devel
Choose a base branch
from

Conversation

c-andy-martin
Copy link

Add an inactivity timer. Some wireless joysticks constantly transmit
data (such as the Play Station Dualshock4). In such cases, it is
possible to determine that the joystick is out of range and stop
motion by the fact that activity slows down or ceases. This is useful
for teleop in the case that the robot leaves range and a twist gets
stuck commanding the robot to move without stopping. In this case, the
inactivity timeout would detect no more messages after the threshold
and send a zero twist (just as if the enable button were released).
The default is for the inactivity timeout to be disabled. It can be
enabled by setting the inactivity_timeout parameter.

@vincentrou
Copy link
Contributor

This is an interesting feature but I think it should go in the joystick_drivers. The joy node could publish a Joy msg with every field at zero when the connection is lost. This will benefit every node that use the Joy msg and not only the teleop.
They already have this issue :
ros-drivers/joystick_drivers#92

@c-andy-martin
Copy link
Author

While it may be good to have the joystick driver do something when it does not receive packets, it is not clear to me that publishing all zeroes is the correct thing to do, as what the buttons mean and do depends on the application and how it uses the joystick. I strongly favor having a layer of protection in the ros-teleop node as it can behave intelligently for joysticks which do send packets regularly. The ros-teleop node can then correctly interpret this at the application level to stop motion of the robot base with a zero twist message. We have been using this change on our robot base with much success to safely teleop the robot in a noisy RF environment.

Add an inactivity timer. Some wireless joysticks constantly transmit
data (such as the Play Station Dualshock4). In such cases, it is
possible to determine that the joystick is out of range and stop
motion by the fact that activity slows down or ceases. This is useful
for teleop in the case that the robot leaves range and a twist gets
stuck commanding the robot to move without stopping. In this case, the
inactivity timeout would detect no more messages after the threshold
and send a zero twist (just as if the enable button were released).
The default is for the inactivity timeout to be disabled. It can be
enabled by setting the inactivity_timeout parameter.
@c-andy-martin
Copy link
Author

I have rebased this PR onto 0.1.3

@c-andy-martin
Copy link
Author

This is related to #27

@Ktysai
Copy link

Ktysai commented Oct 19, 2020

May I put a +1 in this one request? The battery on my joystick just dies and it was a good thing that the robot was the the wheels up! 👍

@c-andy-martin , can you help me a little bit with your implementation?

@c-andy-martin
Copy link
Author

@Ktysai exactly what do you want help with? You need to be using a joystick that sends packets periodically for my changes to be useful, not sure what kind of joystick you are using. The PS4 joysticks we use constantly transmit as they have IMUs in them, so this change works well for us.

@Ktysai
Copy link

Ktysai commented Oct 19, 2020

In my case is an old joystick, a clone for PS3.
I'm a n00b regarding ROS, and I've had trouble finding the *.cpp file in my Ubuntu machine.

Do I have to copy all the content available here into the original *.cpp?

The launch file will have a new argument, what will be the name of it. As I've said, noob questions.

In case my joystick does not send periodically signals, what solution you think will be proper?

All the best!

@c-andy-martin
Copy link
Author

@Ktysai, IIRC the PS3 remote does not send periodic packets. My change won't help you much in that case, unless you are constantly jiggling the stick to keep it sending data rapidly, or constantly push/release a button while driving. To build the change, checkout the git branch for this pull request into a catkin_ws. I use catkin_tools and do a catkin build to build the code and run it. Yes, you would need to add the inactivity_timeout parameter to get the feature to work.

@Ktysai
Copy link

Ktysai commented Oct 22, 2020

@c-andy-martin, thanks for sharing!

There is a how to regarding this catkin_tools and catkin build? I'm on ubuntu 18 & ROS Melodic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants