
Hey Lumpy (or anyone who can advise). I'm addressing this first to Lumpy because I know he is using and working with the Kangaroo X2 / Sabertooth setup. If anyone has some insight please chime in.
Anyway, as mentioned in other posts I'm working through issues with my Kangaroo X2 / Sabertooth setup where I'm using two DC motors that have pots for feedback and limit switches. I now have both motors responding through serial commands from ARC. I had an issue where I was continually getting error codes at power up and would have to power cycle the unit to get it to respond to serial commands. However I found I had to make sure the Sabertooth/Kangaroo powered down completely when the robot and EZB was switched off and then powered up after the EZB was powered up.
My issue now is trying to get the speed ramping feature of the Kangaroo to work. There are different ways to set up the Kangaroo; Velocity or Position control. I cant get the speed ramping to work when serial commands are sent from EZB in either control setting. However, I can get ramping to work nicely in Velocity but not Position tests when using the "Live Test" section of the Describe software used to set up the Kangaroo. When doing these test I'm attached directly to the Kangaroo with a Serial Adapter from a USB port of my laptop and EZB is not connected.
Without any ramping my motor will jerk to full speed and stop suddenly. I've e been working with Dimension Engineering on this for weeks but it's been painfully slow. The only way I can get help from them is through e-mail and it sometimes takes days for them to respond. Then I'll get a one sentence question or answer like "sounds like you need to make sure to upload your settings and reboot" or please send us a copy of your settings. This must be a newer product with limited users. I've found no community forums and few people posting info on this board.
One other thing. What is the best way to set servo control to work independently on the Sabertooth/Kangaroo's second motor channel? So far the only way I've been able to get it to work is if I start the first motor Chanel with a servo command and don't release it. I am using a second cable attached to a second digital port on EZB and attached to S2 of the kangaroo. I'll call that port when I want motor 2 to respond to a servo command.
I must say it is a great little board and from what I've been able to set up, it works great. I like the idea of being able to send servo commands to control my DC motors. Very precise and quick. If I can get this speed ramping issue figured out it will be an excellent addition to my B9 robot motor control.
Thanks Rich for poppping in here with help on this code. It helps more then you know and is very welcomed.
I dont think I would have ever thought of writing it this way. Very nice and just what I was needing. I can see how it will be much smoother. It will be fun to get this code to ramp up, go to the right spot and ramp down as the motor gets there.
I only have a few free hours over the next few days so it may be a while till I get this working. Please keep an eye on me over the next week as I may need a helping hand on this code if your still willing and available.
Dude, I keep an eye on everyone even if I don't always post
Glad it helped.
@irobot58 I have enough praise, I can let a few slide
Rich,
I haven't had a chance to try this code but I've been looking at it a little. I do have a question or two;
Would I have to set this speed variable in the INT script when ARC starts up? I guess I would not have to keep the loop script running all the time waiting if I set it at start up and just call the script when I want to move the jount.
Also I have a feeling I'm going to have to change your commands from EZ Language to C++ or even VB. I'm not sure the Kanagroo will understand the EZ commands. If so I'm going to have to try to learn some of this code. I know the Kangraroo will understand code you would send from an Arduino. Any thoughts on this?
If it understands the Arduino it should understand the ARC commands too. I'll have to look and see if there's any kind of serial monitor I can use to look at exactly what the Kangaroo received from both the Arduino and EZ-B though. Initially though I don't think it would be a problem.
The $X2_Speed would need to be set to something prior to running the script. If you are ramping up, at the very start of the script simply set it to 0 $X2_Speed = 0. If ramping down set it to the fastest speed at the start.
The label for the loop would come after that.
Then the If to slowly increase the speed until a set speed
The the goto
Something like
The code will only loop until max speed (300 in the example) is reached. Once it hits 300 the IF is not true so it runs the code after the Else, which is Halt() which will terminate that script.
Cool, thanks for the fast and thoughtful reply. This all makes sense. I can't wait to have some time this weekend and give this a try.
As far as a monitor, kangaroo does feedback codes and other info like speed and position to a microcontroller. It can be seen with a terminal program on the laptop. I have tried to hook one up to the kangaroo but although I can open a channel I can't understand how to run the several programs I've tried. This is just one more thing I need to tackle. Any suggestions on a good and easy terminal program I can try and that has good instructions?
As far as info feedback from Kangaroo on position and speed maybe the new V4 will be able to read this and let me control better with" Get" statements in scripts.
Holy cats Rich ! Your code works! I'm not surprised but completely amazed that it works so well. I've been struggling with this setup for a while now and had true fears I couldn't make it move to my expectations. I've overcome many challenges and ramping was about the last issue. If I couldn't get it to work I was going to give up. Your code makes the movement ramp up very smoothly and I'm able to easily adjust the acceleration.
Now that I've got the ramp up working I'll need to get the ramp down as the rotation nears the end of rotation. I'll be working on that on the next few days. I would think the code needs to be duplicated and placed between the end of your code (with maybe a delay) and the Halt() command. I've run out of time and energy today so I'll be working on this again in a day or so when I find more of each.
Anyway, Thanks very much Rich. I'm completely thrilled!
I've now got a working script. Thanks again to @Rich for pointing me in the right direction. This successfully ramps the Sabertooth / Kangaroo X2 up to any speed wanted, move to a exact point on a radius and then ramps down to a crawl near the stop point. With the proper timing of the Sleep() command the motor ramps down just before the end and adjusts into center.
It works pretty good but the timing with the Sleep($Sleep) variable and the sleep() pauses in the call script is vital or the ramping will miss and the motor will jerk to a stop at any speed. There has got to be a way to get the position read from Kangaroo into the script. Once I figure that out I can just use Kangaroo's GetP command to start ramping at an exact point instead of relying on timing. That's my next trick. In the mean time the sleep() is working OK and the ramping script is the key part anyway. I'm still looking for other ways to ramp but haven't really tried other commands in C++ that may work. In Kangaroo's Serial Packet reference manual I did find the following but I have no idea how to work it into the script or if it will work. It may only work with the Velocity command but I dont know yet:
Any ideas? I wish I knew better how to write scripts in C++ but in the mean time:
This is the main movement script (pardon my mess) :
Here's an example of the call script. I can make several scripts with different variables set depending on where I what to the motor to stop or how fast to go. It's important to adjust the Sleep() commands so the ramping happens at the right times or the ramping will happen too soon or too late. I only need one "Waist Movement" script that will keep being called:
As always I'm open to suggestions or criticism. Any help is welcomed.
Thanks Dave
I like these scripts. Couldn't they be incorporated into the movement panel? For instance a check box for ramp up and ramp down then if they are ticked, a box for the rate is enabled. A handy feature to be sure. I asked a similar question at one time on the servo control.