Velocity and position control modes on the same hardware
We have a wheel controller that supports both velocity control mode and position control mode. Modes are switch with special explicit commands, mode switches in particular reset encoder values for some reason.
My question is whether it is possible to represent this type of controller within ros_control? As I understand I can create two separate controllers: JointVelocity and JointPosition and switch them on and off with controller manager. There are two aspects I'm not clear about:
While I have methods like ControllerBase::starting in controllers, I'm not sure how I should communicate with hardware interface from that method. Switching modes requires commands to hardware, as I understand such code should be present in my hardware_interface::RobotHW implementation. However, how do I call it from ControllerBase::starting?
Odometry value. Switching mode resets encoder values, however I would obviously like to have continuous odometry even if I switch control modes. However, currently I see no method of communicating the last odometry (or encoder) values from controller that stops to controller that starts. How can I approach this?
Thanks in advance for any help!