Open roboticsai opened 3 years ago
I think you're on the right track with implementing the PWM in write()
.
These two lines are suspicious:
int joint1_out_pow = pid1.computeCommand(pow1_error,elapsed_time);
int joint2_out_pow = pid1.computeCommand(pow2_error,elapsed_time);
You shouldn't be making the call to PID controllers yourself. That gets done automatically by ros_control. Take a look here:
joint_position_command_[joint_id]
is automatically calculated from a PID controller, you just have to use it.
@AndyZe wrote:
You shouldn't be making the call to PID controllers yourself. That gets done automatically by ros_control.
not saying it's correct in this case, but there are actually closed loop hardware_interface
implementations.
ros_control
even comes with a few adapters for those.
Well, gavanderhoorn may well be right. I guess there is no issue with calling your own PID controllers directly. It's just a bit unusual.
Another issue:
int joint1_out_pow = pid1.computeCommand(pow1_error,elapsed_time);
int joint2_out_pow = pid1.computeCommand(pow2_error,elapsed_time);
Shouldn't it be pid1
and pid2
? A separate controller for each joint.
I think you would also need to scale the PID controller output carefully so it is in the range of 0-255. It might be that the output of your PID controllers is tiny, like 0-1.
I have integrated the ros pid controllers in the read and write functions of the hardware interface of my robot like this:
But when i run this hardware interface with diff drive controller and publish the cmd_vel command in twist topic. The output power which is pwm in this case is not properly comming. I asked this question in ros forum they said its not the way to use the pid controllers. If no what is the correct method to use the pid controllers in the hardware interface with ros control boiler plate? Plate-form: ros noetic, ubuntu 20.04. Here i've used the read and write functions from the serial library i've used. which does the reading and writing tasks from arduino nano connected to the raspberry pi where i'm running this, where encoder data is being read and pwm to dc motors has been sent.