Hi, I am doing a task that requires a comfortable speed when the robot move the limb. From my knowledge, I can set up the duration time to control the speed. Is there a way to control the speed directly?
The short answer is “yes, it is possible to control the speed directly”.
There are many ways to do what you asked, so I will provide one method in the context of the position control examples that we provide on our Sample Custom Tasks download section . In the position control examples that we provide, position controllers are used to directly control the movement of the robot. The movement is specified by a trajectory, which is a series of positions over a given duration. These examples create trajectories that have a bell-shaped velocity profile which is specified by a duration and distance (i.e. there is an implicit velocity). However, that trajectory could also be specified by a peak-velocity and distance, for example.
The following code defines the trajectory in the position controller sample:
• trajectory_shape = tick/duration-sin(2*pi*tick/duration)/(2*pi);
• virt_pos = start_pos + (final_pos – start_pos) * trajectory_shape;
Differentiating the virt_pos gives:
• Velocity = (final_pos – start_pos) / duration * (1 – cos(2*pi*tick/duration) )
The peak velocity will occur when tick/duration = 0.5
• Peak_Velocity = (final_pos – start_pos) / duration * 2
• duration = 2 * (final_pos – start_pos) / Peak_Velocity
Therefore, you could use the position controller sample code as in the examples, specify a desired peak velocity (e.g. in your Task Protocol) and then calculate the duration associated with that Peak_Velocity and feed that into the code.
Once I replace duration=input_duration with duration =2*(final_pos-start_pos)/Peak_Velocity. It does not move the handle correctly, it moves so fast and trying to move out of the screen. Cannot figure out why?
The time units in that Stateflow block are milliseconds. So the duration is milliseconds and the Peak_Velocity is metres / millisecond as well. That may account for your high velocity.
Let me know if that solves your problem!
I converted the speed by peakSpeed=desiredSpeed/1000 or peakSpeed=desiredSpeed/100000; Then the handle doesn’t move at all.
The best way to diagnose what the model is doing is to use the xpc scopes (scopes are described in Section 7.5 of our Custom Task Programming user for 3.6). I would put a scope on each
of the desired position inputs (x and y) to double check that the inputs are correct. I also would recommending using the KINdata_bus From tag and use scopes to read some of the values
there to see what the model is doing. In a typical setup, where the robot computer and Dexterit-E computer share a keyboard, video and mouse, the KVM switch will need to be used to
switch the monitor to view the robot computer (e.g. double tap to switch which computer is viewed on the monitor). On the robot computer screen you will see what your
scopes are outputting.
When you connect the KINdata_bus From tag to a Bus Selector component and double click the Bus Selector, you will be able to choose from a host of data that you will be able to read on a
scope. This includes the x and y velocities, the commanded forces, as well as the x and y acceleration. You can check that against your math and see if what’s happening is what you
expected to happen.