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

Limit linear velocity [closed]

asked 2014-07-23 16:46:57 -0600

anamcarvalho gravatar image

updated 2014-07-24 09:08:11 -0600

Hi everyone,

I wrote a node that subscribes to the topic sensor_msgs/LaserScan and publishes in the topic geometry_msgs/Twist. I want to limit the maximum linear velocity that a powered wheelchair can reach. How can I do that?

Here's the code of how I publish the velocity: (this is just an example, I don't want to set the linear velocity to 1.4m/s, I want that the maximum velocity reachable is 1.4 m/s)

ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
(...)
vel.linear.x=1.4;
vel.angular.z+=M_PI/8;
vel_pub_.publish(vel);
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by anamcarvalho
close date 2014-07-24 16:17:20.626914

Comments

can you describe more

bvbdort gravatar image bvbdort  ( 2014-07-23 17:09:29 -0600 )edit

+bvbdort Hi want to limit the max linear velocity. I am new to ROS and I don't know which topic should I publish or with what parameter can I limit the linear velocity.

anamcarvalho gravatar image anamcarvalho  ( 2014-07-23 17:40:54 -0600 )edit

Divide your 'linear.x' by a factor in the Twist message that you send to /command_velocity or cmd_vel. Or limit your linear.x

McMurdo gravatar image McMurdo  ( 2014-07-24 00:46:11 -0600 )edit

please post your code how you are publishing your linear velocity.

bvbdort gravatar image bvbdort  ( 2014-07-24 02:39:19 -0600 )edit

+McMurdo divide linear.c by what factor?? I want to limit my linear velocity (linear.x) just like you said, but I don't know how, please explain it to me... +bvbdort I'll post the code now!

anamcarvalho gravatar image anamcarvalho  ( 2014-07-24 08:34:34 -0600 )edit
1

`linear.x` is zero in the code you posted. I don't know how you want to limit that more.

dornhege gravatar image dornhege  ( 2014-07-24 08:41:40 -0600 )edit

If you just want to enforce a max velocity, check the value of vel.linear.x and change it if it is too large. If you want to scale the velocity to another range, that can be done in one line - see http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio

sterlingm gravatar image sterlingm  ( 2014-07-24 08:43:11 -0600 )edit

+dornhege This was just an example of how I publish the velocity. I want to limit the maximum linear velocity of the wheelchair. I want that, no matter which part of my code is executing, the maximum velocity that the power wheelchair user can reach (joystick is the HMI) is for example 1.4m/s!

anamcarvalho gravatar image anamcarvalho  ( 2014-07-24 09:03:03 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-07-24 12:53:44 -0600

Bill Smart gravatar image

Write another node the subscribes to the Twist message, enforces any limits you want to set (such as maximum speed), and then publishes the new, modified Twist. Have this node subscribe to the topics published by your original node, and publish to the lower-level drivers for the wheelchair.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-07-23 16:46:57 -0600

Seen: 1,140 times

Last updated: Jul 24 '14