vehicle velocity_callback simSetJointTargetVelocity

Typically: "How do I... ", "How can I... " questions
Post Reply
lyz
Posts: 8
Joined: 07 Mar 2019, 07:34

vehicle velocity_callback simSetJointTargetVelocity

Post by lyz » 14 Mar 2019, 10:33

Hello,
I'm a beginner in vrep software. I refer to this package env.ttt https://github.com/gentaiscool/ros-vrep-slam to build my scene, which part of the code is not very clear.

Code: Select all

-- set velocity
function velocity_callback(msg)
    -- This is the sub_velocity callback function
    -- simAddStatusbarMessage('sub_velocity receiver: ' .. msg.linear.x)
    simAuxiliaryConsolePrint(console_debug,'linear: ' .. msg.linear.x)
    simAuxiliaryConsolePrint(console_debug,' angular: ' .. msg.angular.z)
    vLeft = 6*msg.linear.x - 0.6*msg.angular.z
    vRight = 6*msg.linear.x + 0.6*msg.angular.z
    simSetJointTargetVelocity(motorLeft,vLeft)
    simSetJointTargetVelocity(motorRight,vRight)
end
I don't understand how can I get the coefficients in these two formulas.

Code: Select all

    vLeft = 6*msg.linear.x - 0.6*msg.angular.z
    vRight = 6*msg.linear.x + 0.6*msg.angular.z
can you solve it, please. Thanks a lot.

lyz
Posts: 8
Joined: 07 Mar 2019, 07:34

Re: vehicle velocity_callback simSetJointTargetVelocity

Post by lyz » 15 Mar 2019, 06:54

I think it should be calculated by this formula, but the coefficients don't correspond.
In this formula, wheel_radius variable is wheel radius, and axes_length is the distance between wheels.
msg.linear.x is vehicle linear velocity.
msg.angular.z is vehicle angular velocity.

Code: Select all

    v_left  = (1.0/wheel_radius)*(msg.linear.x - axes_length/2.0*msg.angular.z)
    v_right = (1.0/wheel_radius)*(msg.linear.x + axes_length/2.0*msg.angular.z)

Post Reply