ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

Thumbnail

Custom Movement Panel

+ How To Add This Control To Your Project (Click to Expand)
  1. Load the most recent release of ARC.
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Control from the button ribbon bar in ARC.
  4. Choose the Movement Panels category tab.
  5. Press the Custom Movement Panel icon to add the control to your project.
If your robot requires a motor/movement controller that is not supported, use this skill. You may assign scripts to the Forward, Backward, Left, Right, and Stop commands.

There are also script functions available to you to obtain the currently selected speed of both Left and Right wheels. You may modify the speed using SetSpeed(value). The speed values may be altered by any joystick-style skill that affects speed, such as the Joystick in Mobile Interface or a physical joystick using the Joystick Control.

Main Window



1. Movement Panel
These buttons will allow you to control the directional movement of the entire robot (left, right, forward, reverse, and stop).

2. Speed Sliders
You can select the speed of the servos with these sliders. Be aware that the speed range is (0-255) and the default settings are 100% (255). These sliders can allow you to adjust for one motor being faster than the other.

Settings



1. Stop Script
This script will stop the moving robot. It will also activate when the Stop() script is called.

2. Direction Scripts
These scripts will control which way the robot will move when the movement panel buttons are pressed or movement scripts are called [ex: Forward()].

3. Speed Changed Script
This script will execute when the speed sliders are adjusted in the main window or when the setSpeed() script is called.

How to Use Custom Movement Panel


1) Physically connect your robot to an EZ-B.

2) Add the Custom Movement Panel Skill to your ARC project (Project -> Add Skill -> Movement Panels -> Custom Movement Panel).

3) In the Settings menu select enter the scripts you would like to use for each of the directions and stop.

4) In the main window press the direction buttons to move your robot. If the directions seem reversed you can simply change your scripts.

Code Samples


Available EZ-script functions to obtain the current speed are:

GetSpeed( )
Returns the global Movement Speed value
Speed is between 0 and 255
The speed can be viewed in the Script Variable Viewer
Example: $x = GetSpeed()


GetSpeedLeft( )
Returns the global Movement Speed value of the Left wheel
Speed is between 0 and 255
The speed can be viewed in the Script Variable Viewer
Example: $x = GetSpeedLeft()


GetSpeedRight( )
Returns the global Movement Speed value of the Right wheel
Speed is between 0 and 255
The speed can be viewed in the Script Variable Viewer
Example: $x = GetSpeedRight()


Resources


Read more about how Movement Panels work here.


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

PRO
Canada
#1  
Hello @DJ

I'm working with mecanum wheels and it's a lot of fun! The custom Movement Panel works great for controlling 2 H-bridges with individual wheel control.

But I had a few questions for you:

1. Would it be possible to add diagonal buttons to the custom movement panel?

User-inserted image


2. Could you use a combination of arrow keys to activate the diagonal buttons? 
(ex: up and right keyboard keys pressed together activates the forward-right diagonal movement)

User-inserted image
User-inserted image


3. Could this also work with the Movement Joystick skill?
(ex: Moving the joystick in-between the forward and right position activates the forward-right diagonal movement)


User-inserted image
User-inserted image

 

Here's a picture of all the movements mecanum wheels can do:

User-inserted image


This would be a bonus, that couldn't work with the joystick, but is it also possible to have buttons to activate: Turning left, turning right, and curved trajectories?
PRO
Synthiam
#2  
The custom Movement Panel requires you to write that in your code. Read what a Movement Panel is. 

forward is forward but with a left and right speed. That’s how you get diagonal. 

Use another Movement Panel to see how the joystick behaves. You’ll notice diagonal and everything you asked for exists. So write that in your own custom movement panel.
PRO
Synthiam
#3  
Did you figure it out yet? Here's some help to get you going...


1) Here's a project with a Movement Joystick and Custom Movement Panel. You don't have to use a movement joystick, you can use a real joystick or whatever you want. This example is showing this. They're all compatible though because the custom Movement Panel takes care of it.
User-inserted image




2) When the movement joystick is pushed forward all the way, you'll see the speed on the custom Movement Panel go to the max value. The max value can be specified by the movement joystick or whatever joystick robot skill you use. See how it's going forward with both speeds at 255.
User-inserted image



3) Now let's go diagonal North-East direction. See how the LEFT speed maintained 255 and the RIGHT speed lowered, but we're still going "Forward". That's because we're going forward at an angle.
User-inserted image



So what you're code can do is take the speed from using Movement.getSpeedLeft() and Movement.getSpeedRight() and turn that into a speed for your robot controller. If your robot controller accepts some value between 0-100, then you'll have to map the ARC speed (0-255) to 0-100. That's easy using the Map Range command.

Mapping a range to another range is easy like this... So we'll pretend that your Forward Custom Movement Panel script needs to map ARC 0-255 to 0-100. Then you do this...

Code:


var newSpeedLeft = Utility.map(Movement.getSpeedLeft(), 0, 255, 0, 100);
var newSpeedRight = Utility.map(Movement.getSpeedRight(), 0, 255, 0, 100);


In the example above, your variables newSpeedLeft and newSpeedRight contain the newly mapped speed value for the controller.
PRO
Canada
#4   — Edited
Thank you very much @DJ,

Sorry I didn't reply. I did get it figured out on Sunday night. I wanted to post today but ran out of time. After you mentioned using the speed values I started messing around with the Joystick and seeing the speed values change (just as you described above). The key discovery for me was figuring out where to grab the speed values. I finally noticed the "Speed Changed" Script area and placed the following code into there:

Code:

var $r = Movement.getSpeedRight();
var $l = Movement.getSpeedLeftt();
I then placed those speed values into PWM commands (0-255) for the 2 x Dual H-Bridge enable lines, for example:

Code:

PWM.set(D0, $r);
Digital.set(D1, false); // front right
Digital.set(D2, true);
Digital.set(D3, false); // front left
Digital.set(D4, true);
PWM.set(D5, $l);
PWM.set(D6, $l);
Digital.set(D7, true); //back left
Digital.set(D8, false);
Digital.set(D9, true); //back right
Digital.set(D10, false);
PWM.set(D11, $r);
After I got that figured out I went back to try using the keyboard and had to reset the Speed value for left and right manually. Obviously, the Joystick skill sets the speed values to zero after it springs back to the center. I guess I could disable the check box in the Joystick settings that resets it to center when released.

After doing some fooling around with the Joystick control I found that changing the speeds could allow the mecanum wheel robot to move in a curved trajectory when moving forward-right, forward-left, backward-right, and backward-left.

User-inserted image


I love the strafe movement that mecanum wheels allow you to do, so it felt like I was still missing the strafe movements for the diagonal movements of forward-right, forward-left, backward-right, and backward-left.

User-inserted image


I know I can just script those motions to happen by disabling the corresponding wheels in code but in order to switch between "Strafe mode" and "Curved Trajectory Mode" I would need to create some more scripts. I would also need to devise a way to switch between the modes. It seems that it would be a one or the other scenario, Strafe or Curved Trajectory mode.

In my journey, I found that the Movement Panel skills don't allow for multiple arrow keys to be detected, only the first detected key. Is that a windows thing? I would love to have the ability to activate the diagonal movements with the keyboard. I know that would require diagonal buttons (NW, NE, SE, and SW), pictured in yellow, and corresponding script sections for each. I'm not sure if that is even possible but I would love it!

User-inserted image


*Edit: Whoops just noticed that PWM takes (0-100) values so yes, I would need to remap the values as you suggested in your post.

*Edit 2: I forgot to mention that I noticed that if you enter the speed values in the "Left Speed" and "Right Speed" sliders of the Custom Movement Panel skill manually by right-clicking and entering the values with your keyboard (making sure to hit "enter" to confirm the change) the values don't take. If you use the sliders themselves it works, but using the keyboard to enter values seems to be not working for me.
PRO
Canada
#6  
Excellent suggestion @DJ! I used the Key Control Skill with keys Q, W, E, A, S, D, Z, X, & C to control all the strafe directions (NW, N, NE, W, Nothing, E, SW, S, & SE). I actually used X for reverse instead of S because it made a bit more sense with all the directions. I'm now happy for time being with this kind of user control:D
#7  
I have question of the main window panel shown above.  The above pictures show the movement panel  two speed indicators in digital format next to the directional arrows.  
My custom Movement Panel ( yes I just updated to the lates10.3.2021 version) still shows two slider bars bext to the directional arrows.
Which one is the correct latest one and how I get it? Thanks
PRO
Synthiam
#8  
Show us a screenshot. I don’t think it’s a custom movement panel.
#9  
I found my issues. Yes was looking at wrong  panel.  ThanksxD