Usage

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:

#include "youbot/YouBotBase.hpp"
#include "youbot/YouBotManipulator.hpp"

using namespace youbot;

int main() {
  try {
    
    
    // creates a YouBotBase instance with the name "youbot-base" which is also the name of the config file
                YouBotBase myYouBotBase("youbot-base");

                // do the sine commutation of the base joints
                myYouBotBase.doJointCommutation();
    
    // create variables to set and get the base cartesian velocity and pose
    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;
    
    // sets the base cartesian velocity
    myYouBotBase.setBaseVelocity(longitudinalVelocity, transversalVelocity, angularVelocity);
    
    // reads the base cartesian velocity
    myYouBotBase.getBaseVelocity(actualLongitudinalVelocity, actualTransversalVelocity, actualAngularVelocity);
    
    // reads the base cartesian position which have been calculated from the odometry
    myYouBotBase.getBasePosition(actualLongitudinalPose, actualTransversalPose, actualAngle);
    
    // print the actual cartesian velocity
    LOG(info) << "actual velocity longitudinal: " << actualLongitudinalVelocity << " transversal: " << actualTransversalVelocity << " angular: " << actualAngularVelocity;
    
    //command base joint 1 a velocity of 2 radian per second
    JointVelocitySetpoint setVel;
    setVel.angularVelocity = 2 *radian_per_second;
    myYouBotBase.getBaseJoint(1).setData(setVel);
    setVel.angularVelocity = 0 *radian_per_second;
    myYouBotBase.getBaseJoint(1).setData(setVel);
    
    
    

    // creates a YouBotManipulator instance with the name "youbot-manipulator" which is also the name of the config file
    YouBotManipulator myYouBotManipulator("youbot-manipulator");

                // do the sine commutation of the arm joints
                myYouBotManipulator.doJointCommutation();

                // calibrate the reference position of the arm joints
    myYouBotManipulator.calibrateManipulator();

    //receive motor current form joint 1 of the manipulator
    JointSensedCurrent current;
    myYouBotManipulator.getArmJoint(1).getData(current);
    std::cout << "Current manipulator joint 1: " << current.current << std::endl;

    //read the maximum positioning velocity parameter from the manipulator joint 1
    MaximumPositioningVelocity maxPositioningVelocity;
    myYouBotManipulator.getArmJoint(1).getConfigurationParameter(maxPositioningVelocity);
    quantity<angular_velocity> velocity;
    maxPositioningVelocity.getParameter(velocity);
    std::cout << "Maximum positioning speed of joint 1: " << velocity << std::endl;

    //configure 2 radian_per_second as the maximum positioning velocity of the manipulator joint 1
    maxPositioningVelocity.setParameter(2 * radian_per_second);
    myYouBotManipulator.getArmJoint(1).setConfigurationParameter(maxPositioningVelocity);
    
    
    
    
    // calibrate the reference position of the gripper
    myYouBotManipulator.calibrateGripper();
    
    // open the gripper 2 cm
    GripperBarSpacingSetPoint gripperSetPoint;
    gripperSetPoint.barSpacing = 0.02 * meter;
    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.



youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:03