The youBot API give you complete joint level access to the youBot joints. Every youBot joint is represented as a youbot::YouBotJoint class in the API.
At this stage we make no difference if it is a base joint which powers a wheel or a manipulator joint. By the classes youbot::YouBotBase and youbot::YouBotManipulator it is possible to get access to a youbot::YouBotJoint instance for a particular joint.
To set a setpoint or read some sensor values form the joints you have to use the youbot::JointData classes. Which could be for instance youbot::JointVelocitySetpoint or youbot::JointSensedCurrent.
To configure parameters of a joint, you have to use the youbot::JointParameter classes. Which could be for instance youbot::MaximumPositioningVelocity.
Example how to use:
try {
myYouBotBase.doJointCommutation();
quantity<si::velocity> longitudinalVelocity = 0.2 * meter_per_second;
quantity<si::velocity> transversalVelocity = 0.0 * meter_per_second;
quantity<si::angular_velocity> angularVelocity = 0 * radian_per_second;
quantity<si::velocity> actualLongitudinalVelocity = 0 * meter_per_second;
quantity<si::velocity> actualTransversalVelocity = 0 * meter_per_second;
quantity<si::angular_velocity> actualAngularVelocity = 0 * radian_per_second;
quantity<si::length> actualLongitudinalPose = 0 * meter;
quantity<si::length> actualTransversalPose = 0 * meter;
quantity<si::plane_angle> actualAngle = 0 * radian;
myYouBotBase.setBaseVelocity(longitudinalVelocity, transversalVelocity, angularVelocity);
myYouBotBase.getBaseVelocity(actualLongitudinalVelocity, actualTransversalVelocity, actualAngularVelocity);
myYouBotBase.getBasePosition(actualLongitudinalPose, actualTransversalPose, actualAngle);
LOG(
info) <<
"actual velocity longitudinal: " << actualLongitudinalVelocity <<
" transversal: " << actualTransversalVelocity <<
" angular: " << actualAngularVelocity;
myYouBotBase.getBaseJoint(1).setData(setVel);
myYouBotBase.getBaseJoint(1).setData(setVel);
myYouBotManipulator.doJointCommutation();
myYouBotManipulator.calibrateManipulator();
myYouBotManipulator.getArmJoint(1).getData(current);
std::cout <<
"Current manipulator joint 1: " << current.
current << std::endl;
myYouBotManipulator.getArmJoint(1).getConfigurationParameter(maxPositioningVelocity);
quantity<angular_velocity> velocity;
std::cout << "Maximum positioning speed of joint 1: " << velocity << std::endl;
myYouBotManipulator.getArmJoint(1).setConfigurationParameter(maxPositioningVelocity);
myYouBotManipulator.calibrateGripper();
myYouBotManipulator.getArmGripper().setData(gripperSetPoint);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "unhandled exception" << std::endl;
}
return 0;
}
Run without sudo
The youBot Driver needs access to the raw ethernet device. Under Linux a normal user does not have access to the raw ethernet device. You can grand this capability to a program by the tool setcap. To install setcap use:
sudo apt-get install libcap2-bin
To provide a program with raw access to a ethernet device use: (replace the ./YouBot_KeyboardRemoteControl with your program.)
sudo setcap cap_net_raw+ep ./YouBot_KeyboardRemoteControl
This have to be done whenever the executable is created or replaces e.g. after building.