Plotting the Hokuyo measurements

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

Plotting the Hokuyo measurements

Post by sisyphus_s » 22 Jul 2014, 08:26

Hello everyone,

I am using the "2IndustrialRobots" scenes that is available as a part of V-REP installation. I have attached a FastHokuyo rangefinder to the Mesh_part_13 (i.e., the part that carries the end-effector). More specifically, the FaskHokuyo is a child of Mesh_part_13 now. The sensor moves along this joint and I am able to print/output its readings (i.e., x-y-z coordinates of the contact point(s) with an obstacle) through the Hokuyo's script in the windows shell. However, I don't know how to plot these values graphically.

I will be grateful if you kindly advise on the procedure to associate a graph object to these readings.

Your assistance is highly appreciated.
Sincerely,

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

Re: Plotting the Hokuyo measurements

Post by coppelia » 22 Jul 2014, 15:27

Hello,

the approach is following:
  • Add a graph object to your scene.
  • In the graph properties, insert two data streams to record. The data stream type should be Various:user-defined
  • Select Explicit handling for your graph.
  • Create a XY graph (click Edit XY graphs, then Add new curve, and specify the two data streams you have just created. Unckeck Link points for that new curve)
  • Add a floating view to your scene [Popup menu --> Add --> Floating view]
  • Associate your graph with the floating view: select the graph, then over the floating view [popup menu --> View --> Associate view with selected graph]
  • Switch to the X/Y graph display: over the floating view: [popup menu --> View --> Display X/Y graph]
  • Then, use simSetGraphUserData to set the coordinates of the next point. For each point set, call simHandleGraph afterwards. To clear the graph, call simResetGraph.

Similar to:

Code: Select all

-- For each point you wish to record/display:
simSetGraphUserData(graphHandle,'Data',xCoord)
simSetGraphUserData(graphHandle,'Data0',yCoord)
simHandleGraph(graphHandle,0)

-- To clear the graph:
simResetGraph(graphHandle)
Cheers

sisyphus_s

Re: Plotting the Hokuyo measurements

Post by sisyphus_s » 25 Jul 2014, 03:52

Hi,
Thank you very much for your kind assistance, it is highly helpful.

I am using this rangefinder to extract the X-Y-Z coordinates of some points along with their respective Euclidean distances to a surface (e.g., a confined cavity within a larger body). In order to find these distances, I need to know the angle between individual beams. I understand that Hokuyo uses an almost 0.36 (360/1024) resolution angle. Is this a correct incremental value I can consider to calculate the beam-to-detected-point angle? Or should I use the X-Y coordinates of the detected point and the Hokuyo to calculate the angle?

I know 'simGetScriptSimulationParameter' along with the 'scanAngle' gives me the actual scanning angle. However, I don't know of any parameter name or argument to extract the between-beam-angle.

I will be grateful if you kindly advise if there is a way to obtain this inter-beam angle value.

Your kind assistance is highly appreciated.

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

Re: Plotting the Hokuyo measurements

Post by coppelia » 26 Jul 2014, 00:43

I am not sure I understand what you mean.

In the case of the Hokuyo laser scanner, you can easily obtain the coordinates of the detected points, RELATIVE to the reference point. In the case of the Hokuyo URG 04LX UG01_Fast, the returned points are relative to the object fastHokuyo_ref. From there you can do the calculation you want. For example:
  • Radial distance to a detected point would be d=sqrt(x*x+y*y)
  • Distance between the vertical plan in which the sensor is in, and a detected point would be d=x
Cheers

sisyphus_s

Re: Plotting the Hokuyo measurements

Post by sisyphus_s » 29 Jul 2014, 06:27

Hi there,

Thank you very much for your instructions on the working of Hokuyo and its returned values.

At present, I am trying to understand the remoteAPI functionality through the "controlTypesExample". In particular, bubbleRob. While looking at the bubbleRobCleint.cpp and bubbleRobServer.cpp, I notice the robot's control is replicated in both and I don't understand the reason for it. I will be grateful if you kindly explain the rationale behind such implementation.

Your kind assistance is highly appreciated.

sisyphus_s

Re: Plotting the Hokuyo measurements

Post by sisyphus_s » 29 Jul 2014, 07:43

My sincere apologies for not awaiting for your response before posting this new comment, I have got to get this up and running so to conduct a few preliminary experiments on our project.
When I try the simpleTest.py program, I receive the following error:

Traceback (most recent call last):
File "C:\Program Files (x86)\V-REP3\V-REP_PRO_EDU\programming\remoteApiBindings\python\python\simpleTest.py", line 28, in <module>
import vrep
File "C:\Program Files (x86)\V-REP3\V-REP_PRO_EDU\programming\remoteApiBindings\python\python\vrep.py", line 37, in <module>
libsimx = CDLL("./remoteApi.dll")
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

I am using Python 2.7.6.
Would you please let me know if I am doing it wrong
Your assistance is highly appreciated.

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

Re: Plotting the Hokuyo measurements

Post by coppelia » 29 Jul 2014, 18:21

bubbleRobClient and bubbleRobServer are just 2 different examples how to control a simulation model. Just focus on bubbleRobClient and the remote API.

Then, for your Python problem: make sure you have the remote api library in your directory (remoteApi.dll). The full instructions are listed here.

Cheers

sisyphus_s

Re: Plotting the Hokuyo measurements

Post by sisyphus_s » 31 Jul 2014, 14:43

Hi,

Thank you very much for your kind responses to my posts. They are highly instructive and helpful.
In my simulation, there is a prismatic joint that performs the relocation of a Hokuyo laser rangefinder. As a part of the design, I need to dynamically readjust the joint interval (i.e., its range) and its position minimum (i.e., how far it can move downward as it is operating on Z-axis). I understand there is a simGetJointInterval API. I am wandering if there is an equivalent simx for this API. Moreover, I am unable to find an API to control the position minimum value.

I will be grateful if you kindly advise how I can address this issue. I am using the python remoteAPI. Furthermore, I modified the simpleTest.py to control the joint and and receive the Hokuyo data.

Your kind assistance is highly appreciated.

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

Re: Plotting the Hokuyo measurements

Post by Eric » 31 Jul 2014, 21:01

hi

As a general workaround when a function exists in the regular API and does not exist in the remote one, most of the time you can use the regular API function into a script passing parameters and reading the result of the function from the remote API program passing messages by tubes or signals.
your python application sends simxSetStringSignal(...,"simGetJointInterval","JOINTNAME"...)
and reads simxGetStringSignal(..,'simGetJointInterval,..') and simxSetFloatSignal(...,interval1,...) and simxSetFloatSignal(...,interval2,...)
if the signal read from simxGetStringSignal is "cyclic" or "error"you can act accordingly

v-rep threaded script (code not tested):

Code: Select all

simSetThreadSwitchTiming(2) -- Default timing for automatic thread switching
simDelegateChildScriptExecution()

while (simGetSimulationState()~=sim_simulation_advancing_abouttostop) do

	joint=simGetStringSignal('simGetJointInterval') --get the name of the joint to retrieves the interval parameters
	if joint~=nil then 
		simClearStringSignal()
		handle=simGetObjectHandle(joint)
		cyclic,interval=simGetJointInterval(handle)
		if cyclic== true then -- the joint is cyclic hence have no interval
			message='cyclic'
		else 
			if interval~=nil then -- we have some interval to send back 
				simSetFloatSignal('interval1',interval[2])-- sending the result
				simSetFloatSignal('interval2',interval[2])-- sending the result
			else --there has been a problem
				message='error'
			end
		end
		simSetStringSignal('simGetJointInterval',message)-- sending the result
	else 
		simSwitchThread()
	end
end
also to position minimum value, you can use simxSetIntegerSignal(...,handle,...),then simxSetFloatSignal(...,interval1,...) and simxSetFloatSignal(...,interval2,...) to send the value to a script that does a simSetJointInterval( handle,false, {interval1,interval2})

cheers
Eric

sisyphus_s

Re: Plotting the Hokuyo measurements

Post by sisyphus_s » 02 Aug 2014, 11:30

Hi Eric,

Thank you very much for your kind instructions. They helped me solve the problem.
One persisting message that shows on the top of my prismatic joint is the exclamation mark that says this joint is not dynamically enabled. I checked the following parameters that are associated with this joint:
1. Motion handling of all joints enabled
2. joint is in torque/force mode
Moreover, in the show dynamic parameters, I checked the followings:
1. Motor enabled
2. Control loop enabled.
Furthermore, I select the Position control (PID) radio bottom, under the Control loop enabled checkbox.

I will be thankful if you kindly advise whether I am missing any other parameter(s) (or possibly a call to an API at the start of the simulation) to prevent this warning.

I am controlling the position of this joint through the python remoteApi, using the following code:

[err, jointHandle] = vrep.simxGetObjectHandle(clientID, 'laserJoint', vrep.simx_opmode_oneshot_wait)
[flag, translation] = PrismaticJointMotion(jointPositionMinimum, jointExtensionValue)
vrep.simxSetJointPosition(clientID, jointHandle, translation, vrep.simx_opmode_oneshot)

Your kind assistance is highly appreciated.
Sincerely,
Soheil

Post Reply