Cryoschrome
Member
Hi,
I have a trajectory, which contains 3 arrays (positions, velocity, and acceleration). Sample arrays are given below.
The logic I need to implement is such that at position[0] velocity and acceleration should also be velocity[0] and acceleration[0] and when position[1] has been reached the update velocity and acceleration with velocity[1] and acceleration[1] as factors and so on.
The problem I am facing two issues:
1: Since I am using micro_ros for communicating the above trajector to teensy for execution, I am not able to accurately check if the position has been reached to then override the speed and acceleration, due to the latencies introduced in the loop due to micro_ros. Is there a better way I could approach the execution of the trajectory?
2: Since I want to control the velocity and acceleration, I figured that RotateControl was the way to move forward. But the motor overshoots at the end of the trajectory due to the deceleration. Is there a direct correlation between the speed and acceleration values and the number of steps it will overshoot before coming to a complete stop?
I have a trajectory, which contains 3 arrays (positions, velocity, and acceleration). Sample arrays are given below.
The logic I need to implement is such that at position[0] velocity and acceleration should also be velocity[0] and acceleration[0] and when position[1] has been reached the update velocity and acceleration with velocity[1] and acceleration[1] as factors and so on.
The problem I am facing two issues:
1: Since I am using micro_ros for communicating the above trajector to teensy for execution, I am not able to accurately check if the position has been reached to then override the speed and acceleration, due to the latencies introduced in the loop due to micro_ros. Is there a better way I could approach the execution of the trajectory?
Code:
...
void moveCallback(const void *req, void *res)
{
custom_interfaces__srv__MoveitControl_Request *req_in = (custom_interfaces__srv__MoveitControl_Request *)req;
custom_interfaces__srv__MoveitControl_Response *res_in = (custom_interfaces__srv__MoveitControl_Response *)res;
if (valuesInitialised) {
if(notMotorActive()) {
if(req_in->joint_positions.size > 0)
{
positions = req_in->joint_positions.data;
velocities = req_in->joint_velocities.data;
positionsSize = req_in->joint_positions.size;
moveFlag = true;
rotateMotor.rotateAsync(motor);
rotateMotor.overrideSpeed(0.0f);
res_in->success = true;
}
else {
res_in->success = false;
}
}
else {
res_in->success = false;
}
}
else {
res_in->success = false;
}
}
void loop()
{
RCSOFTCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)));
if(moveFlag)
{
if(moveCount == 9) {
moveCount = 0;
moveFlag = false;
rotateMotor.stop();
}
if(speedFlag) {
rotateMotor.overrideSpeed(speed);
speedFlag = false;
}
if(motor.getPosition() == positions[moveCount]) {
speedFlag = true;
moveCount++;
}
}
}
2: Since I want to control the velocity and acceleration, I figured that RotateControl was the way to move forward. But the motor overshoots at the end of the trajectory due to the deceleration. Is there a direct correlation between the speed and acceleration values and the number of steps it will overshoot before coming to a complete stop?