
Creativita
Australia
Asked
— Edited
This thread is for the purpose of script evaluation. If you are stuck in writing a script or just can't get it to work post it and it can be checked by other EZ-B users. It can also be used for the sharing of a script that you believe would be particularly useful to others. Remember to include a breakdown of all the parts of your script.
$second doesn't have a value that you can use that way, that's why... You don't need to use it anyway just use the sleep command as below...
Just to clarify why $second isn't working. It is not the number of seconds from the time the step is hit, it is the seconds of the current time. ie, if it is 8:12:24 am, then $seconds with be = 24 ($hours will be 8 and at minutes will be 12)
So what your script was doing was executing the action for up to a minute depending on when you started it, until it was 2 seconds after the current (next) minute.
Alan
Richard / Alan, Thank you for the answers! I totally misunderstood the function of $second (sigh) and now I get how that works and will test with Richards method of using the delay (sleep xxx).
Just as an aside, do you suppose that is the best way to program rotation on this? I cant imagine I am the first to try and use a robot that was not differential steered?
Thanks, Greg
@Steve G used a steering wheel separate from his drive wheels in his K-9 project.
You might find details looking in his project showcase here: https://synthiam.com/Community/Questions/6837
Or searching his forum history: https://synthiam.com/User/steve-g/ForumPosts
Alan
Alan, That K-9 project looks great! Thanks for pointing me towards it. I am curious how @Steve G worked out his steering.
I will try a few things tonight and post my pics somewhere up here on my Hero Jr. Status.
Thank you! Greg
Steve has been dealing with some family issues and hasn't commented on the forum in a while, but I will drop him an email and point him to this thread.
Alan
@Alan.
Hey buddy. I got you email. I'll shoot you one off back shortly.
@GregSS.
After reading Alan's email, and reading the thread, I'll see if I can offer some help for you. I will write two posts to help make things a bit clearer so I will take you through K-9's drive setup with script examples first, then hopefully give you some simpler script examples using your project using your port details. (Forgive me if things seem as clear as mud, lol, its been a while since I've been here writing anything so I'm a bit rusty).
Just to explain, K-9's drive setup is a two rear wheel drive system, with an freewheeling (un-powered) front steering wheel which sits on a bearing that turns using a 180 servo. The forward body weight is supported by a Lazy Susan bearing which takes all of the weight so there's no strain on the servo itself. If you have watched any of the K-9 showcase videos, you will also see his head move into the direction he turns (which also is a good visual indicator for which way the steering wheel is facing). The servo that moves the head is linked via script to the steering servo and works under the same principles explained below. The steering system that I have set up has the best of both worlds... steer then move, or steer AND move.
Above is a screen grab of K-9's mobile interface control. As you can see, there are "Turn Right" and "Turn Left" buttons which steers the steering wheel left or right without drive movement, with "Turn Right" and "Steer Centre" centering the wheel for forward movement.
Above the left and right buttons, you will also see "Forward Right" and "Forward Left". These buttons will steer in the chosen direction and move the drive wheels forwards simultaneously, which I believe is what you're after. After the desired turning position is reached, I can either press "Forward Right" or "Forward Left" button a second time which will now stop the drive motors and centre the steering. Or, I can simply press "Steer Centre" which will centre the steering, but continue to power the drive wheels so he will now steer and drive in a straight line. Two quick taps of the forward or reverse buttons, and K-9 will stop. What you could do here is to add a "Stop" button to you mobile control.
Anyway, here's how my scrips are set up for turning while moving.
First off, I added an Init script to my EZ-B Connection control on ARC...
Connection INIT script.
Then I added a Custom Movement Panel, then opened the config menu to add the following scripts...
Custom Movement Panel script for "Right".
Custom Movement Panel script for "Left".
Custom Movement Panel scripts for "Stop".
The next thing was to add and configure the mobile control. I added three image buttons for Forward Right, Forward Left and Steer Centre, then added the following scripts to each of the corresponding buttons...
Mobile interface controls for Forward Right.
Mobile interface controls for Forward Left.
Mobile interface controls for Steer Centre.
Once everything is saved, EZ-B connected to ARC, to control K-9 using just the three buttons mentioned above I can press Forward Right once, and he will turn and move right. pressing Forward Right a second time and he will stop and steer centre (same for Forward Left. Or I can press Forward Right once, and he will turn and move right, then i can press Steer Centre and his steering will return to centre, but still move forwards. This is where you may want to add a "STOP" button to your mobile control and script it to press once and override all movement.
The next post will be using something similar to the above, but simplified and using the information in the script you posted...
Here's a few script examples using your projects port details using the controls I use mentioned in the previous post.
First off, add an Init script to your EZ-B Connection control on ARC...
Connection INIT script.
Then add a custom control panel, open the config menu, and add the following...
Custom Movement Panel script for "Right".
Custom Movement Panel script for "Left".
Custom Movement Panel script for "Stop and Centre".
Script digital ports D1 and D2 or forwards and reverse movements in the custom movement panels. In the mobile interface control, add three buttons for steer left, steer right and stop motor/centre steering, then configure the buttons with the following scripts...
Mobile interface controls for Forward Right.
Mobile interface controls for Forward Left.
Mobile interface controls for Stop/Steer Centre.
Then you can add forward and reverse buttons.
Once saved and the EZ-B is connected to your ARC project, you should have the same kind of control mentioned in the previous post. Of course, you don't have to use the $pressed = 0 (Push On" "Push Off) mobile button idea, and you could simply use the the scripts I've used in the custom movement panel, and use the scripts directly in the mobile buttons. I like to use the $pressed variable in the mobile interface because it can sometimes save on adding buttons, for example a "On" button and an "Off" button where using the $pressed variable makes just one button have two uses.
Anyway, have a play around and I hope the info I provided will help you Greg, but although I'm not back on the forum properly yet, I do monitor the boards from time to time so if you have any further questions, let me know and I'll see if I can help further. If I'm not around, there are plenty of great guys here as you've seen already who will be able to help or advise.
good luck matey.
Steve.