Connecting Ps3 controller to gazebo

I would like to know if it is possible to use the Ps3 controller to navigate the Rosbot around in gazebo? Using the teleop keyboard is tedious. Having a physical controller to use would be nice.

I am using Ubuntu 16.04 and Ros kinetic.

So far I have installed the drivers. I am getting the controller to publish data but currently it seems to just replace the mouse instead of moving the Rosbot around.

In my ~/ros_workspace/src/rosbot_description/src/rosbot_navigation folder I have made the ps3.launch

I am using the command: roslaunch rosbot_navigation ps3.launch
The ps3.launch file which reads

<?xml version="1.0"?>
<launch>
  <node pkg="joy" type="joy_node" name="ps3_joy" output="screen" >
    <param name="dev" type="string" value="/dev/input/js0" />
    <param name="deadzone" value="0.12" />
  </node>

  <node pkg="diagnostic_aggregator" type="aggregator_node" name="diagnostic_aggregator" >
    <!-- Load the file you made above -->
    <rosparam command="load" file="$(find ps3joy)/diagnostics.yaml" />
  </node>


</launch>

Any suggestions would be GREAT!
Thank you!




This last picture is after running roslaunch rosbot_navigation ps3.launch
I followed these to install the necessary components to get the Ps3 controller to work with ubuntu.
sudo apt-get install ros-kinetic-joystick-drivers

http://wiki.ros.org/ps3joy/Tutorials/PairingJoystickAndBluetoothDongle

Hello JB_KSU,

Your joystick seems to be working fine, joy topic that is published contains state of every button and axis.

To control ROSbot you need to convert axis values to velocity commands. It can be done with teleop_twist_joy.

Regards,
Łukasz

1 Like

Try this launch:

<launch>
       <node pkg="joy" type="joy_node" name="ps3_joy" output="screen" >
           <param name="dev" type="string" value="/dev/input/js0" />
           <param name="deadzone" value="0.12" />
           <param name="autorepeat_rate" value="5" />
       </node>
       <node pkg="teleop_twist_joy" type="teleop_node" name="teleop_node" output="screen" respawn="false">
           <param name="enable_button" value="1" />
           <param name="axis_angular" value="1" />  
       </node>
</launch>

You need to install teleop-twist-joy beforehand:

$ sudo apt install ros-kinetic-teleop-twist-joy

There is an enable button activated (kind of safety feature). To allow movement, you need to find out which one it is.

1 Like

Am I to just create this launch file and place it in this launch folder ?
/ros_workspace/src/rosbot_description/src/rosbot_navigation/launch

This will be correct place, assuming you will name this file joy.launch then you can launch it with:

roslaunch rosbot_navigation joy.launch

Regards,
Łukasz

1 Like

OKAY! I finally got the ROSbot to move in gazebo! the only problem is I have to click down on the ps3’s joystick to make the ROSbot move, and it also moves the map around at the same time. Makes it very hard to get any work done. But the ROSbot finally moves.

Is it possible to only move the joystick and not have to click it at the same time to make the ROSbot move? Thank you for all your help so far!

If you use a variation of the launch file from my response a few posts above, then you just need to change the following parameter:

<param name="enable_button" value="1" />

to

<param name="enable_button" value="0" />
1 Like

Ah. Okay. I did not vary they file, but I will try changing the button values. It may help.

Thanks again

So basically the enable button value is selecting one of these buttons from the ps3 controller?
And the chosen button needs to be pressed in order for the velocity command to be sent out?
image

EDIT: SO I have figure out that the enable button does enables the ROSbot to move. However, it only moves forward and left. Large counter clockwise circles. and I cannot make it turn at all.

Hi,
My bad. I should have check before posting the replay. The enable_button parameter seems to select button which enables robot’s movement. It looks like you cannot disable it, but you can select a better button. Please check the default launch file for teleop_twist_joy package. You can access it by typing:

$ roscd teleop_twist_joy/launch/
$ cat teleop.launch
<launch>
  <arg name="joy_config" default="ps3" />
  <arg name="joy_dev" default="/dev/input/js0" />
  <arg name="config_filepath" default="$(find teleop_twist_joy)/config/$(arg joy_config).config.yaml" />
  
  <node pkg="joy" type="joy_node" name="joy_node">
    <param name="dev" value="$(arg joy_dev)" />
    <param name="deadzone" value="0.3" />
    <param name="autorepeat_rate" value="20" />
  </node>

  <node pkg="teleop_twist_joy" name="teleop_twist_joy" type="teleop_node">
    <rosparam command="load" file="$(arg config_filepath)" />
  </node>
</launch>

The associated .yaml file can found in config directory. For ps3 it looks like this:

axis_linear: 1
scale_linear: 0.7
scale_linear_turbo: 1.5

axis_angular: 0
scale_angular: 0.4

enable_button: 8  # L2 shoulder button
enable_turbo_button: 10  # L1 shoulder button

Experiment with the settings.