I am reading the encoder pins by using the ros arduino bridge, where i am subscribing to the encoder pins inside my ros node i.e a c++ program. Here every time a new pin value arrives in program all its variables are reset. But as i saw the encoder programs one variable has to store the privious encoder position, so how can it be done in c++. The arduino program to read encoder is:
Now in the callback function how do i program the encoder? Here since every time the ros node subscribes to a new topic all the parameters inside the program is also reset, i am getting the problem.
I am reading the encoder pins by using the ros arduino bridge, where i am subscribing to the encoder pins inside my ros node i.e a c++ program. Here every time a new pin value arrives in program all its variables are reset. But as i saw the encoder programs one variable has to store the privious encoder position, so how can it be done in c++. The arduino program to read encoder is:
Currentely my roscpp program is:
Now in the callback function how do i program the encoder? Here since every time the ros node subscribes to a new topic all the parameters inside the program is also reset, i am getting the problem.