V-REP
From RoboWiki
V-REP (Virtual Robot Experimentation Platform)
Description: V-REP is a distributed control 3D robot simulator, that allows to create whole robotic systems, simulate and interact with dedicated hardware. It possesses several versatile calculation modules (dynamics based on ODE and Bullet, inverse kinematics, proximity sensors, vision sensors, path planning, collision detection, minimum distance calculation, graphing, etc.) and a very elaborate API (more than 650 API functions in total). The platform supports CAD data import, robot and world edition and user interface edition.
Platform: Windows, Mac OS X & Linux.
License: Partially open source. Several prices available. Free fully functional version available for students.
Example of source code
if (simGetScriptExecutionCount()==0) then
-- This is executed exactly once, the first time this script is executed
bubbleRobBase=simGetObjectAssociatedWithScript(sim_handle_self) -- this is bubbleRob's handle
-- following is the handle of bubbleRob's associated UI (user interface):
ctrl=simGetUIHandle("bubbleCtrl")
-- Set the title of the user interface:
simSetUIButtonLabel(ctrl,0,simGetObjectName(bubbleRobBase).." speed")
leftMotor=simGetObjectHandle("leftMotor") -- Handle of the left motor
rightMotor=simGetObjectHandle("rightMotor") -- Handle of the right motor
noseSensor=simGetObjectHandle("sensingNose") -- Handle of the proximity sensor
minMaxSpeed={50*math.pi/180,300*math.pi/180} -- Min and max speeds for each motor
backUntilTime=-1 -- Tells whether bubbleRob is in forward or backward mode
end
-- if any child script is attached to the bubbleRob tree, this command will execute it/them:
simHandleChildScript(sim_handle_all_except_explicit)
-- Retrieve the desired speed from the user interface:
speed=minMaxSpeed[1]+(minMaxSpeed[2]-minMaxSpeed[1])*simGetUISlider(ctrl,3)/1000
result=simReadProximitySensor(noseSensor) -- Read the proximity sensor
-- If we detected something, we set the backward mode:
if (result>0) then backUntilTime=simGetSimulationTime()+4 end
if (backUntilTime<simGetSimulationTime()) then
-- When in forward mode, we simply move forward at the desired speed
simSetJointTargetVelocity(leftMotor,speed)
simSetJointTargetVelocity(rightMotor,speed)
else
-- When in backward mode, we simply backup in a curve at reduced speed
simSetJointTargetVelocity(leftMotor,-speed/2)
simSetJointTargetVelocity(rightMotor,-speed/8)
end