Thumbnail

Servo Recorder

by Synthiam

Record and play back servo movements on your robot at specified speed and direction

Requires ARC v15 (Updated 6/17/2020) Source Code

How to add the Servo Recorder robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Servo category tab.
  5. Press the Servo Recorder icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Servo Recorder robot skill.

How to use the Servo Recorder robot skill

This plugin allows recording and replaying servo movements in specified speeds and direction. Trigger the recording playback and speed using ControlCommand() from scripts.

Realistic Motions For realistic motion recordings, we recommend creating the recordings with the servo Pad Control. Find more information about the servo Pad here: http://www.ez-robot.com/Tutorials/Help.aspx?id=150

Recording You can store multiple recordings in this plugin. Each can be given a unique name that allows the recordings to be differentiated - click on the name to rename a recording. Pressing the Add button will append a new recording instance to the list. You may re-record over existing recordings as well. Press the Record button, which will set the instance to begin recording at the first servo movement.

Playback Individual or multiple recordings can be played back manually by pressing the Play button. Programmatically, you can play recordings using ezscript or Blockly. In Blockly, select the recording from the ControlCommand() block located under Utility. With ezscript, the Cheat Sheet shows the ControlCommand() for starting and stopping the playback of each recording.

Playback Speeds & Direction The modifier allows playback of speed and direction. A value of 1 means original playback speed in forward direction. A value of -1 means original playback speed in reverse direction. The ControlCommand() also accepts an optional parameter for speed. You can specify a value between -5 and +5 with 0.1 increments. For example -0.5 is half speed in reverse. Half speed forward is 0.5.

There is also a ControlCommand() to set the speed while a recording is being played back. You can programatically reverse the playback direction with the ControlCommand() speed parameter, or change the speed.


// Play Reverse at half speed
ControlCommand("Servo Recorder", "Play", "No Name", -0.5);

// Wait for 2 seconds
sleep(2000);

// Set the speed to play forward at half speed 
ControlCommand("Servo Recorder", "Speed", "No Name", 0.5);

Variable There is a variable that returns the status of the playback of recordings. If a recording is being played back, the variable $IsServoRecorderRunning will be true. You can wait for a playback to complete by using WaitFor(). See this example code below, which will run Test 1, Test 2 and Test 3 recordings one after another. The WaitFor() will wait to see when the recording has completed, and the Sleep(100) is merely to ensure the recording has started before checking the variable. The sleep(100) is most likely not required, and my tests without it worked - but I put it in for safe practice. Test in your application to see if it's required as well, it may not be.

print("Playing test 1")

ControlCommand("Servo Recorder", Play, "test 1")

# Wait a short while to ensure record is running
sleep(100)

# Wait for the recorder to stop running
waitfor($IsServoRecorderRunning = false)

print("Playing test 2")

ControlCommand("Servo Recorder", Play, "test 2")

# Wait a short while to ensure record is running
sleep(100)

# Wait for the recorder to stop running
waitfor($IsServoRecorderRunning = false)

print("Playing test 3")

ControlCommand("Servo Recorder", Play, "test 3")

# Wait a short while to ensure record is running
sleep(100)

# Wait for the recorder to stop running
waitfor($IsServoRecorderRunning = false)

User-inserted image


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
USA
#1  

Is there a way to "play" several servo recorders in a script, where each recorded action finishes before playing the next one. I want to play three servo recorder recordings, one after the previous one finishes. I cant use sleep as the sleep would need to be exact length of servo recorder and they need to appear as one long seamless animation. I tried just adding all three to a master script and they all play at the same time. I need something like a play and wait to finish, before moving to the next servo recorder. I'm prolly missing something obvious.

User-inserted image

#2  

I don't know how to do that but it sure would be great to have something like 'SayEZBWait' or in this case 'ControlCommandWait'

PRO
USA
#3  

Exactly what I was thinking Bob!

PRO
USA
#4   — Edited

My first thought is: Three scripts each with one of your recordings controlCommands each Then with a forth script call each of the scripts using the ControlCommand with the wait.  3 extra scripts but the result will work.

#5  

I am sure I am (as usual) overthinking this, but if each of your servo recordings ends with one of the servos going to a unique position (or even moves a servo that otherwise is not used.  Could even be a hidden servo not connected to anything) you could then use the [color=#442e5f][size=3][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][b]Servo_Wait ( digitalPort, higher/lower/equals, value) [/font][/size][/color][/b][color=#442e5f][size=3][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][color=#442e5f][size=3][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]or [/font][/size][/color][color=#442e5f][size=3][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][b]WaitForServoMove (servoPort, [timeout MS])[/font][/size][/color][/b] [color=#442e5f][size=3][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"] command to initiate the next ControlCommand. [/font][/size][/color][/font][/size][/color]

PRO
USA
#6   — Edited

@rz90208 Thats what i thought of last night. I had a good read through DJs commandcontrol in the manual. Some good stuff in there.

After reading that i tried creating 3 separate scripts, each with a servo recording in them like this this one ::

User-inserted image

Then I was able to create a new script and use the command with wait. Like this:

User-inserted image

But When i run i run the loop i get the following error:

User-inserted image

PRO
Synthiam
#7   — Edited

The update of this control has a variable which returns the status. Read the description to see how to use it for your use case.

*Note: I moved this question to a comment under the specific control - since it's related directly to this control for organization. We like to keep things organized

PRO
USA
#8  

Thank you very much. Hopefully I'll get the hang of posting in the right area! Its hard to teach an old dog new tricks!

PRO
USA
#9   — Edited

When i run this script i don't get errors but it runs all the scripts at the same time it doesn't wait for the next one to complete. Am I doing something wrong? For sure.......nearly blew apart Alan..looked like a scene from Total Recall when they are gasping for air on mars....

User-inserted image

#10  

I think you need to check for the word false, not 0.  That is what DJ's example shows.

You can always check the content of variables using variable watcher to see what they show with a simpler script before committing multiple lines that could conflict.

PRO
USA
#11   — Edited

I did try both, 0 and false.  Neither worked for me. When I run the above script, all the other servo recorder play buttons are active at the same time (red). See Pic and you can see the variable watch throwing back a 1 as true its running and running all the servo recorders at once.

And yes, it was stupid to have the robot active during this stage of testing..that wont happen again.

User-inserted image

PRO
Synthiam
#12   — Edited

Ooops - I was distracted with family on new years eve and didn't pay attention to the example code syntax. Check the description now, it has the correct WaitFor() syntax. WaitFor() expects an expression.


ControlCommand("Servo Recorder", Play, "test 1")

# Wait a short while to ensure record is running
sleep(100)

# Wait for the recorder to stop running
waitfor($IsServoRecorderRunning = false)

print("Playing test 2")

ControlCommand("Servo Recorder", Play, "test 2")

This is a good example that you can proof my work in the future:). Next time check the EZ-Script manual to see if i presented the correct syntax, because I'm not perfect haha

PRO
USA
#13  

Much better. Thank you, now works as advertised!

PRO
USA
#14  

Is there a reason why this control does not have an option to move to other desktops using right click in the title bar? When i save and reload the servo recorder windows move from desktop to desktop but don't have the option to move them back ie F11,F12 etc

PRO
Synthiam
#15  

Plugins don't support that currently

PRO
USA
#16  

Ok Thanks very much. And again thanks for this variable!!

PRO
USA
#17  

Thank you for this update.

PRO
USA
#18  

Servo Recorder works well, thanks

EzAng

#19   — Edited

I have a few questions about this skill.

I LOVE this skill! It gives my robots more human-like movements. The only thing I do not like is that each time I start to playback a new recording, the servos jump/jerk from the last position to the new position. I am using this skill to animate my fembot's head as she speaks and It is rough on my servos and the jumping when going from one recording to another looks terrible.

  1. is there a way to pause the playback of the recordings while they are playing?
  2. is there a way to get the servo values from as a recording is played back? (In real time.)
  3. is there a way to manually edit the values of the servo recordings? (I want to be able to return the servos to a known position after each recording is finished.)

Thanks,

--Thomas

PRO
Synthiam
#20  

You can get servo positions in real time using servos that support that. I would suggest checking out the support page that explains how servos work, which has info on what a bidirectional servo is: https://synthiam.com/Support/Advanced-Fundamentals/servo-motor

Although if I were to avoid the jump - it would make sense to bring the servos back into a starting position during the creation of each animation. Otherwise, you're asking not to jump - but how can they not flinch when the servos are in different places? If a servo is at position 2, and the next frame is position 175, it will jump because those are two other numbers. And that's what servos do, is they move. So when a servo is instructed to move, it will do what it's designed to do and move. So moving from one position to another will occur. So you'd want the servos not to have such significant gaps between their positions to remove the "jump" effect.

#21  

To separate my questions:

  1. is there a way to PAUSE the playback of the servo recorder, and then continue from the paused location?
#22   — Edited
  1. Can I edit the servo recorder frames? Where are they stored?
#23  
  1. Can I get the servo values recording FROM THE FRAME, in REAL TIME?

for example, the servo recorder is playing back a recording. It tells servo 1 to move to a new position. Can I get THE POSITION that the servo recorder is playing back in real time?

PRO
Synthiam
#24  

I don't know what kind of servos you're using; as I mentioned, it matters. I provided a link that explains what servos are and the different types.

There are two commands that you can look at, which are available in the support section. I use JavaScript, so that's what I'm linking to

1) https://synthiam.com/Support/javascript-api/Servo/getPosition

2) https://synthiam.com/Support/javascript-api/Servo/getPositionRealtime

As for your other questions and multiple posts, you can scroll up to read the manual for this robot skill.

#25  

This skill seems like it could be very useful. I haven't used it yet but a simple fix for the jumping is to have it go to a certain safe position before and after you send it into the command control. Didn't know this skill existed, very cool.

PRO
Synthiam
#26  

Automation, man, yeah, that's precisely it. And it's not a "fix" because there is no way to get from position 1 to position 180, for example, then to move. There's no other way to "fill in the missing positions" because there's no data to fill in with. It's a chicken and egg scenario - how can the robot move nicely between two positions when there are no positions? Haha.

If a servo "jump" is the issue, perhaps setting the servo speed to a slower value. That way, the servos will move slowly to the new position - I guess that's one way.

But realistically, as a designer, that's a responsibility you will have to endure: moving to a safe position after each animation.

An export/import option for the positions to be edited in excel could be done. But it would be best if you remembered that there would be thousands and thousands of rows.

#27  

DJ, When I record actions with this skill, I assume there is some file created and saved somewhere on my hard drive. Can I edit that FILE?

#28  

A similar skill that I use all the time is the AutoPosition which has frames and actions Inside of the frames you can move and edit each individual servo. This is very helpful to fine-tune each position exactly the way you want it to be.