ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Adjusting cmd_vel linear.y value published by move_base

asked 2021-04-18 20:49:13 -0600

sisko gravatar image

updated 2021-04-19 09:29:39 -0600

I have the following action-client code which I use to send a pose to move_base which inturn moves my robot model.

def move(self, goal):
    client_mb = actionlib.SimpleActionClient('move_base', MoveBaseAction)

    pose = Pose(Point(goal.x, goal.y, goal.z), Quaternion(0.000, 0.000, 0.0, 1.0))

    # Set up the next goal location
    self.goal = MoveBaseGoal()
    self.goal.target_pose.pose = pose
    self.goal.target_pose.header.frame_id = 'map'
    self.goal.target_pose.header.stamp =

    # Let the user know where the robot is going next
    rospy.loginfo("Going to: " + str(goal))
    feedback_obj = TakePositionFeedback() = 'Moving to: ' + str(goal.position)

    # Start the robot toward the next location

The robot successfully moves to the specified destination.

But, I'm looking for a means of instructing the robot to move on the left or righ hand side of a corridor while travelling to the destination. The idea is to read the laser sensors on the right side of the robot, determin the distance to the wall and get the robot to drive parrallel to the wall maintaining a specified maximum distance. The same would apply to the left.

I can see data being published to /cmd_vel but I'm not sure how or if it's possible to preempt the linear.y value on the fly.

Any help please ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-04-19 09:55:51 -0600

miura gravatar image

You may be able to move it by changing the value of cmd_vel in the following.

  1. Use remap and make cmd_vel of move_base a different name. ( For example, cmd_vel_origin )
  2. Create a node that subscribes to cmd_vel_origin, updates its value, and publishes it.
  3. Move the created node together with move_base
edit flag offensive delete link more


@miura: Hi nad thanks for your answer. You were completely right. That was infact what I was attempting. I remapped cmd_vel to cmd_vel_original in the mode_base node of my launch file. However, I have serious issues when I subscrided to cmd_vel_original, overwrote the value of twist.angular.z and published to cmd_vel. My robot did not move smoothly towards the wall edge as I hoped. It just does a very disorganized looking rotation on the spot. I have been reshearching and it seems the kind on problem a PID would solve but I don't know how to implement one. Is this something that the pid package can be used for and if so how ?

sisko gravatar image sisko  ( 2021-04-21 06:56:33 -0600 )edit

I'm glad I could be of some help.

Sorry, I'm not familiar with the pid package. However, on a general topic, I think PID is a way to smoothly bridge the gap between the target and current values. If the target and current values are defined in overriding the twist.angular.z, may the PID package is going to be effective.

Since the question is changing from the content of the question, I would recommend creating another question.

miura gravatar image miura  ( 2021-04-21 07:35:53 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-04-18 20:49:13 -0600

Seen: 116 times

Last updated: Apr 19 '21