Ask Your Question
2

code explanation

asked 2014-08-15 02:39:06 -0500

syaz nyp fyp gravatar image

updated 2014-08-15 12:23:19 -0500

hi guys. I need help understanding this code. What does it do?

00802   private void publishVelocity(double linearVelocityX, double linearVelocityY,
00803       double angularVelocityZ) {
00804     currentVelocityCommand.getLinear().setX(linearVelocityX);
00805     currentVelocityCommand.getLinear().setY(-linearVelocityY);
00806     currentVelocityCommand.getLinear().setZ(0);
00807     currentVelocityCommand.getAngular().setX(0);
00808     currentVelocityCommand.getAngular().setY(0);
00809     currentVelocityCommand.getAngular().setZ(-angularVelocityZ);
00810   }

Publish the velocity as a ROS Twist message.

Parameters:


linearVelocityX The normalized linear velocity (-1 to 1).

angularVelocityZ The normalized angular velocity (-1 to 1).


currentVelocityCommand declaration:

   private geometry_msgs.Twist currentVelocityCommand;
edit retag flag offensive close merge delete

Comments

It seems to me that the actual publish code is missing here.

dornhege gravatar image dornhege  ( 2014-08-15 04:21:51 -0500 )edit

Right, apart from that the code modifies an existing velocity command with respect to linear and angular velocity ( http://people.wku.edu/david.neal/117/... ). You can see the layout of the command using rosmsg show geometry_msgs/Twist.

atp gravatar image atp  ( 2014-08-15 08:56:18 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2014-08-15 14:20:30 -0500

lucaluca gravatar image

It modifies currentVelocityCommand accordingly to the parameters passed to the function, but it doesn't actually publish anything, it just modifies the content of currentVelocityCommand. In my opinion, there must be somewhere else some code that really publishes currentVelocityCommand to some rostopic: you could publish currentVelocityCommand at a publishing rate suitable for your goal and modify from time to time its content with this function.

edit flag offensive delete link more

Comments

@syaz nyp fyp could you solve that?

lucaluca gravatar image lucaluca  ( 2014-08-21 07:12:25 -0500 )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

1 follower

Stats

Asked: 2014-08-15 02:39:06 -0500

Seen: 182 times

Last updated: Aug 15 '14