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 a teleop plugin that sends twist commands #186

Closed
chapulina opened this issue Mar 3, 2021 · 8 comments
Closed

Add a teleop plugin that sends twist commands #186

chapulina opened this issue Mar 3, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chapulina
Copy link
Contributor

A GUI plugin that has arrow buttons and publishes twist messages to a custom topic to control robots would be nice to test vehicles easily.

Desired behavior

The user loads a world in ign-gazebo that has a vehicle in it, like ign gazebo diff_drive.sdf.

Then the user can insert the GUI twist teleop plugin, set the desired topic, and start sending commands by pressing buttons or keys, or with sliders.

Alternatives considered

The approach currently taken for teleop is using KeyPublisher + TriggeredPublisher as described on the moving robot tutorial. This can be inconvenient because:

  • There's no way to load and configure TriggeredPublisher at runtime yet (Insert system plugins from the GUI gz-sim#190), so it needs to be hardcoded in the SDF file.
  • The combination of controls that can be made with that approach is very limited, because the speed has to be hardcoded. It isn't possible for example to increment the speed at each click.

Implementation suggestion

The rqt_robot_steering plugin for ROS has vertical and horizontal sliders to control throttle and steering.

@chapulina chapulina added enhancement New feature or request good first issue Good for newcomers labels Mar 3, 2021
@LolaSegura
Copy link
Contributor

LolaSegura commented Jun 11, 2021

I am tackling this on my branch: on the latest commit I added the buttons functionality
31c4a4b

TestingPlugin.mp4

You can set the desire topic and change the module of the linear and angular velocities.

For now it can only be controlled clicking on the buttons. So the next steps would be :

  • Allow moving the robot using keys.
  • Adding a switch to enable-disable the plugin.

@jennuine
Copy link
Contributor

Looks good @LolaSegura ! A suggestion would be to add a stop button. Also, it would be nice to turn while driving forward/backward (for example, driving forward and turning left at the same time)

@chapulina
Copy link
Contributor Author

I am tackling this on my branch

Nice! Looking good!

it would be nice to turn while driving forward/backward (for example, driving forward and turning left at the same time)

+1, that would be very helpful! I believe that's why the robot steering plugin linked above uses sliders instead of buttons.

But I think we can also achieve the same with buttons. For example, when the user presses "forward", we increment the forward velocity instead of setting it. So the more the user presses forward, the faster the robot goes. Then the same number of backward presses results in the robot slowing down until it stops. Pressing right while there's some forward velocity would make the robot go forward while rotating, etc.


Another idea is to use unicode characters with arrows on the buttons instead of the words "Forward", etc.

@francocipollone
Copy link
Contributor

francocipollone commented Jun 15, 2021

Looks good @LolaSegura ! A suggestion would be to add a stop button. Also, it would be nice to turn while driving forward/backward (for example, driving forward and turning left at the same time)

That's a great idea. Actually, Lola has implemented these buttons too:

image
This is wip so the buttons could be replaced by something else to be more user-friendly.

Another idea is to use unicode characters with arrows on the buttons instead of the words "Forward", etc.

+1000.

But I think we can also achieve the same with buttons. For example, when the user presses "forward", we increment the forward velocity instead of setting it. So the more the user presses forward, the faster the robot goes. Then the same number of backward presses results in the robot slowing down until it stops. Pressing right while there's some forward velocity would make the robot go forward while rotating, etc.

I think that approach is interesting, it is definitely good to mix forward/backward movement and clockwise rotation at the same time however I feel like probably it would be a bit confusing for the user.

What about the following:

  • [Buttons]Having buttons to move in 8 directions + stop as it is shown in the previous image. Pressing these buttons will send a twist message with the angular and linear velocity that is described in the text fields.
  • [Keys]Allow pressing keys from the keyboard. Replicate functionality with the buttons in the visualizer.
    Typically: W: forward, A: left, X: backward, D: right., S: stop. (And Q, E, Z and C for the combinations)
    • Having a switch to enable/disable key pressing is necessary to avoid an involuntary command. (Up here is implemented so far)
    • It would be nice to visually press the buttons when a key in the keyboard is pressed so as to match behavior.
    • Having keys to rapidly increment and decrement the velocities is useful too, the text in the fields should be paired with this change. (Probably not mandatory but it is a nice enhancement.)
  • [Sliders]We can also add two sliders to replicate the behavior of rqt_robot_steering if it is useful to have. We could add a switch to enable/disable the sliders.

Alternative:
If you consider it is too many features in one plugin probably leaving the keys and the sliders and removing the buttons could be ok given that the keys and buttons have similar functionality.

Wdyt @chapulina ? I am ok with either option but I wanted to bring this option to the table too. You certainly have more insight about what could be more useful to the users than me 😄

@francocipollone
Copy link
Contributor

(Sorry for the noise, I hit some key combination by mistake)

@chapulina
Copy link
Contributor Author

W: forward, A: left, X: backward, D: right., S: stop. (And Q, E, Z and C for the combinations)

+1 to having WASD+ keys. The advantage of keys over buttons is that the user can press more than one at the same time. So we could achieve the linear + angular combinations by combining keys instead of using new keys. For example, front + right would be W + D instead of Q.

Having buttons to move in 8 directions + stop

I'm ok with that. That's the approach in turtlebot_teleop, for example.

Another idea that came to mind is to make just 4 buttons that are togglable. So the user could enable front and right at the same time. The advantage would be that:

  • we have less buttons
  • the user knows the current state of the controller by looking at the widget and seeing which buttons are checked

Sliders

If it's not too difficult, I think they'd be a nice addition. Similar to the idea above, they allow throttle + steer combinations while providing visual feedback of the current command.

You certainly have more insight about what could be more useful to the users than me smile

Not sure about that 😉 In the end of the day, the best approach is to write something, then have someone else try to use it. In the end of the day, there's no ideal GUI control for 2D movement - that's why we have joysticks! 😄

@LolaSegura
Copy link
Contributor

LolaSegura commented Jun 18, 2021

Another idea that came to mind is to make just 4 buttons that are togglable. So the user could enable front and right at the same time.

I implemented this idea so now there are only 5 togglable buttons. 4 for direction and 1 for stopping the vehicle. So now for turning while moving forward you have to push both 'forward' and 'right' buttons for example.
I also change the forward, left, right and backward text of the buttons for black triangles pointing to the direction. I couldn't think of any symbol for the stop button so I left it as it was. But any suggestions are welcome.
I added some visual feature so that it shows which buttons are toggled at the moment.

The advantage of keys over buttons is that the user can press more than one at the same time. So we could achieve the linear + angular combinations by combining keys instead of using new keys.

I implemented this as well. So now the keys available for moving the vehicle are W, A, D and X. I didn't include any key for stopping because the vehicle only moves while the keys are pressed.

Here is a video showing the plugin with all I mentioned before.

122595556-09270000-d03f-11eb-8d2f-969c4e61b685.mp4

The next steps to follow would be:

  • Adding sliders.
  • Solve a bug that appears when you first use the buttons and then the keyboard.

@chapulina
Copy link
Contributor Author

That looks great, @LolaSegura ! Feel free to open a PR once you're ready!

The last recommendation I have is to use Material Design controls so the UI looks a bit more modern. I think that changing to these imports should do the trick:

import QtQuick 2.9
import QtQuick.Controls 2.2

See for example how the Publisher plugin's TextField and Switch have a more modern look and make use of the UI's color scheme for highlights:

pub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants