## Robot movement and linear velocity

Typically: "How do I... ", "How can I... " questions
makbut
Posts: 10
Joined: 29 Dec 2016, 11:39

### Robot movement and linear velocity

Hello! I am running some simulations on VREP and I have one question regarding the movement of my robot.
I am using the Pioneer-P3dx robot. The robot subscribes to the /cmd_vel topic. I am using the teleop_twist_keyboard in order to publish messages to that topic and then the robot moves according to the keystrokes. The callback function which is called upon subscription is the following:

Code: Select all

    local wheel_radius = 0.2
local wheel_separation = 0.5

local speed_left = (msg['linear']['x'] + msg['angular']['z'] * wheel_separation/2)/wheel_radius
local speed_right = (msg['linear']['x'] - msg['angular']['z'] * wheel_separation/2)/wheel_radius

simSetJointTargetVelocity(motorLeft, speed_left)
simSetJointTargetVelocity(motorRight, speed_right)
I observed that the wheel radius has an impact on the movement. For example the bigger is the radius, the bigger linear velocities values, I can provide and the robot can move in straight line. If the radius is small, then the robot is not moving in straight line and it does a weird curved movement.

For example, for linear velocity of 2 m/s and radius 1 meter the robot moves straight, but if radius is 0.1 meters it does not move straight. Instead it does a curved motion.

I think that there is something with the physics that I miss, could anyone explain?

EDIT: The original post about the simulation step was inaccurate. I figured that out!

coppelia
Posts: 7450
Joined: 14 Dec 2012, 00:25

### Re: Robot movement and linear velocity

Hello,

not sure I understood your problem correctly.
Your robot could suffer under the effect of slipping, or too small torque. The best is to switch to another physics engine and see if the results are similar or not. That can also give you a clue of what is going on.
If you can reproduce the problem in self-contained scene, the please post it. It is often faster to look at the scene than to try to guess the problem.

Cheers

makbut
Posts: 10
Joined: 29 Dec 2016, 11:39

### Re: Robot movement and linear velocity

Hi!
It seems the problem is solved or it never existed. It was just a matter of understanding the physics.

WillC
Posts: 4
Joined: 23 Apr 2015, 06:33

### Re: Robot movement and linear velocity

Thanks makbut!

For anyone else, here's the full child script for a standard Pioneer 3DX model to receive geometry_msgs/Twist topic on the /cmd_velfrom ROS such e.g. rosrun teleop_keyboard teleop_keyboard.
You may want to add scaling factors and/or limits for linear and/or rotational acceleration and velocity on top of this.

Code: Select all

-- This is a very simple EXAMPLE navigation program, which avoids obstacles using the Braitenberg algorithm

function cmd_vel__callback(msg_)
-- Apply the received image to the passive vision sensor that acts as an image container
msg = msg_
print(msg_)

end

if (sim_call_type==sim_childscriptcall_initialization) then
usensors={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
for i=1,16,1 do
usensors[i]=simGetObjectHandle("Pioneer_p3dx_ultrasonicSensor"..i)
end
motorLeft=simGetObjectHandle("Pioneer_p3dx_leftMotor")
motorRight=simGetObjectHandle("Pioneer_p3dx_rightMotor")
noDetectionDist=0.5
maxDetectionDist=0.2
detect={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
braitenbergL={-0.2,-0.4,-0.6,-0.8,-1,-1.2,-1.4,-1.6, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}
braitenbergR={-1.6,-1.4,-1.2,-1,-0.8,-0.6,-0.4,-0.2, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}
v0=2

sub=simExtRosInterface_subscribe('/cmd_vel', 'geometry_msgs/Twist', 'cmd_vel__callback')
simExtRosInterface_subscriberTreatUInt8ArrayAsString(sub) -- treat uint8 arrays as strings (much faster, tables/arrays are kind of slow in Lua)
msg = {}
end

if (sim_call_type==sim_childscriptcall_cleanup) then

end

if (sim_call_type==sim_childscriptcall_actuation) then
if msg ~= nil then