forked from ros-controls/ros_control
-
Notifications
You must be signed in to change notification settings - Fork 5
Home
wmeeusse edited this page Nov 9, 2012
·
21 revisions
This is a future project that hasn't really even been written yet
Suppose we have a robot with 2 joints: A & B. Joint A is position controlled, and Joint B is Velocity controlled.
class MyRobotHW : public JointEffortCommandInterface, public JointCommandPositionInterface
{
public:
RobotHW() { }
const std::vector<std::string> getJointNames()
{
std::vector<std::string> names;
names.push_back("A");
names.push_back("B");
return names;
}
double& getPositionCommand(const std::string& name)
{
if (name == "A")
return joint_A_pos_command_;
else
throw Error(name + "is not a Position Joint");
}
double& getEffortCommand(const std::string& name)
{
if (name == "B")
return joint_B_pos_command_;
else
throw Error(name + "Is not a Velocity Joint");
}
double getPosition(const std::string& name)
{
if (name == "A")
return pos[0];
else if(name == "B")
return pos[1];
else
return Error(name + " is not known");
}
double getVelocity(const std::string& name)
{
if (name == "A")
return vel[0];
else if(name == "B")
return vel[1];
else
return Error(name + " is not known");
}
double getEffort(const std::string& name)
{
if (name == "A")
return eff[0];
else if(name == "B")
return eff[1];
else
return Error(name + " is not known");
}
private:
double joint_A_pos_command_;
double joint_B_vel_command_;
double pos[2];
double vel[2];
double eff[2];
}