minimal_example.cpp
Go to the documentation of this file.
00001 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00002 // This file is part of the SCHUNK Canopen Driver suite.
00003 //
00004 // This program is free software licensed under the LGPL
00005 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00006 // You can find a copy of this license in LICENSE folder in the top
00007 // directory of the source code.
00008 //
00009 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany
00010 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00011 // -- END LICENSE BLOCK ------------------------------------------------
00012 
00013 #include <icl_hardware_canopen/CanOpenController.h>
00014 #include <icl_hardware_canopen/DS402Group.h>
00015 #include <icl_hardware_canopen/Logging.h>
00016 #include <icl_hardware_canopen/ds402.h>
00017 #include <icl_hardware_canopen/SchunkPowerBallNode.h>
00018 
00019 using namespace icl_hardware::canopen_schunk;
00020 
00021 
00022 int main (int argc, char* argv[])
00023 {
00024   // Initializing
00025   icl_core::logging::initialize(argc, argv);
00026 
00027   CanOpenController my_controller("auto");
00028 
00029   DS402Group::Ptr arm_group = my_controller.getGroup<DS402Group>();
00030   my_controller.addNode<SchunkPowerBallNode>(3);
00031   my_controller.addNode<SchunkPowerBallNode>(4);
00032   my_controller.addNode<SchunkPowerBallNode>(5);
00033   my_controller.addNode<SchunkPowerBallNode>(6);
00034   my_controller.addNode<SchunkPowerBallNode>(7);
00035   my_controller.addNode<SchunkPowerBallNode>(8);
00036 
00037 
00038   arm_group->initNodes();
00039   uint8_t nr = 8;
00040   SchunkPowerBallNode::Ptr node = my_controller.getNode<SchunkPowerBallNode>(nr);
00041 
00042   ds402::ProfilePositionModeConfiguration config;
00043   config.profile_acceleration = 0.2;
00044   config.profile_velocity = 0.2;
00045   config.use_relative_targets = false;
00046   config.change_set_immediately = true;
00047   config.use_blending = true;
00048 
00049   arm_group->setupProfilePositionMode(config);
00050 
00051   std::vector<float> targets (6, 0.0);
00052 
00053 
00054   arm_group->enableNodes();
00055   sleep(1);
00056   arm_group->setTarget(targets);
00057   sleep(1);
00058 //   node->setTarget(0.3-targets[0]);
00059 
00060   std::vector<bool> foo;
00061 
00062   while (true)
00063   {
00064     try {
00065       my_controller.syncAll();
00066     }
00067     catch (const std::exception& e)
00068     {
00069       LOGGING_ERROR (CanOpen, e.what() << endl);
00070       return  -1;
00071     }
00072     usleep(10000);
00073 
00074 //     arm_group->printStatus(8);
00075 
00076     if (arm_group->isTargetReached(foo))
00077     {
00078       LOGGING_INFO (CanOpen, "All targets reached" << endl;);
00079       break;
00080     }
00081   }
00082 
00083   arm_group->disableNodes();
00084 
00085   return 0;
00086 }


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Thu Jun 6 2019 20:17:24