underwater robot simulation

Typically: "How do I... ", "How can I... " questions
croncal

underwater robot simulation

Post by croncal » 19 Feb 2015, 15:11

Hello!

I'm currently working on a project which consists of simulating the openROV robot, which is an underwater robot, and to use the results from the simulator to evaluate different control techniques. Therefore, the goal is not to make a simulation setup but to obtain some results which can be used in further phases of the project. I wonder if someone has done it before and if someone has used a model of this robot in V-Rep to simulate its performance.
Besides, I've read in a couple of queries that it is possible to fake the water environment with particles and additional forces, but i wonder how accurate this fake environment would be in order to get reliable results?

Thank you in advance for your help!

Cheers,
Carlos

coppelia
Site Admin
Posts: 6914
Joined: 14 Dec 2012, 00:25

Re: underwater robot simulation

Post by coppelia » 19 Feb 2015, 21:57

Hello,

it is difficult to say how accurate such a simulation will be. It will actually depend on how you implement it. But you will have to use self-created forces that you will have to compute yourself. If you know the drag coefficients for your robot for the various flow directions, then it could be pretty accurate.
Using particles might render the whole less accurate, I would try to subdivide the water into smaller volumes where each of those volumes could be assignes a specific flow direction and velocity.

Cheers

croncal

Re: underwater robot simulation

Post by croncal » 24 Feb 2015, 11:18

Hello,

Thank you very much for your help. I have a couple of questions, I have built a very approximated model of the robot as a box and three propellers and I am trying to follow the quadcopter example to learn how to use the propellers. I use a graph to plot the joint velocity of one of the propellers but no matter which value is sent to the propellers, a steady value around 2800 is plotted. I have tried with the angular velocity of "Quadricopter_propeller_propeller4" and the result is the same. Am I choosing the wrong variables if I want to represent the velocity of the rotor?
Then, I have found in another query that it is possible to write to a file by using these lines of code:
name = "IOfile.txt"
file = io.open(name, "w")
file:write("Hello World")
file:close()
I want to write the computed velocity of the rotor as: file:write(particlesTargetVelocities[1]), however only one value is written to the file. How can I write all the computed values in the file? Could the problem be that I am closing the file just after writing the value, and in this case, where should the file be closed in the code?

Thank you for your help!

Cheers

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: underwater robot simulation

Post by Eric » 24 Feb 2015, 13:40

Hi

If you open and close the file at each simulation step you ll get only the last value in the file after you are done with the simulation. Maybe you should try this, in a non-threaded script

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
	name = "IOfile.txt"
	file = io.open(name, "w")
end

if (sim_call_type==sim_childscriptcall_sensing) then
	file:write(particlesTargetVelocities[1]..",")
end


if (sim_call_type==sim_childscriptcall_cleanup) then
	file:close()
end
cheers

Eric

croncal

Re: underwater robot simulation

Post by croncal » 03 Mar 2015, 16:36

Hi,

So far, I have built a simple model as a box and placed it in a certain position in the scene. When I run the simulation the model falls until it reaches the floor of the scene, so I think the gravitational force is applied to the body. I would like to set an external force which is opposite to the forces applied to the body so it is stable in the initial position and it doesn't fall. Is there any function to get the forces applied to a body? In order to apply the opposite force I am thinking in using the function simAddForce, is it correct?

Thank you for your help

Cheers,
Carlos

coppelia
Site Admin
Posts: 6914
Joined: 14 Dec 2012, 00:25

Re: underwater robot simulation

Post by coppelia » 03 Mar 2015, 22:05

Hello Carlos,

use instead simAddForceAndTorque (will add a central force and/or torque). You can retrieve the world gravity with simGetArrayParameter(sim_arrayparam_gravity).

Have also a look at how it is done in the demo model Models/robots/mobile/ACM-R5.ttm.

Cheers

croncal

Re: underwater robot simulation

Post by croncal » 24 Apr 2015, 13:46

Hello,

I am carrying out a simple test in which the orientation of the object is changed and then a force is applied to it. The code I'm using is this:

error = simSetObjectOrientation(robot,-1,{0, 0, 3.1415/2})
force = {1,0,0}
matrix = simGetObjectMatrix(robot,-1)
force = simMultiplyVector(matrix,force)
simAddForceAndTorque(robot,force,{0,0,0})

However, the orientation of the object is changed but the robot is not moving. I have read the help of the functions in the manual and I think I use them correctly, so I don't know why the robot is not moving.
Thank you for your help.

Cheers,
Carlos

coppelia
Site Admin
Posts: 6914
Joined: 14 Dec 2012, 00:25

Re: underwater robot simulation

Post by coppelia » 24 Apr 2015, 17:06

Hello Carlos,

when you set the position/orientation of a non-static object, then it will be temporarily reset dynamically (since instantaneously changing the position/orientation in reality is not possible).

Also, adding a force/torque to an object: you need to constantly add the force, in each simulation step, since after one simulation step, the auxiliary force is reset. So maybe something like:

Code: Select all

 if (sim_call_type==sim_childscriptcall_initialization) then
	robot=simGetObjectHandle('myRobot')
	simSetObjectOrientation(robot,-1,{0, 0, 3.1415/2})
end


if (sim_call_type==sim_childscriptcall_actuation) then
	local force = {1,0,0}
	local matrix = simGetObjectMatrix(robot,-1)
	force = simMultiplyVector(matrix,force)
	simAddForceAndTorque(robot,force,{0,0,0})
end
Cheers

croncal

Re: underwater robot simulation

Post by croncal » 17 May 2015, 19:20

Hi,
I am trying to simulate a scenario in which two vehicles are attached together while the the simulation is running. One of the vehicles has been created as a cuboid which is grouped with a cylinder and it has an associated script in which the dynamics of the object is defined, while the second object is a cuboid which has a script in which only the necessary code for making the robot to stay at a certain position has been written. The first vehicle should move until a certain point where both are very close, at this point both shapes should attach together and then the resulting object should continue moving as it is defined in the code. The code used to group the objects is the following:

Code: Select all

-- Compute position difference between robots
diffPosition[1] = position[1] - positionPassive[1]
diffPosition[2] = position[2] - positionPassive[2]
diffPosition[3] = position[3] - positionPassive[3]
if (math.abs(diffPosition[1]) < 0.001 and math.abs(diffPosition[2]) < 0.001 and groupRobots == 0) then
		numGroup = simGroupShapes({robotPassive, robot})
		groupRobots = 1
end
The problem is that after the vehicles have been grouped, the resulting object falls to the bottom of the scenario and it is not executing the rest of the code so it is not moving any longer as it should do. I tried to disable the script of the second vehicle and to define it as static but the result is the same. Besides, when both shapes are grouped the body frame is rotated instead of being kept as it was before.
Then, I have problems with the ungroup process too. I want them to ungroup when the simulation finishes and to be initialized as they were before so I can repeat the simulation as many times as I want. I added this code to ungroup the vehicles before the simulation finishes:

Code: Select all

if k > 1400 then
	robotPassive, robot = simUngroupShape(numGroup)
	simStopSimulation()
end
With this the shapes are not ungrouped and due to the rotation during the grouping process it is initialized at the initial position but it is rotated. I added the same command in the cleanup part of the code:

Code: Select all

if (sim_call_type==sim_childscriptcall_cleanup) then
        -- ungroup the robots
	robotPassive, robot = simUngroupShape(numGroup)
end
After adding this code, it is ungrouped but the second vehicle, the one which is a cuboid, it is deleted from the scene and the first one, which has been created as a group of a cuboid and a cylinder, it has been ungrouped too and the cylinder is deleted from the scene. Besides, instead of being at the initial position it stays at the last position reached during the simulation.
Is it not possible to group/ungroup objects in this way? I tried to use a force sensor to attach to objects together and then apply a force in order to make it to move, but as soon as the force is applied the resulting vehicle is going unstable.
Thank you for your help.
Cheers,
Carlos

coppelia
Site Admin
Posts: 6914
Joined: 14 Dec 2012, 00:25

Re: underwater robot simulation

Post by coppelia » 18 May 2015, 06:08

You should not group/ungroup dynamic objects during simulation, since this will result in the creation of new objects (and destruction of other objects). Use grouping/ungrouping only during the edition phase.

If you need to rigidly attach shapes during simulation, as you mentioned it, use a force/torque sensor. The simplest would be to attach the force sensor to one of your shape, and attach the other shape to the force sensor. In other situations, this doesn't work well (e.g. when you have two serial robots that should shake hands.. i.e. be attached via their end-effectors). In that case you can still use a force sensor, but in a loop-closure configuration.

Why your two attached shapes are unstable is probably due to the fact that the two shapes are overlapping and colliding with each other?! If this is the case, you need to make sure that their respective local respondable masks do not overlapp. Best would be if you could post the scene.

Cheers

Post Reply