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

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

#1  

All you need is 180 "if" statements for left and 180 "if" statements for right.... :P

Seriously I would use larger "chunk" like commands... for instance right 1deg, 5deg, 10deg, 30deg, 60deg, 90deg, etc.... same for the left...

So say you need 96deg left (from centre)... you say "rotate left 90" then in a second voice command say "rotate left 5deg" and lastly in a third command say "rotate left 1 deg"... total 96deg left...

#2  

You could use a script that is fired by saying "Wiggins, move right". The script would set a variable (say $movingdirection) to right. From there, Wiggins would ask "How many degrees?" You would have 1 entry in the speech recognition control for each of the degrees that you want. You would say the number, which could be phonetically correct ("won" for 1 for example, "to" for two). This would set a variable (say $movedistance) to the value.

Your script would set the direction and distance that you want to move and perform the action if there is a valid value in $moveingdirection and $movedistance. It could also set a variable of say $moving to indicate that the motor is moving until it reached its location. From there, you would clear the variables and wait for the next command.

It will be a pain to put in all of the entries into the speech recognition control, but these can be entered once and then used for other things also.

#3  

Thanks for the grin! I'm thinking something a bit more elegant might be appropriate - again like setting a variable via voice and then executing that variable... hmmmm

#4  

In my solution above, I would put in "Wiggins won" instead of just "won" for 1. The reason is that you want to make sure that when you address your robot, you always put the name in first to reduce the chance that the robot picks up something unintended and runs with it.

#5  

David has a good point... That arm you are building (I think you mentioned the ability to move 70lbs or so) could do some serious damage if it should move unintentionally... You need to write your voice commands to be rock solid to avoid any dangerous surprise movements.... It might not be a bad idea to also "cage" the arm for safety...

#6  

Limiting damage and unintentional movement is going to be interesting - maybe a 360 degree LIDAR for collision detection... not sure what you mean by "cage".

Would it be asking too much for some sample EZ-Script to get me started?

Castle

#7  

You could even get creative with the scripts for the numbers and have it first check to see if the $movingdirection variable has a "Right" or "Left" prior to setting the $movedistance variable.

A couple of other things that I would do... disable speech recognition when your robot is speaking (done through the script) disable speech recognition when the robot is moving. You may want to incorporate a button that can be pressed as an emergency stop that could be hooked up to a digital port and monitored. When pressed, the digital port would go to high for example, and the movement script would send a stop command to the Kangaroo.

#8  

I will put together a sample project for you. It will be limited but you will get the idea pretty easily.

#9  

Where I work robotic arms are kept in a caged area so people don't unintentionally walk into to one while it is moving... Only authorized people are allowed in the cage... So the cage I am referring to is an actual cage like a bird cage but only way bigger...

#10  

Wonderful! The cage idea is probably a good one but I want Wiggins to be an assistant arm with the ability to reach anywhere inside my barn workshop so the barn would be the cage. Typically I am the only person in the barn.

I look forward to the sample script - I'm still struggling with how to get a spoken command to interface with a Horizontal servo control in my ARC project - so something beginner would be appropriate -sorry for the need for all the handholding...

Castle

#11  

there is a sample of what I am talking about doing. I dont know the commands that you need to have put in your code for the Kangaroo to function in the way you have it functioning, but this should get you started.

The project is called For castlephelps

#12  

if you grabbed it already, I had forgotten one thing. There is a new version out there now.

#13  

Servo (servoPort, position) is what you would probably use in your script.

You may want to store the previous position, do some math based on the request, and determine the location the arm needs to be in, then store this value in the previous position variable.

You could also read the pot through analog but I think it is tied to the Kangaroo in your solution, so probably just storing as a variable and using it to calculate what position to tell the motor to go to from the previous value + or - the distance you want to move from the command (determined by left or right) would work fine for you.

In the init script, I would add something like this


Servo (servoPort, 90)
$PreviousLocation = 90

to move the arm to the center as an initialization process.

In the movemotor script you would add something like this under either the left or right condition depending on how the motor works.

under left if statement


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

under right if statement


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

#14  

I wrote a script to go to coordinates and found GetServo(servo port) works well for data feedback.

Ron R

#15  

Cool, you could then make it pretty easy to then get the servo location and do the calculation based off of that.

#16  

I will post my test script in my other thread.

Ron R

#17  

I was wondering If you could use different commands like, move ninety. move twenty, move ten, move five, move one, turn right, turn left, move up, move down, stop, activate. With eleven commands commands you could operate in all directions.

Just a thought.

Ron R

#18  

Sure, the example was just to show him how to have a conversation with ARC through scripting so that he could move a specific distance instead of set distances.

#19  

Hi!

This all looks great / I have a lot to learn - for example I don't know how to find the For castlephelps project you posted...I have been heads down foing mechanical and wiring stuff on Wiggins all day. I hope to be working with your code tomorrow - here's a photo of my progress.

Castle

User-inserted image

#20  

Look through the recent threads from yesterday for a thread titled "For castlephelps"... below your name click on download app....

#21  

Hi Richard,

Wow, you really lost me on that one. I looked back through this series of answers to my question and thread #12 lists For castlephelps. There is nothing to click on that I can find anywhere. Can you be a bit more specific about where I would find this?

I could not find a thread titled For castlephelps. Where should I be searching?

Thanks, Castle

#22  

One way to cut down on the number of entries in the Speech Recognition control would be to use individual numbers and pause briefly between them. Then use a script to bring them together into a complete number. For example you might say one two two for 122. The Speech Recognition control would be programmed to recognize the 10 basic digits, zero through nine. The brief pause between numbers would be to allow the control to recognize each number. An overarching script would take in each number in turn and bring them together for eventual execution.

In the same manner, you could also put the words "Hundred", "Twelve", "Thirteen", "Twenty", "Thirty" etc. to be able to say "One Hundred Twenty" "Fifty Seven" etc as the words to be recognized to give it all a more natural sounding tone. With the same pauses between the words.

If neither of those ideas appeal to you, I can at least save you a lot of typing. I have a program I used a while back to extract the entries in the Speech Recognition control and present them in a grid for modifying as desired. Additionally, it can save that same data to a text file, as well as load from a text file. Finally, it can save that data back into an EZB project file. I could whip up a quicky routine to automatically create a text file with all the numbers from 0 to 180 in the proper format for importing into my program, and then into an EZB file so as to show up in the project's Speech Recognition control.

If you post your current project with your current Speech Recognition control, I can download it and add whatever you already have in the control and merge it with the number data. My program can even alphabetize the whole thing (or only a part) if you like. It can then put it into your project file which I can upload for you to download. Let me know. Shouldn't take more than a day or two to do.

#23  

Wow - that is very interesting! Thank you for the offer! So far all I have been focusing on is determining if what I want my robot to do is possible (yes), building the mechanicals (making good progress) and doing simple things in ARC to make the motors move.

I have now arrived at the point where I need to learn how to pull it all together and write the scripts to do what I want.

So right now my next task is to connect speech recognition to a servo control then doing what we have been discussing in this thread will be added and then what you propose would be added. So I have some baby steps to take...

You guys are way beyond me but I will get get there! Now knowing I can do what I want (as illustrated in this topic discussion) is fantastic! Now to pull it together...

Thank you, Castle

#24  

Hi castle,

You really need to first play with a simple servo. Make a new project and add the servo (horizontal or vertical). Be sure to go to a tutorial to learn about it. Clicking the gear goes to the setup, the "?" gives information. Once you get that working and understand, you can mess with below:

Here it a start on speech control. 1 Set up your ezb with one servo connected to D0. 2 Set up speech recognition. 3 click on the gear 4 in the blank space on the bottom left, write move to a 5 in the blank space next to that on the right type servo (D0,90) enter 6 on the new line left, write move to b 7 on the right type Servo(D0,120) enter

(I hope I didn't forget anything)( if I did, go to the tutorial to check)

connect the ezb and test and play using verbal commands to move the servo.

You need to use the "?" over the commands you want to play with. examples.. I get reminded of this often.

By doing this experiment, you can see how this works. YOU MUST consider speed issues because with the massive arm, you will need to control the maximum speed.

Use the tutorials and all the information everyone has given you to go further.

I always test small and on the bench before moving to the actual robot or device.

Ron R

#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

#33  

This will make things much nicer for you. A small scale version of what you are building to test with could be very beneficial.

#34  

I think you will have a lot less "White Knuckle" issues.. LOL... A test of raw scripting with the full size arm could have the barn "reorganized" in a way you might not want it.

A test unit at home will be nice to prove out your designs. Have fun.

Ron R

#35  

I initially started out building a small scale of Wiggins out of aluminum but the servos that came with the SDK weren't strong enough to make it work but if I concentrate on one axis at a time I can still use this mockup. Thanks for the redirection although it is quite fascinating watching the full size Wiggins moving. I've attached a photo of my early model.

Castle

User-inserted image

#36  

I am unable to explain why all of my photos display rotated 90 degrees...

#37  

Quote:

I am unable to explain why all of my photos display rotated 90 degrees.

Are you taking the pictures with an iPhone? Everyone I know who uses one has this problem. The Metadata embedded in the photos clearly screws up the orientation info. (My wife's Mac also messes up pictures from my Android but my PC's don't).

Alan

#38  

As a matter of fact yes I am using an iPhone. I emailed the photo from the iPhone to my Windows 10 computer and then posted it - still rotated. How can I strip off the offending metadata?

I feel kind of embarrassed that my photos aren't coming out straight...

Castle

#39  

One thing to keep in mind when building the model is that you don't need to use heavier materials like aluminum. Plastic, and even thick cardboard is fine. All you are doing is making something that moves like the large unit. It doesn't have to actually lift anything. Well, other than servos that is and they don't weigh much.

EDIT As to the photos, you could flip them before sending them so they will come out right on this end.

#40  

I agree with WBS00001. I use foam board and a glue gun. Anything around the house will work. This way the batteries last longer and it is easy to make changes. Being able to doing this at home will be helpful. I look forward to your progress and wish you well..

Ron R

#41  

Hi guys,

This is great information! I will definitely reconstruct the model with your ideas as I test out code when the EZ-B arrives hopefully next week. Sorry for the noise but I am uploading one of my photos of Wiggins that I rotated. I'm curious to see if it comes out correctly. It is a photo taken with my iPhone 6+ and I have rotated it 90 degrees to the right (clockwise). Let's see if it comes out right side up. Again, sorry for the bandwidth.

Castle

User-inserted image

#43  

Weird - I guess you have to rotate it to the right and save it, then rotate it back and save it and then it comes out correct. Something to remember, at least for me.

Again, sorry for the bandwidth.

Castle

#44  

I was looking through the ARC manual and it looks like the servoup and servodown the code will really help with moving without having to identify current position. Any experience with thus guys?

#45  

I use it all the time.

Here is a script example I have to open the hand on my Roli. It is triggered as long as I am holding down a key on my joystick or the O key on my keyboard. If the of the servo goes above 90, it does nothing.


RepeatWhile(GetServo(D13) < 90)
  ServoUp(D13, 2)
Sleep(150)
EndRepeatWhile

Alan