transmission_interface
Transmission Interface.
transmission_interface contains data structures for representing mechanical transmissions, and methods for propagating position, velocity and effort variables between actuator and joint spaces.
In the same spirit as the hardware_interface package, this package wraps existing raw data (eg. current actuator position, reference joint command, etc.) under a consistent interface. By not imposing a specific layout on the raw data, it becomes easier to support arbitrary hardware drivers to software control.
The transmission_interface is not used by controllers themselves (it does not implement a HardwareInterface
) but instead operates before or after the controllers update, in the read()
and write()
methods (or equivalents) of the robot abstraction.
Code API
There are three main elements involved in setting up a transmission_interface:
Examples
The first example is minimal, and shows how to propagate the position of a single actuator to joint space through a reducer.
int main(
int argc,
char** argv)
{
double a_pos;
double j_pos;
}
The second example is a bit more complicated, and represents a robot with three actuators and three joints:
- The first actuator/joint are coupled through a reducer.
- The last two actuators/joints are coupled through a differential.
The hardware is such that one can read current actuator position, velocity and effort, and send position commands.
#include <vector>
using std::vector;
class MyRobot
{
public:
MyRobot()
: sim_trans(-10.0,
1.0),
dif_trans(vector<double>(2, 5.0),
vector<double>(2, 1.0))
{
a_state_data[0].position.push_back(&a_curr_pos[0]);
a_state_data[0].velocity.push_back(&a_curr_vel[0]);
a_state_data[0].effort.push_back(&a_curr_eff[0]);
j_state_data[0].position.push_back(&j_curr_pos[0]);
j_state_data[0].velocity.push_back(&j_curr_vel[0]);
j_state_data[0].effort.push_back(&j_curr_eff[0]);
a_cmd_data[0].position.push_back(&a_cmd_pos[0]);
j_cmd_data[0].position.push_back(&j_cmd_pos[0]);
a_state_data[1].position.push_back(&a_curr_pos[1]); a_state_data[1].position.push_back(&a_curr_pos[2]);
a_state_data[1].velocity.push_back(&a_curr_vel[1]); a_state_data[1].velocity.push_back(&a_curr_vel[2]);
a_state_data[1].effort.push_back(&a_curr_eff[1]); a_state_data[1].effort.push_back(&a_curr_eff[2]);
j_state_data[1].position.push_back(&j_curr_pos[1]); j_state_data[1].position.push_back(&j_curr_pos[2]);
j_state_data[1].velocity.push_back(&j_curr_vel[1]); j_state_data[1].velocity.push_back(&j_curr_vel[2]);
j_state_data[1].effort.push_back(&j_curr_eff[1]); j_state_data[1].effort.push_back(&j_curr_eff[2]);
a_cmd_data[1].position.push_back(&a_cmd_pos[1]); a_cmd_data[1].position.push_back(&a_cmd_pos[2]);
j_cmd_data[1].position.push_back(&j_cmd_pos[1]); j_cmd_data[1].position.push_back(&j_cmd_pos[2]);
&sim_trans,
a_state_data[0],
j_state_data[0]));
&dif_trans,
a_state_data[1],
j_state_data[1]));
&sim_trans,
a_cmd_data[0],
j_cmd_data[0]));
&dif_trans,
a_cmd_data[1],
j_cmd_data[1]));
}
void read()
{
act_to_jnt_state.propagate();
}
void write()
{
jnt_to_act_pos.propagate();
}
private:
double a_curr_pos[3];
double a_curr_vel[3];
double a_curr_eff[3];
double a_cmd_pos[3];
double j_curr_pos[3];
double j_curr_vel[3];
double j_curr_eff[3];
double j_cmd_pos[3];
};