ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Alternatively, you could place the loop to be on the Publisher side. It would publish at a constant rate even if the value isn't changing. The ROS Publisher/Subscriber tutorial has an example of publishing at a fixed rate.

For the subscriber callback, you would run one PID iteration with every new message. You would need some memory on the Subscriber side for the integral and the derivative, which you could do with a class (like Airuno said) or with global variables. If you use global variables, it's good practice to put them in a namespace.

Alternatively, you could place the loop to be on the Publisher side. It would publish at a constant rate even if the value isn't changing. The ROS Publisher/Subscriber tutorial has an example of publishing at a fixed rate.

For the subscriber callback, you would run one PID iteration with every new message. You would need some memory on the Subscriber side for to store the integral and the derivative, which you could do with a class (like Airuno said) or with global variables. If you use global variables, it's good practice to put them in a namespace.

Alternatively, you could place the loop on the Publisher side. It would publish at a constant rate even if the value isn't changing. The ROS Publisher/Subscriber tutorial has an example of publishing at a fixed rate.

For the subscriber callback, you would run one PID iteration with every new message. You would need some memory on the Subscriber side to store the integral and the derivative, which you could do with a class (like Airuno said) or with global variables. If you use global variables, it's good practice to put them in a namespace.

Alternatively, you could place the loop on the Publisher side. It would publish at a constant rate even if the value isn't changing. The ROS Publisher/Subscriber tutorial has an example of publishing at a fixed rate.rate.

For the subscriber callback, you would run one PID iteration with every new message. You would need some memory on the Subscriber side to store the integral and the derivative, previous error, which you could do with a class (like Airuno said) or with global variables. If you use global variables, it's good practice to put them in a namespace.