loading
 
Laser tracking
Hein van den Broek from Netherlands  [6 posts]
8 years
Hello,

Is it possible to track a laser with a robot that is controlled by a Sabertooth dx10 motorcontroller.

I have tried the laser module thats standard in the roborealm softwarepackage, and it detects the laser perfectly but now i need to control the sabertooth controller.

I dont have any experience with the roborealm software, but i am interested in it.

I've read that i do need to write some coding to control the sabertooth but i don't now how to.

So my questions are: Can i use the roborealm laser spot module to steer the sabertooth motor driver?
Where can i find learning material to write a simple vbscript program so i can control my sabertooth driver.

The software will be used for a schoolproject and i am in a bit of a hury so if someone has already written a program that does this then that would realy help me.

Regards,
Hein

Ps. i control the sabertooth via a USB => TTl cable.
Anonymous 8 years
Hein,

Yes, that is possible. What you need to do is to create a variable that can be used to tell the motor controller what value to send to the motor. This is accomplished in the following manner:

1. Extract position of laser using the module you already have. This creates a variable called LASER_POINTS which identify where the spots are. We will assume there is only one value in this array for simplicity.

2. You need to convert this image coordinate to a motor value. For now we will only consider the x coordinate in the LASER_POINTS. This value could range from 0 to 320 assuming a 320x240 camera image. (Your size may be different). To convert this to a motor value 0 to 255 we need to scale that value before using the Sabertooth module. We do this using the VBScript module.

3. Add the VBScript module and enter the following code

width = GetVariable("IMAGE_WIDTH")
list = GetArrayVariable("LASER_POINTS")
if isArray(list) then
  if ubound(list) >=0 then
    SetVariable "motor_value", (list(0)*255)/width
  else
    SetVariable "motor_value", 128
  end if
else
  SetVariable "motor_value", 128
end if

which will create a new variable called motor_value that ranges from 0 to 255 based on the x coordinate of the laser spot.

4. Add the DE_Sabertooth module to the pipeline. Easiest way is to click on the search tab and type in Sabertooth. In that interface select the motor_value variable (or type it in) on the motor1 or appropriate channel. Assuming you have selected the right port this value is now being sent to the motor and it should start spinning based on the location of the laser spot.

Included below is the robofile with all these elements in it which you may need to customize for your own usage.

Hope this helps ...

STeven.
program.robo
Hein van den Broek from Netherlands  [6 posts] 8 years
Hello STeven,

Thanks for the explanation, I realy appriciate this.

I will test your program and will let you now if I can get it to work, as being a noob with programming.


I've one question: Do you now a site or something were I can learn the basics of VBscript to learn programming with roborealm?

Grtz Hein van den Broek.

PS. I will post some video's and photo's of the working machine on this site.
Anonymous 8 years
Hein,

We don't have a particular site that we recommend to learn VBScript ... but as there are many on the internet I'd recommend doing a search and see which one works best for you.

Looking forward to the images!

STeven.
Hein van den Broek from Netherlands  [6 posts] 8 years
Hello,

I'm having some trouble with the writing of the vbscript program, the sabertooth module works perfect ( manual control via roborealm).

The image width is 640 and the height is 480. Now  I have placed 640 in the program, but do I have to change IMAGE_WIDTH also to 640 or is this just the variable name?

And when I want to make y axes in the program, can I use the same vbscript pipeline then?, so I only need to change the width value in height and can i copy your written program only with the width value's changed in HEIGHT.

I've tried the following program but it didn't work for me.

width = GetVariable("IMAGE_WIDTH")
list = GetArrayVariable("LASER_POINTS")
if isArray(list) then
  if ubound(list) >=0 then
    SetVariable "motor_value", (list(0)*255)/640
  else
    SetVariable "motor_value", 128
  end if
else
  SetVariable "motor_value", 128
end if
height = GetVariable("IMAGE_HEIGHT")
list = GetArrayVariable("LASER_POINTS")
if isArray(list) then
  if ubound(list) >=0 then
    SetVariable "motor_value", (list(0)*255)/480
  else
    SetVariable "motor_value", 128
  end if
else
  SetVariable "motor_value", 128
end if

Thanks for the help so far.

Grtz Hein van den Broek.
Anonymous 8 years
Hein,

The IMAGE_WIDTH is a variable that is set by RR to the width of the image ... so you should just use that value instead of hardcoding the value. (more flexible that way).

You are mixing both X and Y which perhaps should be kept separate? Perhaps something more like this:

width = GetVariable("IMAGE_WIDTH")
height = GetVariable("IMAGE_HEIGHT")
list = GetArrayVariable("LASER_POINTS")
if isArray(list) then
  if ubound(list) >=0 then
    SetVariable "pan_value", (list(0)*255)/width
    SetVariable "tilt_value", (list(1)*255)/height
  else
    SetVariable "pan_value", 128
    SetVariable "tilt_value", 128
  end if
else
  SetVariable "pan_value", 128
  SetVariable "tilt_value", 128
end if

and then use the two variable pan_value and tilt_value in the sabertooth interface to more the X motor and Y motor respectively.This assumes a pan/tilt kind of setup.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index