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

Fine joystick library control

asked 2020-08-04 00:17:04 -0600

sisko gravatar image

updated 2022-01-22 16:10:42 -0600

Evgeny gravatar image

I am leaning the ROSLiB library and I am using the NG-Joystick virtual joystick library to issue twist instructions to a TurtleSim robot.

My problem is when I use the joystick to move the robot, it lurches around widely which is not acceptable for the TurtleSim and certainly not acceptable for moving a real robot. Below is a screen shot of the effects I'm experiencing.

image description

If you look at the console area on the left of the image, you would see the raw X & Y coordinates I am directly publishing to turtle1/cmd_vel. The right side part of the image shows the erratic effect of those coordinates. The section of my code for publishing those coordinates are simple enough but I thought I'd include it below:

this.joystickComp.joystickMove$.subscribe(d => {
      console.log(d);
      console.log('X: ' + d.pointerPos.x + ', Y: ' + d.pointerPos.y);
      console.log('sending cmd_vel ...');
      this.rosService.move(d.pointerPos.x, d.pointerPos.y);
      console.log('cmd_vel sent');
});

Can anyone advice how I can get better control ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-08-04 01:59:38 -0600

mgruhler gravatar image

If you are really sending a twist message, you should work on your units. Note that ROS uses SI-units. You are asking (at least according to the log) for 450+ m/s translational velocity and 310+ rad/s rotational velocity.

edit flag offensive delete link more

Comments

1

Makes for some nice spirograph renders though ..

gvdhoorn gravatar image gvdhoorn  ( 2020-08-04 02:54:44 -0600 )edit
1

Thank you both for your answers. I especially appreciate the link, @gvdhoorn.

sisko gravatar image sisko  ( 2020-08-04 04:28:47 -0600 )edit

To be clear (because this is not my strong point), I'm dividing the x & y values by 100. The control is far more reasonable but if I'm still incorrect, I would appreciate your feedback

sisko gravatar image sisko  ( 2020-08-04 04:31:55 -0600 )edit
1

What I would suggest is to define a minimum and maximum velocity (linear and rotational), map that to the minimum and maximum pixel positions of your joystick (in both dimensions), and then define a (linear) mapping between those two ranges.

That would allow you to use proper units for your minimum and maximum velocities, instead of fudging with a factor to get pixel positions in "the right range".

gvdhoorn gravatar image gvdhoorn  ( 2020-08-04 04:49:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-08-04 00:17:04 -0600

Seen: 166 times

Last updated: Aug 04 '20