Asked — Edited
Resolved Resolved by CochranRobotics!

Moving Discrete Distances

Now that I have part of Wiggins (my robot arm's name) built with multiple motors and multiple sabertooth/kangaroos all of which are being driven by digital ports on EZ-B and speech recognition via bluetooth headset configured on the computer... I am not using a movement control, only things like Horizontal servo which configured will move a kangaroo controlled motor from 0 to 180. The kangaroo is Teach Tuned to drive left and right from 0 to 360 degrees and the feedback is a 10 turn potentiometer on the pinion of the gear motor.

What I want is to tell Wiggins to turn left a certain number of degrees, for example. So the swivel for Wiggins' arm is a single gear motor driven pivot that rotates 360 degrees and is controlled by a Horizontal servo control so that it moves the full 360 degrees using the 0-180 on the control. Is there a control that turns left and right 180 degrees?

What I want is to be able to tell Wiggins to move a discrete variable distance. For example," Wiggins - rotate left 32 degrees". Or "Wiggins - rotate to 090".

One of these is movement from the current position and then left 32 degrees. The other is to rotate to a constant location.

How do I do this?

User-inserted image


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

#25  

I may have broken things out to far for you to understand easily in the projects I gave you. I will try to explain it so that you can follow what is going on.

The init script is used to setup the variables that would be used in other sections. I have changed the project to fire the init script when you connect to the EZ-B. Also, it now centers the arm and tells people to stand clear of the arm before doing so. This is to give you a starting point. The speech recognition control is disabled during this process

To modify its behavior, you would modify the script control called Init by clicking on the gear button on this control.

The next thing to do is to speak to the robot. These actions are handled through the Speech Recognition control. You can see a list of the commands and make modifications to the speech recognition phrases by clicking on the gear in the speech recognition control.

You will see that I have added 4 phrases as examples for you. They are Wiggins Turn Left Wiggins Turn Right Wiggins Won Wiggins To The Won and To are the phonetic representations of 1 and 2. These phrases are what the robot listens to.
The Wiggins Turn Left command looks like this


$TurnDirection = "Left" 
ControlCommand("Speech Recognition", PauseOn)
SayWait("How may degrees would you like me to move?")
ControlCommand("Speech Recognition", PauseOff)

This code sets a variable that is used later by a different script.
It then turns off Speech Recognition It asks a question of how far would you like the arm to move Then it turns on Speech Recognition.

The robot would then be waiting for the answer to the question that it asked. Here is the Wiggins Won script


if($TurnDirection = "Right") 
  $TurnDistance = 1
  ControlCommand("Script Manager", ScriptStart, "MoveMotor")
endif
if($TurnDirection = "Left") 
  $TurnDistance = 1
  ControlCommand("Script Manager", ScriptStart, "MoveMotor")
endif

The first thing it does is makes sure that the first variable i mentioned is set and then sets a different variable for how far the robot needs to move. It then starts the MoveMotor script.

You can modify the commands for the recognition text by clicking the row in the command column to the right of the phrase that you want to modify. A pencil button will show up. Click it to show the entire script for that item.

The script manager is a control that I like to used to keep the number of windows in a projects far fewer. The script manager allows you to have many scripts in a single control. There is one script right now called MoveMotor. You can see what it contains by clicking Edit.


ControlCommand("Speech Recognition", PauseOn)
if($moving = "")
  if($TurnDirection = "Right")
    #do something here to move the motor.  I am just saying the info 
    #as an example.
    SayWait("I am moving right " + $TurnDistance + " Degrees.") 
  endif 
  if($TurnDirection = "Left")
    #do something here to move the motor.  I am just saying the info 
    #as an example.
    SayWait("I am moving Left " + $TurnDistance + " Degrees.") 
  endif 
  $moving = "Yep Moving"
endif

#wait here long enough to complete the move.
Sleep(10000)
$moving = ""
ControlCommand("Speech Recognition", PauseOff)


First it turns off speech recognition. Then it sees if the arm still thinks it is moving from a previous command. Then it checks to see if you told it to move left or right This is where you would add your code to move your servos. Right now, I just have it speaking to you.

Something like


Servo(servoPort,$PreviousLocation + $TurnDistance)
$PreviousLocation = $PreviousLocation + $TurnDistance

You may also decide to use the GetServo option which doesn't read from the servo but pulls the information that is stored in an object in the ARC code that tracks what it thinks the servo's location is. Really, this option and that one do the same thing.

Once the motor starts moving, the variable $moving should be set. The script waits 10 seconds (this could be replaced with some math based on how far you told it to move) and then sets the $moving variable back to "" so that the robot knows it isnt moving anymore and is ready for the next command. It then enables speech recognition so you can give it another command.

I found something that I missed that I should have put in there. Between the $moving = "" and the ControlCommand line, I would add this...


$TurnDistance = ""
$TurnDirection = ""

This will clear the variables that are used earlier in this process and to help prevent the robot from running crazy when someone comes in and says Wiggins To without you first telling it to move.

I hope this explanation helps to understand what is happening with the project.

#26  

To open the project, here is what I would do...

Open ARC In the area called EZ-Cloud App Store click Open

User-inserted image

Setup the selection criteria as shown in this image and then click open on the first item in the list.

User-inserted image

#27  

@CochranRobotics has been extremely helpful showing me how to make this work! I wanted to give him recognition quickly but I hope that we can continue this thread as I get Wiggins moving!

Thank you very much! Castle

#28  

Thank you for the credit. I am happy to continue helping you out. I can't wait to see Wiggins come to life.

#29  

@CochranRobotics - thank you for the support. I will be working with your code hopefully today but my EZ-B is up in my barn (about an hour away) and I won't be back there until Friday (Jury duty).

I have had success getting the sabertooth/kangaroo working with servo Controls to drive the large motors to behave as servos successfully with both potentiometer and encoder feedback so I know that mechanically and manually (just sliding a Horizontal servo control left and right makes the arm swing. So the code examples you have provided will go a long way to automating this and using speech to move Wiggins!

Thank you again - I look forward to getting Wiggins to come to life with you help! I guess the best way to correspond is thru this thread?

Castle

#30  

I would say yes to using this thread. The purpose of forum is to help others learn by providing solutions to people. It is good to document this in this thread.

#32  

I just ordered a second EZ-B to allow me to work small with the servos that came with my initial SDK as recommended by ANDY ROID. Soon I will be able to test EZ-Script at home