Cannot send feedback to PS3 Controller

asked 2021-03-08 03:51:14 -0500

AndrewH1 gravatar image

Hi,

Ubuntu: 18.04.5 ROS: Melodic

I have successfully connected my PS3 Dualshock3 Sixaxis Controller to my Ubuntu machine, and can control a Turtlebot3 Burger in Gazebo Simulation through Teleop_Twist_Joy package.

I want to send vibration feedback to the controller and have found that I should do this through the topic "/joy/set_feedback". My node is subscribed to this topic and I successfully publish to it.

However, my controller doesnt move... nothing rumbles or vibrates.

I think it might be related to this following warning message I get when starting the teleop_twist_joy node.

    "[ WARN] []: Couldn't set gain on joystick force feedback: Bad file descriptor"

Other places I google people always had the problem that it said "Couldnt open force feedback" and the solution was that the joystick didnt offer force feedback, but mine doesnt say exactly that and I know that my controller can rumble.

I researched where the message is send from and it originates from here: https://github.com/ros-drivers/joysti... Lines: 428-456

    if (!dev_ff.empty())
    {

    ff_fd_ = open(dev_ff.c_str(), O_RDWR);

    /* Set the gain of the device*/
    int gain = 100;           /* between 0 and 100 */
    struct input_event ie;      /* structure used to communicate with the driver */

    ie.type = EV_FF;
    ie.code = FF_GAIN;
    ie.value = 0xFFFFUL * gain / 100;

    if (write(ff_fd_, &ie, sizeof(ie)) == -1)
    {
      ROS_WARN("Couldn't set gain on joystick force feedback: %s", strerror(errno));
    }

    memset(&joy_effect_, 0, sizeof(joy_effect_));
    joy_effect_.id = -1;
    joy_effect_.direction = 0;  // down
    joy_effect_.type = FF_RUMBLE;
    joy_effect_.u.rumble.strong_magnitude = 0;
    joy_effect_.u.rumble.weak_magnitude = 0;
    joy_effect_.replay.length = 1000;
    joy_effect_.replay.delay = 0;

    // upload the effect
    int ret = ioctl(ff_fd_, EVIOCSFF, &joy_effect_);
  }

However, I do not understand what this means or what I could change to fix it.

Help please :-)

edit retag flag offensive close merge delete