├── README.md ├── lbr_fri ├── srv │ └── SetStiffness.srv ├── launch │ ├── fri_node.launch │ └── fri_launch.launch ├── include │ ├── Server.h │ └── iiwa_fri_client.h ├── package.xml ├── src │ ├── iiwa_node.cpp │ ├── iiwa_fri_client.cpp │ ├── iiwa_hw_interface.cpp │ └── Server.cpp └── CMakeLists.txt ├── lbr_iiwa_description ├── meshes │ ├── link_0.stl │ ├── link_1.stl │ ├── link_2.stl │ ├── link_3.stl │ ├── link_4.stl │ ├── link_5.stl │ ├── link_6.stl │ ├── link_7.stl │ └── coarse │ │ ├── link_0.stl │ │ ├── link_1.stl │ │ ├── link_2.stl │ │ ├── link_3.stl │ │ ├── link_4.stl │ │ ├── link_5.stl │ │ ├── link_6.stl │ │ └── link_7.stl ├── gazebo │ └── gazebo.urdf.xacro ├── package.xml ├── launch │ ├── lbr_iiwa_online.launch │ ├── lbr_iiwa_rviz.launch │ └── lbr_iiwa.rviz ├── urdf │ ├── lbr_iiwa.urdf.xacro │ ├── materials.xacro │ ├── utilities.xacro │ ├── lbr_iiwa.gazebo.xacro │ ├── lbr_iiwa.transmission.xacro │ └── lbr_iiwa.xacro └── CMakeLists.txt ├── lbr_iiwa_control ├── package.xml ├── launch │ ├── lbr_iiwa_control.launch │ ├── lbr_iiwa_forward_pos_control.perspective │ ├── lbr_iiwa_forward_vel_control.perspective │ └── lbr_iiwa_effort_pos_control.perspective ├── config │ └── lbr_iiwa_control.yaml └── CMakeLists.txt ├── lbr_iiwa_gazebo ├── package.xml ├── worlds │ └── lbr_iiwa.world ├── launch │ └── lbr_iiwa_world.launch └── CMakeLists.txt ├── lbr_iiwa_launch ├── package.xml ├── launch │ ├── lbr_iiwa_gazebo_effort_pos_control.launch │ ├── lbr_iiwa_gazebo_forward_pos_control.launch │ └── lbr_iiwa_gazebo_forward_vel_control.launch └── CMakeLists.txt ├── .gitignore ├── license.dat └── lbr_iiwa_java ├── JointTargetsListner.java ├── SmartServoControl.java └── Client.java /README.md: -------------------------------------------------------------------------------- 1 | Urdf & Gazebo files for a KUKA LBR iiwa R820 with electrical media flange 2 | -------------------------------------------------------------------------------- /lbr_fri/srv/SetStiffness.srv: -------------------------------------------------------------------------------- 1 | float64 sx 2 | float64 sy 3 | float64 sz 4 | float64 sa 5 | float64 sb 6 | float64 sc 7 | --- 8 | -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_0.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_0.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_1.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_2.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_3.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_4.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_4.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_5.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_5.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_6.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_6.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/link_7.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/link_7.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_0.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_0.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_1.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_2.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_3.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_4.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_4.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_5.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_5.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_6.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_6.stl -------------------------------------------------------------------------------- /lbr_iiwa_description/meshes/coarse/link_7.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rtkg/lbr_iiwa/HEAD/lbr_iiwa_description/meshes/coarse/link_7.stl -------------------------------------------------------------------------------- /lbr_fri/launch/fri_node.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lbr_fri/launch/fri_launch.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lbr_iiwa_description/gazebo/gazebo.urdf.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /lbr_iiwa 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lbr_iiwa_description/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | lbr_iiwa_description 4 | 0.0.0 5 | The rrbot_description package 6 | 7 | Robert Krug 8 | 9 | BSD 10 | 11 | Robert Krug 12 | 13 | catkin 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /lbr_iiwa_control/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | lbr_iiwa_control 4 | 0.0.0 5 | The lbr_iiwa_control package 6 | 7 | Robert Krug 8 | 9 | BSD 10 | 11 | Robert Krug 12 | 13 | catkin 14 | 15 | controller_manager 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lbr_iiwa_gazebo/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | lbr_iiwa_gazebo 4 | 0.0.0 5 | The lbr_iiwa_gazebo package 6 | 7 | Robert Krug 8 | 9 | Robert Krug 10 | 11 | BSD 12 | 13 | 14 | catkin 15 | 16 | lbr_iiwa_description 17 | gazebo_ros 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lbr_iiwa_launch/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | lbr_iiwa_launch 4 | 0.0.0 5 | The lbr_iiwa_control package 6 | 7 | Robert Krug 8 | 9 | BSD 10 | 11 | Robert Krug 12 | 13 | catkin 14 | 15 | lbr_iiwa_gazebo 16 | lbr_iiwa_control 17 | controller_manager 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lbr_iiwa_gazebo/worlds/lbr_iiwa.world: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | model://ground_plane 8 | 9 | 10 | 11 | 12 | model://sun 13 | 14 | 15 | 16 | 17 | 18 | 4.927360 -4.376610 3.740080 0.000000 0.275643 2.356190 19 | orbit 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lbr_iiwa_description/launch/lbr_iiwa_online.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/lbr_iiwa.urdf.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/materials.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /lbr_iiwa_description/launch/lbr_iiwa_rviz.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Lines that start with '#' are comments. 2 | 3 | # Backup and data files 4 | eg/eg.* 5 | *~ 6 | *.bak 7 | *.off 8 | *.x 9 | x.* 10 | r 11 | x 12 | x? 13 | r? 14 | 15 | #Misc 16 | 17 | lbr_fri/fri 18 | 19 | # patch results 20 | *.rej 21 | 22 | # Build products 23 | tmp/* 24 | build/Makefile* 25 | build/CMakeFiles 26 | build/CMakeCache.txt 27 | build/*/Makefile* 28 | build/*/object_script* 29 | build/*/Release/* 30 | build/*/Debug/* 31 | build/*/MinSizeRel/* 32 | build/*/RelWithDebInfo/* 33 | build 34 | 35 | *# 36 | *.# 37 | *.obj 38 | *.urdf 39 | *.dae 40 | .stl 41 | *.zip 42 | *.a 43 | *.dll 44 | *.lib 45 | *.exe 46 | *.bag 47 | *.o 48 | *.md5sum 49 | 50 | # Qt files 51 | *.pro.user 52 | 53 | # DevStudio files 54 | *.bsc 55 | *.ncb 56 | *.pdb 57 | *.suo 58 | *.user 59 | *.ilk 60 | 61 | # CVS files 62 | CVS/* 63 | */CVS/* 64 | */*/CVS/* 65 | */*/*/CVS/* 66 | *.cvsignore 67 | 68 | # Other files 69 | working/ 70 | Status API Training Shop Blog About 71 | © 2014 GitHub, Inc. Terms Privacy Security Contact 72 | 73 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/utilities.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lbr_iiwa_launch/launch/lbr_iiwa_gazebo_effort_pos_control.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /lbr_iiwa_launch/launch/lbr_iiwa_gazebo_forward_pos_control.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /lbr_iiwa_launch/launch/lbr_iiwa_gazebo_forward_vel_control.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /license.dat: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Robert Krug & Todor Stoyanov, AASS Research Center, Orebro University, Sweden 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /lbr_iiwa_gazebo/launch/lbr_iiwa_world.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /lbr_iiwa_control/launch/lbr_iiwa_control.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/lbr_iiwa.gazebo.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Gazebo/Grey 10 | 0.2 11 | 0.2 12 | 13 | 14 | 15 | 16 | Gazebo/Orange 17 | 0.2 18 | 0.2 19 | 20 | 21 | 22 | 23 | Gazebo/Orange 24 | 0.2 25 | 0.2 26 | 27 | 28 | 29 | 30 | Gazebo/Orange 31 | 0.2 32 | 0.2 33 | 34 | 35 | 36 | 37 | 38 | Gazebo/Orange 39 | 0.2 40 | 0.2 41 | 42 | 43 | 44 | 45 | Gazebo/Orange 46 | 0.2 47 | 0.2 48 | 49 | 50 | 51 | 52 | Gazebo/Orange 53 | 0.2 54 | 0.2 55 | 56 | 57 | 58 | 59 | Gazebo/Grey 60 | 0.2 61 | 0.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /lbr_fri/include/Server.h: -------------------------------------------------------------------------------- 1 | // A C++ socket server class 2 | // 3 | // Keith Vertanen 11/98, updated 12/08 4 | 5 | #ifndef _SERVER_H__ 6 | #define _SERVER_H__ 7 | 8 | static const int SERVER_BUFF_SIZE = 64000; 9 | 10 | // Adds in the send/recv acks after each message. 11 | #define DEBUG_ACK 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #ifdef _WIN32 19 | #include 20 | #else 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // Duplicated from winsock2.h 29 | #define SD_RECEIVE 0x00 30 | #define SD_SEND 0x01 31 | #define SD_BOTH 0x02 32 | 33 | #endif 34 | 35 | class Server 36 | { 37 | public: 38 | Server(int iPort, int iPortDatagram, bool* pResult); 39 | ~Server(); 40 | 41 | bool Connect(); // Accept a new connection 42 | bool Close(); // Close the socket 43 | 44 | bool SendString(char* pStr); // Send a string to socket 45 | bool SendInts(int* pVals, int iLen); // Send some integers 46 | bool SendBytes(char* pVals, int iLen); // Send some bytes 47 | bool SendFloats(float* pVals, int iLen); // Send some floats 48 | bool SendDoubles(double* pVals, int iLen); // Send some doubles 49 | 50 | int RecvString(char* pStr, int iMax, char chTerm); // Receive a string 51 | int RecvInts(int* pVals, int iLen); // Receive some ints 52 | int RecvFloats(float* pVals, int iLen); // Receive some floats 53 | int RecvDoubles(double* pVals, int iLen); // Receive some doubles 54 | int RecvBytes(char* pVals, int iLen); // Receive some bytes 55 | 56 | // NOTE: these are not currently implemented! 57 | bool SendDatagram(char* pVals, int iLen); // Send a datagram 58 | int RecvDatagram(char* pVals, int iLen); // Receive a datagram 59 | 60 | protected: 61 | bool m_bReverse; // Am I reversing byte order or not? 62 | int m_iPort; // The port I'm listening on 63 | int m_iPortDatagram; // Port I listen for datagrams on (can be same or different from port) 64 | int m_iListen; // Descriptor we are listening on 65 | int m_iSock; // Descriptor for the socket 66 | struct sockaddr_in m_addrRemote; // Connector's address information 67 | struct sockaddr_in m_addrMe; // My address information 68 | double* m_pBuffer; // Reuse the same memory for buffer 69 | double* m_pBuffer2; 70 | 71 | private: 72 | bool RecvAck(); 73 | bool SendAck(); 74 | 75 | }; 76 | 77 | #endif 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /lbr_fri/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | lbr_fri 4 | 0.0.0 5 | The lbr_fri package 6 | 7 | 8 | 9 | 10 | tsv 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | catkin 43 | 44 | sensor_msgs 45 | std_srvs 46 | roscpp 47 | hardware_interface 48 | controller_manager 49 | velvet_msgs 50 | message_generation 51 | 52 | 53 | sensor_msgs 54 | roscpp 55 | message_runtime 56 | hardware_interface 57 | controller_manager 58 | std_srvs 59 | velvet_msgs 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/lbr_iiwa.transmission.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | transmission_interface/SimpleTransmission 8 | 9 | ${hardware_interface} 10 | 11 | 12 | ${hardware_interface} 13 | 1 14 | 15 | 16 | 17 | 18 | transmission_interface/SimpleTransmission 19 | 20 | ${hardware_interface} 21 | 22 | 23 | ${hardware_interface} 24 | 1 25 | 26 | 27 | 28 | 29 | transmission_interface/SimpleTransmission 30 | 31 | ${hardware_interface} 32 | 33 | 34 | ${hardware_interface} 35 | 1 36 | 37 | 38 | 39 | 40 | transmission_interface/SimpleTransmission 41 | 42 | ${hardware_interface} 43 | 44 | 45 | ${hardware_interface} 46 | 1 47 | 48 | 49 | 50 | 51 | transmission_interface/SimpleTransmission 52 | 53 | ${hardware_interface} 54 | 55 | 56 | ${hardware_interface} 57 | 1 58 | 59 | 60 | 61 | 62 | transmission_interface/SimpleTransmission 63 | 64 | ${hardware_interface} 65 | 66 | 67 | ${hardware_interface} 68 | 1 69 | 70 | 71 | 72 | 73 | transmission_interface/SimpleTransmission 74 | 75 | ${hardware_interface} 76 | 77 | 78 | ${hardware_interface} 79 | 1 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /lbr_fri/src/iiwa_node.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // strstr 4 | #include "iiwa_fri_client.h" 5 | #include "friUdpConnection.h" 6 | #include "friClientApplication.h" 7 | #include 8 | 9 | #include 10 | #include "sensor_msgs/JointState.h" 11 | #include 12 | #include 13 | 14 | #define DEFAULT_PORTID 30200 15 | #define DEFAULT_JAVA_PORTID 5010 16 | 17 | using namespace KUKA::FRI; 18 | 19 | 20 | class IIWANode { 21 | 22 | protected: 23 | // Our NodeHandle 24 | ros::NodeHandle nh_; 25 | ros::NodeHandle n_; 26 | ros::Timer heartbeat_; 27 | 28 | ros::Publisher joints_pub_; 29 | ros::ServiceServer test_streamer; 30 | 31 | //boost::mutex m, message_m; 32 | //ros::ServiceServer save_map_; 33 | std::string hostname; 34 | int port, port_java; 35 | int publish_ctr; 36 | double loop_rate; 37 | int n_publish_skip; 38 | 39 | IIWAFRIClient client; 40 | UdpConnection connection; 41 | ClientApplication app; 42 | Server *target_streamer; 43 | bool connected; 44 | bool run_streamer; 45 | 46 | public: 47 | // Constructor 48 | IIWANode(ros::NodeHandle param_nh): client(),connection(),app(connection,client) 49 | { 50 | n_ = ros::NodeHandle(""); 51 | param_nh.param("hostname",hostname,"192.170.10.2"); 52 | param_nh.param("port",port,DEFAULT_PORTID); 53 | param_nh.param("port_java",port_java,DEFAULT_JAVA_PORTID); 54 | param_nh.param("loop_rate",loop_rate,0.001); 55 | param_nh.param("run_streamer",run_streamer,false); 56 | 57 | app.connect(port, hostname.c_str()); 58 | joints_pub_=n_.advertise("/joint_states",1000); 59 | 60 | heartbeat_ = nh_.createTimer(ros::Duration(loop_rate),&IIWANode::do_step,this); 61 | publish_ctr = 0; 62 | n_publish_skip = 5; 63 | connected = false; 64 | 65 | if(run_streamer) { 66 | int dataport = -1; 67 | target_streamer = new Server(port_java,dataport,&connected); 68 | if(connected) { 69 | //wait for incoming connecction 70 | target_streamer->Connect(); 71 | test_streamer = param_nh.advertiseService("test_streamer", &IIWANode::test_streamer_callback, this);; 72 | } 73 | } 74 | } 75 | 76 | ~IIWANode() 77 | { 78 | app.disconnect(); 79 | if(target_streamer != NULL) delete target_streamer; 80 | } 81 | 82 | void do_step(const ros::TimerEvent& event) { 83 | bool success = app.step(); 84 | publish_ctr++; 85 | if(publish_ctr > n_publish_skip) { 86 | publish_ctr = 0; 87 | sensor_msgs::JointState js; 88 | client.getJointMsg(js); 89 | js.header.stamp = ros::Time::now(); 90 | joints_pub_.publish(js); 91 | } 92 | } 93 | 94 | bool test_streamer_callback(std_srvs::Empty::Request &req, 95 | std_srvs::Empty::Response &res ) { 96 | 97 | if(run_streamer && connected) { 98 | double *jv = new double[7]; 99 | for(int i=0; i<7; ++i) jv[i] = 0; 100 | 101 | target_streamer->SendDoubles(jv, 7); 102 | 103 | delete []jv; 104 | } 105 | return true; 106 | } 107 | 108 | 109 | }; 110 | 111 | int main(int argc, char **argv) 112 | { 113 | ros::init(argc, argv, "iiwa_node"); 114 | 115 | ros::NodeHandle param("~"); 116 | IIWANode nd(param); 117 | 118 | ros::AsyncSpinner spinner(4); // Use 4 threads 119 | spinner.start(); 120 | ros::waitForShutdown(); 121 | 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /lbr_iiwa_java/JointTargetsListner.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.io.IOException; 4 | import java.util.concurrent.Semaphore; 5 | import java.util.concurrent.locks.Condition; 6 | import java.util.concurrent.locks.Lock; 7 | import java.util.concurrent.locks.ReentrantLock; 8 | 9 | import sun.awt.Mutex; 10 | 11 | import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication; 12 | import com.kuka.roboticsAPI.controllerModel.Controller; 13 | import com.kuka.roboticsAPI.deviceModel.JointPosition; 14 | import com.kuka.roboticsAPI.deviceModel.LBR; 15 | 16 | public class JointTargetsListner extends Thread { 17 | private String hostname; 18 | int SIZE = 7; 19 | private Client mylink_send, mylink_recv; 20 | private boolean quit; 21 | private JointPosition jp; 22 | private double joint_targets[], joint_states[]; 23 | private static final Lock lockObj = new ReentrantLock(); 24 | private static final Condition cond = lockObj.newCondition(); 25 | //private final Semaphore sem; 26 | 27 | public JointPosition getJP(JointPosition js) {// throws InterruptedException { 28 | lockObj.lock(); 29 | JointPosition jp = new JointPosition(joint_targets); 30 | for(int j=0; j 50 | Value: true 51 | - Alpha: 1 52 | Class: rviz/RobotModel 53 | Collision Enabled: false 54 | Enabled: true 55 | Links: 56 | All Links Enabled: true 57 | Expand Joint Details: false 58 | Expand Link Details: false 59 | Expand Tree: false 60 | Link Tree Style: Links in Alphabetic Order 61 | lbr_iiwa_link_0: 62 | Alpha: 1 63 | Show Axes: false 64 | Show Trail: false 65 | Value: true 66 | lbr_iiwa_link_1: 67 | Alpha: 1 68 | Show Axes: false 69 | Show Trail: false 70 | Value: true 71 | lbr_iiwa_link_2: 72 | Alpha: 1 73 | Show Axes: false 74 | Show Trail: false 75 | Value: true 76 | lbr_iiwa_link_3: 77 | Alpha: 1 78 | Show Axes: false 79 | Show Trail: false 80 | Value: true 81 | lbr_iiwa_link_4: 82 | Alpha: 1 83 | Show Axes: false 84 | Show Trail: false 85 | Value: true 86 | lbr_iiwa_link_5: 87 | Alpha: 1 88 | Show Axes: false 89 | Show Trail: false 90 | Value: true 91 | lbr_iiwa_link_6: 92 | Alpha: 1 93 | Show Axes: false 94 | Show Trail: false 95 | Value: true 96 | lbr_iiwa_link_7: 97 | Alpha: 1 98 | Show Axes: false 99 | Show Trail: false 100 | Value: true 101 | world: 102 | Alpha: 1 103 | Show Axes: false 104 | Show Trail: false 105 | Name: RobotModel 106 | Robot Description: robot_description 107 | TF Prefix: "" 108 | Update Interval: 0 109 | Value: true 110 | Visual Enabled: true 111 | Enabled: true 112 | Global Options: 113 | Background Color: 200; 200; 200 114 | Fixed Frame: world 115 | Frame Rate: 30 116 | Name: root 117 | Tools: 118 | - Class: rviz/Interact 119 | Hide Inactive Objects: true 120 | - Class: rviz/MoveCamera 121 | - Class: rviz/Select 122 | - Class: rviz/FocusCamera 123 | - Class: rviz/Measure 124 | - Class: rviz/SetInitialPose 125 | Topic: /initialpose 126 | - Class: rviz/SetGoal 127 | Topic: /move_base_simple/goal 128 | - Class: rviz/PublishPoint 129 | Single click: true 130 | Topic: /clicked_point 131 | Value: true 132 | Views: 133 | Current: 134 | Class: rviz/Orbit 135 | Distance: 2.07084 136 | Enable Stereo Rendering: 137 | Stereo Eye Separation: 0.06 138 | Stereo Focal Distance: 1 139 | Swap Stereo Eyes: false 140 | Value: false 141 | Focal Point: 142 | X: -0.0818598 143 | Y: -0.131827 144 | Z: 0.274699 145 | Name: Current View 146 | Near Clip Distance: 0.01 147 | Pitch: -0.0846019 148 | Target Frame: 149 | Value: Orbit (rviz) 150 | Yaw: 1.19539 151 | Saved: ~ 152 | Window Geometry: 153 | Displays: 154 | collapsed: false 155 | Height: 691 156 | Hide Left Dock: false 157 | Hide Right Dock: true 158 | QMainWindow State: 000000ff00000000fd00000004000000000000011100000210fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006400fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000004100000210000000dd00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000210fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000004100000210000000b000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000005560000003efc0100000002fb0000000800540069006d0065010000000000000556000002f600fffffffb0000000800540069006d006501000000000000045000000000000000000000043f0000021000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 159 | Selection: 160 | collapsed: false 161 | Time: 162 | collapsed: false 163 | Tool Properties: 164 | collapsed: false 165 | Views: 166 | collapsed: true 167 | Width: 1366 168 | X: -7 169 | Y: 24 170 | -------------------------------------------------------------------------------- /lbr_fri/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(lbr_fri) 3 | 4 | ## Find catkin macros and libraries 5 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 6 | ## is used, also find other catkin packages 7 | find_package(catkin REQUIRED COMPONENTS sensor_msgs roscpp hardware_interface controller_manager std_srvs message_generation) 8 | 9 | ## System dependencies are found with CMake's conventions 10 | find_package(Boost REQUIRED COMPONENTS thread) 11 | 12 | 13 | ## Uncomment this if the package has a setup.py. This macro ensures 14 | ## modules and global scripts declared therein get installed 15 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 16 | # catkin_python_setup() 17 | 18 | ################################################ 19 | ## Declare ROS messages, services and actions ## 20 | ################################################ 21 | 22 | ## To declare and build messages, services or actions from within this 23 | ## package, follow these steps: 24 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 25 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 26 | ## * In the file package.xml: 27 | ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET 28 | ## * If MSG_DEP_SET isn't empty the following dependencies might have been 29 | ## pulled in transitively but can be declared for certainty nonetheless: 30 | ## * add a build_depend tag for "message_generation" 31 | ## * add a run_depend tag for "message_runtime" 32 | ## * In this file (CMakeLists.txt): 33 | ## * add "message_generation" and every package in MSG_DEP_SET to 34 | ## find_package(catkin REQUIRED COMPONENTS ...) 35 | ## * add "message_runtime" and every package in MSG_DEP_SET to 36 | ## catkin_package(CATKIN_DEPENDS ...) 37 | ## * uncomment the add_*_files sections below as needed 38 | ## and list every .msg/.srv/.action file to be processed 39 | ## * uncomment the generate_messages entry below 40 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 41 | 42 | ## Generate messages in the 'msg' folder 43 | # add_message_files( 44 | # FILES 45 | # Message1.msg 46 | # Message2.msg 47 | # ) 48 | 49 | ## Generate services in the 'srv' folder 50 | add_service_files( 51 | FILES 52 | SetStiffness.srv 53 | ) 54 | 55 | ## Generate actions in the 'action' folder 56 | # add_action_files( 57 | # FILES 58 | # Action1.action 59 | # Action2.action 60 | # ) 61 | 62 | ## Generate added messages and services with any dependencies listed here 63 | generate_messages( 64 | DEPENDENCIES 65 | std_msgs # Or other packages containing msgs 66 | ) 67 | 68 | ################################### 69 | ## catkin specific configuration ## 70 | ################################### 71 | ## The catkin_package macro generates cmake config files for your package 72 | ## Declare things to be passed to dependent projects 73 | ## INCLUDE_DIRS: uncomment this if you package contains header files 74 | ## LIBRARIES: libraries you create in this project that dependent projects also need 75 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 76 | ## DEPENDS: system dependencies of this project that dependent projects also need 77 | catkin_package( 78 | INCLUDE_DIRS include fri/include 79 | # LIBRARIES lbr_fri 80 | CATKIN_DEPENDS sensor_msgs message_runtime roscpp hardware_interface controller_manager std_srvs 81 | # DEPENDS system_lib 82 | ) 83 | 84 | ########### 85 | ## Build ## 86 | ########### 87 | 88 | ## Specify additional locations of header files 89 | ## Your package locations should be listed before other locations 90 | include_directories(include fri/include) 91 | include_directories(${catkin_INCLUDE_DIRS}) 92 | 93 | ## Declare a cpp library 94 | # add_library(lbr_fri 95 | # src/${PROJECT_NAME}/lbr_fri.cpp 96 | # ) 97 | 98 | ## Declare a cpp executable 99 | link_directories(fri/lib) 100 | 101 | add_executable(iiwa_node src/Server.cpp src/iiwa_node.cpp src/iiwa_fri_client.cpp) 102 | ## Add cmake target dependencies of the executable/library 103 | ## as an example, message headers may need to be generated before nodes 104 | # add_dependencies(lbr_fri_node lbr_fri_generate_messages_cpp) 105 | 106 | ## Specify libraries to link a library or executable target against 107 | target_link_libraries(iiwa_node 108 | ${catkin_LIBRARIES} ${Boost_LIBRARIES} FRIClient 109 | ) 110 | 111 | add_executable(iiwa_hw_interface src/Server.cpp src/iiwa_hw_interface.cpp src/iiwa_fri_client.cpp) 112 | ## Add cmake target dependencies of the executable/library 113 | ## as an example, message headers may need to be generated before nodes 114 | # add_dependencies(lbr_fri_node lbr_fri_generate_messages_cpp) 115 | 116 | ## Specify libraries to link a library or executable target against 117 | target_link_libraries(iiwa_hw_interface 118 | ${catkin_LIBRARIES} ${Boost_LIBRARIES} FRIClient 119 | ) 120 | ############# 121 | ## Install ## 122 | ############# 123 | 124 | # all install targets should use catkin DESTINATION variables 125 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 126 | 127 | ## Mark executable scripts (Python etc.) for installation 128 | ## in contrast to setup.py, you can choose the destination 129 | # install(PROGRAMS 130 | # scripts/my_python_script 131 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 132 | # ) 133 | 134 | ## Mark executables and/or libraries for installation 135 | # install(TARGETS lbr_fri lbr_fri_node 136 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 137 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 138 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 139 | # ) 140 | 141 | ## Mark cpp header files for installation 142 | # install(DIRECTORY include/${PROJECT_NAME}/ 143 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 144 | # FILES_MATCHING PATTERN "*.h" 145 | # PATTERN ".svn" EXCLUDE 146 | # ) 147 | 148 | ## Mark other files for installation (e.g. launch and bag files, etc.) 149 | # install(FILES 150 | # # myfile1 151 | # # myfile2 152 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 153 | # ) 154 | 155 | ############# 156 | ## Testing ## 157 | ############# 158 | 159 | ## Add gtest based cpp test target and link libraries 160 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_lbr_fri.cpp) 161 | # if(TARGET ${PROJECT_NAME}-test) 162 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 163 | # endif() 164 | 165 | ## Add folders to be run by python nosetests 166 | # catkin_add_nosetests(test) 167 | -------------------------------------------------------------------------------- /lbr_iiwa_control/launch/lbr_iiwa_forward_pos_control.perspective: -------------------------------------------------------------------------------- 1 | { 2 | "keys": {}, 3 | "groups": { 4 | "pluginmanager": { 5 | "keys": { 6 | "running-plugins": { 7 | "type": "repr", 8 | "repr": "{u'rqt_plot/Plot': [1], u'rqt_publisher/Publisher': [1]}" 9 | } 10 | }, 11 | "groups": { 12 | "plugin__rqt_plot__Plot__1": { 13 | "keys": {}, 14 | "groups": { 15 | "dock_widget__DataPlotWidget": { 16 | "keys": { 17 | "dockable": { 18 | "type": "repr", 19 | "repr": "True" 20 | }, 21 | "parent": { 22 | "type": "repr", 23 | "repr": "None" 24 | } 25 | }, 26 | "groups": {} 27 | }, 28 | "plugin": { 29 | "keys": { 30 | "autoscroll": { 31 | "type": "repr", 32 | "repr": "True" 33 | }, 34 | "plot_type": { 35 | "type": "repr", 36 | "repr": "1" 37 | }, 38 | "topics": { 39 | "type": "repr", 40 | "repr": "[u'/lbr_iiwa/lbr_iiwa_joint_2_forward_pos_controller/command/data', u'/lbr_iiwa/joint_states/position[1]']" 41 | } 42 | }, 43 | "groups": {} 44 | } 45 | } 46 | }, 47 | "plugin__rqt_publisher__Publisher__1": { 48 | "keys": {}, 49 | "groups": { 50 | "dock_widget__PublisherWidget": { 51 | "keys": { 52 | "dockable": { 53 | "type": "repr", 54 | "repr": "True" 55 | }, 56 | "parent": { 57 | "type": "repr", 58 | "repr": "None" 59 | } 60 | }, 61 | "groups": {} 62 | }, 63 | "plugin": { 64 | "keys": { 65 | "publishers": { 66 | "type": "repr", 67 | "repr": "u\"[{'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_1_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 5, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_2_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 6, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_3_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 7, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_4_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 8, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_5_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 9, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_6_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 10, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_7_forward_pos_controller/command', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 11, 'counter': 0}]\"" 68 | } 69 | }, 70 | "groups": {} 71 | } 72 | } 73 | } 74 | } 75 | }, 76 | "mainwindow": { 77 | "keys": { 78 | "geometry": { 79 | "type": "repr(QByteArray.hex)", 80 | "repr(QByteArray.hex)": "QtCore.QByteArray('01d9d0cb00010000000000e7000000d10000078e000002ec000000f1000000f700000784000002e2000000000000')", 81 | "pretty-print": " " 82 | }, 83 | "state": { 84 | "type": "repr(QByteArray.hex)", 85 | "repr(QByteArray.hex)": "QtCore.QByteArray('000000ff00000000fd000000010000000300000694000001bdfc0100000006fb00000062007200710074005f0063006f006e00740072006f006c006c00650072005f006d0061006e0061006700650072005f005f0043006f006e00740072006f006c006c00650072004d0061006e0061006700650072004700550049005f005f0031005f005f0100000000000002580000000000000000fb00000058007200710074005f007000750062006c00690073006800650072005f005f005000750062006c00690073006800650072005f005f0031005f005f005000750062006c006900730068006500720057006900640067006500740100000000000003470000026600fffffffc0000034d000003470000017700fffffffa000000010200000002fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0031005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f0077006900640067006500740200000068000000180000028b00000214fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0031005f005f00440061007400610050006c006f00740057006900640067006500740100000019000003d30000008c00fffffffb00000062007200710074005f0072006f0062006f0074005f006d006f006e00690074006f0072005f005f0052006f0062006f0074004d006f006e00690074006f0072005f005f0031005f005f0052006f0062006f00740020004d006f006e00690074006f007201000004f2000000dc0000000000000000fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0032005f005f00440061007400610050006c006f0074005700690064006700650074030000041f0000006b0000026e00000178fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0032005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f007700690064006700650074030000004100000048000001f9000001dd000006940000000000000004000000040000000800000008fc00000001000000030000000100000036004d0069006e0069006d0069007a006500640044006f0063006b00570069006400670065007400730054006f006f006c0062006100720000000000ffffffff0000000000000000')", 86 | "pretty-print": " brqt_controller_manager__ControllerManagerGUI__1__ Xrqt_publisher__Publisher__1__PublisherWidget M G w h k n x A H " 87 | } 88 | }, 89 | "groups": { 90 | "toolbar_areas": { 91 | "keys": { 92 | "MinimizedDockWidgetsToolbar": { 93 | "type": "repr", 94 | "repr": "8" 95 | } 96 | }, 97 | "groups": {} 98 | } 99 | } 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /lbr_iiwa_control/launch/lbr_iiwa_forward_vel_control.perspective: -------------------------------------------------------------------------------- 1 | { 2 | "keys": {}, 3 | "groups": { 4 | "pluginmanager": { 5 | "keys": { 6 | "running-plugins": { 7 | "type": "repr", 8 | "repr": "{u'rqt_plot/Plot': [1], u'rqt_publisher/Publisher': [1]}" 9 | } 10 | }, 11 | "groups": { 12 | "plugin__rqt_plot__Plot__1": { 13 | "keys": {}, 14 | "groups": { 15 | "dock_widget__DataPlotWidget": { 16 | "keys": { 17 | "dockable": { 18 | "type": "repr", 19 | "repr": "True" 20 | }, 21 | "parent": { 22 | "type": "repr", 23 | "repr": "None" 24 | } 25 | }, 26 | "groups": {} 27 | }, 28 | "plugin": { 29 | "keys": { 30 | "autoscroll": { 31 | "type": "repr", 32 | "repr": "True" 33 | }, 34 | "plot_type": { 35 | "type": "repr", 36 | "repr": "1" 37 | }, 38 | "topics": { 39 | "type": "repr", 40 | "repr": "[u'/lbr_iiwa/joint_states/velocity[1]', u'/lbr_iiwa/lbr_iiwa_joint_2_forward_vel_controller/command/data']" 41 | } 42 | }, 43 | "groups": {} 44 | } 45 | } 46 | }, 47 | "plugin__rqt_publisher__Publisher__1": { 48 | "keys": {}, 49 | "groups": { 50 | "dock_widget__PublisherWidget": { 51 | "keys": { 52 | "dockable": { 53 | "type": "repr", 54 | "repr": "True" 55 | }, 56 | "parent": { 57 | "type": "repr", 58 | "repr": "None" 59 | } 60 | }, 61 | "groups": {} 62 | }, 63 | "plugin": { 64 | "keys": { 65 | "publishers": { 66 | "type": "repr", 67 | "repr": "u\"[{'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_1_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 0, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_2_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {u'/lbr_iiwa/lbr_iiwa_joint_2_forward_vel_controller/command/data': '-0.01'}, 'publisher_id': 1, 'counter': 76}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_3_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 2, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_4_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 3, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_5_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 4, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_6_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 5, 'counter': 0}, {'type_name': 'std_msgs/Float64', 'topic_name': '/lbr_iiwa/lbr_iiwa_joint_7_forward_vel_controller/command', 'enabled': False, 'rate': 1.0, 'expressions': {}, 'publisher_id': 6, 'counter': 0}]\"" 68 | } 69 | }, 70 | "groups": {} 71 | } 72 | } 73 | } 74 | } 75 | }, 76 | "mainwindow": { 77 | "keys": { 78 | "geometry": { 79 | "type": "repr(QByteArray.hex)", 80 | "repr(QByteArray.hex)": "QtCore.QByteArray('01d9d0cb0001000000000033000000c800000695000002e30000003d000000ee0000068b000002d9000000000000')", 81 | "pretty-print": " 3 = " 82 | }, 83 | "state": { 84 | "type": "repr(QByteArray.hex)", 85 | "repr(QByteArray.hex)": "QtCore.QByteArray('000000ff00000000fd00000001000000030000064f000001bdfc0100000006fb00000062007200710074005f0063006f006e00740072006f006c006c00650072005f006d0061006e0061006700650072005f005f0043006f006e00740072006f006c006c00650072004d0061006e0061006700650072004700550049005f005f0031005f005f0100000000000002580000000000000000fb00000058007200710074005f007000750062006c00690073006800650072005f005f005000750062006c00690073006800650072005f005f0031005f005f005000750062006c006900730068006500720057006900640067006500740100000000000003250000026600fffffffc0000032b000003240000017700fffffffa000000010200000002fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0031005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f0077006900640067006500740200000068000000180000028b00000214fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0031005f005f00440061007400610050006c006f00740057006900640067006500740100000019000003d30000008c00fffffffb00000062007200710074005f0072006f0062006f0074005f006d006f006e00690074006f0072005f005f0052006f0062006f0074004d006f006e00690074006f0072005f005f0031005f005f0052006f0062006f00740020004d006f006e00690074006f007201000004f2000000dc0000000000000000fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0032005f005f00440061007400610050006c006f0074005700690064006700650074030000041f0000006b0000026e00000178fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0032005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f007700690064006700650074030000004100000048000001f9000001dd0000064f0000000000000004000000040000000800000008fc00000001000000030000000100000036004d0069006e0069006d0069007a006500640044006f0063006b00570069006400670065007400730054006f006f006c0062006100720000000000ffffffff0000000000000000')", 86 | "pretty-print": " brqt_controller_manager__ControllerManagerGUI__1__ Xrqt_publisher__Publisher__1__PublisherWidget + $ w h k n x A H O " 87 | } 88 | }, 89 | "groups": { 90 | "toolbar_areas": { 91 | "keys": { 92 | "MinimizedDockWidgetsToolbar": { 93 | "type": "repr", 94 | "repr": "8" 95 | } 96 | }, 97 | "groups": {} 98 | } 99 | } 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /lbr_fri/include/iiwa_fri_client.h: -------------------------------------------------------------------------------- 1 | #ifndef _IIWA_FRI_CLIENT_H 2 | #define _IIWA_FRI_CLIENT_H 3 | 4 | #include "friLBRClient.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace KUKA::FRI; 13 | 14 | /** 15 | * \brief Test client that can overlay interpolator joint positions with sine waves. 16 | */ 17 | class IIWAFRIClient : public LBRClient 18 | { 19 | 20 | public: 21 | 22 | IIWAFRIClient () { 23 | joint_names.push_back("lbr_iiwa_joint_1"); 24 | joint_names.push_back("lbr_iiwa_joint_2"); 25 | joint_names.push_back("lbr_iiwa_joint_3"); 26 | joint_names.push_back("lbr_iiwa_joint_4"); 27 | joint_names.push_back("lbr_iiwa_joint_5"); 28 | joint_names.push_back("lbr_iiwa_joint_6"); 29 | joint_names.push_back("lbr_iiwa_joint_7"); 30 | for(int i=0; i<7; ++i) { 31 | joint_targets[i] = 0; 32 | joint_increment[i] = 0; 33 | } 34 | //per joint 35 | max_incr[0] = 0.0058; 36 | min_incr[0] = 0.0001; 37 | max_incr[1] = 0.0058; 38 | min_incr[1] = 0.001; 39 | max_incr[2] = 0.0069; 40 | min_incr[2] = 0.0001; 41 | max_incr[3] = 0.0052; 42 | min_incr[3] = 0.0002; 43 | max_incr[4] = 0.009; 44 | min_incr[4] = 0.0001; 45 | max_incr[5] = 0.009; 46 | min_incr[5] = 0.0001; 47 | max_incr[6] = 0.009; 48 | min_incr[6] = 0.0001; 49 | }; 50 | ~IIWAFRIClient () { }; 51 | 52 | /** 53 | * \brief Callback for FRI state changes. 54 | * 55 | * @param oldState 56 | * @param newState 57 | */ 58 | virtual void onStateChange(ESessionState oldState, ESessionState newState); 59 | 60 | /** 61 | * \brief Callback for the FRI state 'Commanding Active'. 62 | */ 63 | virtual void command(); 64 | 65 | /** 66 | * \brief Callback for the FRI state 'Monitoring Active'. 67 | */ 68 | virtual void monitor(); 69 | 70 | void getJointMsg(sensor_msgs::JointState &msg); 71 | void getJointsRaw(double (&pos)[7], double (&vel)[7], double (&eff)[7]); 72 | 73 | void setJointTargets(const double (&com)[7]); 74 | 75 | ros::Time getTime(){ 76 | //ros::Time t (robotState().getTimestampSec(), robotState().getTimestampNanoSec()); 77 | //return t; 78 | return ros::Time::now(); 79 | }; 80 | ros::Duration getPeriod() { 81 | //return ros::Duration(robotState().getSampleTime()); 82 | return ros::Duration(period); 83 | } 84 | private: 85 | double joint_pos[7]; 86 | double joint_increment[7]; 87 | double joint_pos_interp[7]; 88 | double max_incr[7]; 89 | double min_incr[7]; 90 | double joint_torques[7]; 91 | double joint_targets[7]; 92 | std::vector joint_names; 93 | double period; 94 | double last_time; 95 | double getDoubleTime() 96 | { 97 | struct timeval time; 98 | gettimeofday(&time,NULL); 99 | return time.tv_sec + time.tv_usec * 1e-6; 100 | } 101 | }; 102 | 103 | class IIWAFRIClientNative 104 | { 105 | 106 | public: 107 | 108 | IIWAFRIClientNative () { 109 | joint_names.push_back("lbr_iiwa_joint_1"); 110 | joint_names.push_back("lbr_iiwa_joint_2"); 111 | joint_names.push_back("lbr_iiwa_joint_3"); 112 | joint_names.push_back("lbr_iiwa_joint_4"); 113 | joint_names.push_back("lbr_iiwa_joint_5"); 114 | joint_names.push_back("lbr_iiwa_joint_6"); 115 | joint_names.push_back("lbr_iiwa_joint_7"); 116 | for(int i=0; i<7; ++i) { 117 | joint_targets[i] = 0; 118 | joint_increment[i] = 0; 119 | } 120 | //per joint 121 | max_incr[0] = 0.0058; 122 | min_incr[0] = 0.000; 123 | max_incr[1] = 0.0058; 124 | min_incr[1] = 0.00; 125 | max_incr[2] = 0.0069; 126 | min_incr[2] = 0.000; 127 | max_incr[3] = 0.0052; 128 | min_incr[3] = 0.000; 129 | max_incr[4] = 0.009; 130 | min_incr[4] = 0.000; 131 | max_incr[5] = 0.009; 132 | min_incr[5] = 0.000; 133 | max_incr[6] = 0.009; 134 | min_incr[6] = 0.000; 135 | SIZE = 7; 136 | send_established = false; 137 | recv_established = false; 138 | last_read_time = 0; 139 | period = 0; 140 | firstRead = true; 141 | //set default values for stiffness 142 | for(int i=0; i<3; i++) { 143 | msg[i+7] = 2000; 144 | } 145 | for(int i=3; i<6; i++) { 146 | msg[i+7] = 200; 147 | } 148 | }; 149 | ~IIWAFRIClientNative () { 150 | joinThreads(); 151 | if(joints_recv != NULL) delete joints_recv; 152 | if(command_send != NULL) delete command_send; 153 | }; 154 | 155 | virtual void startThreads() { 156 | recv_quit = false; 157 | send_quit = false; 158 | doStep = false; 159 | send_thread = boost::thread(boost::bind(&IIWAFRIClientNative::commandThread,this)); 160 | recv_thread = boost::thread(boost::bind(&IIWAFRIClientNative::monitorThread,this)); 161 | } 162 | virtual void joinThreads() { 163 | js_m.lock(); 164 | recv_quit = true; 165 | js_m.unlock(); 166 | 167 | jt_m.lock(); 168 | send_quit=true; 169 | jt_m.lock(); 170 | 171 | send_thread.join(); 172 | recv_thread.join(); 173 | } 174 | 175 | //signals 176 | void step() { 177 | //wakes up everyone waiting for a socket step 178 | boost::mutex::scoped_lock lock(socket_m); 179 | doStep=true; 180 | socket_cond_.notify_all(); 181 | } 182 | 183 | bool waitForSession() { 184 | boost::mutex::scoped_lock lock(session_m); 185 | while(!(send_established && recv_established)) { 186 | session_cond_.wait(lock); 187 | } 188 | 189 | return true; 190 | } 191 | /** 192 | * thread that sends joint commands 193 | */ 194 | virtual void commandThread(); 195 | 196 | /** 197 | * thread that reads joint values 198 | */ 199 | virtual void monitorThread(); 200 | 201 | void getJointMsg(sensor_msgs::JointState &msg); 202 | void getJointsRaw(double (&pos)[7], double (&vel)[7], double (&eff)[7]); 203 | void setJointTargets(double (&com)[7]); 204 | 205 | ros::Time getTime(){ 206 | t_m.lock(); 207 | ros::Time t (last_read_time); 208 | t_m.unlock(); 209 | return t; 210 | }; 211 | ros::Duration getPeriod() { 212 | t_m.lock(); 213 | ros::Duration d (period); 214 | t_m.unlock(); 215 | return d; 216 | } 217 | void setStiffness(double sx, double sy, double sz, double sa, double sb, double sc) { 218 | //reset the interpolation point 219 | js_m.lock(); 220 | jt_m.lock(); 221 | memcpy(joint_pos_interp, joint_pos, 7 * sizeof(double)); 222 | memcpy(msg, joint_pos, 7 * sizeof(double)); 223 | jt_m.unlock(); 224 | js_m.unlock(); 225 | usleep(100000); 226 | //set the new stiffness 227 | js_m.lock(); 228 | jt_m.lock(); 229 | msg[7] = sx; 230 | msg[8] = sy; 231 | msg[9] = sz; 232 | msg[10] = sa; 233 | msg[11] = sb; 234 | msg[12] = sc; 235 | jt_m.unlock(); 236 | js_m.unlock(); 237 | usleep(500000); 238 | } 239 | private: 240 | double joint_pos[7]; 241 | double joint_torques[7]; 242 | double joint_targets[7]; 243 | double joint_pos_interp[7]; 244 | double max_incr[7]; 245 | double min_incr[7]; 246 | double joint_increment[7]; 247 | double msg[13]; 248 | std::vector joint_names; 249 | double period, last_read_time; 250 | Server *joints_recv, *command_send; 251 | boost::mutex js_m, jt_m, t_m, session_m, socket_m; 252 | boost::thread send_thread, recv_thread; 253 | boost::condition_variable session_cond_; 254 | boost::condition_variable socket_cond_; 255 | 256 | bool firstRead; 257 | bool recv_quit, send_quit, doStep; 258 | bool send_established, recv_established; 259 | int SIZE; 260 | 261 | double getDoubleTime() 262 | { 263 | struct timeval time; 264 | gettimeofday(&time,NULL); 265 | return time.tv_sec + time.tv_usec * 1e-6; 266 | } 267 | 268 | }; 269 | 270 | #endif // _IIWA_FRI_CLIENT_H 271 | -------------------------------------------------------------------------------- /lbr_fri/src/iiwa_fri_client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //****************************************************************************** 4 | void IIWAFRIClient::onStateChange(ESessionState oldState, ESessionState newState) 5 | { 6 | LBRClient::onStateChange(oldState, newState); 7 | switch (newState) 8 | { 9 | case MONITORING_READY: 10 | { 11 | //set targets to current joints 12 | //memcpy(joint_targets, robotState().getMeasuredJointPosition(), 7 * sizeof(double)); 13 | last_time = getDoubleTime(); 14 | break; 15 | } 16 | case COMMANDING_WAIT: 17 | { 18 | last_time = getDoubleTime(); 19 | memcpy(joint_pos_interp, robotState().getMeasuredJointPosition(), 7 * sizeof(double)); 20 | for(int i=0; i<7; ++i) { 21 | joint_increment[i] = 0; 22 | } 23 | break; 24 | } 25 | 26 | default: 27 | { 28 | break; 29 | } 30 | } 31 | } 32 | 33 | //****************************************************************************** 34 | void IIWAFRIClient::monitor() 35 | { 36 | double t_here = getDoubleTime(); 37 | period = t_here - last_time; 38 | last_time = t_here; 39 | LBRState current_state = robotState(); 40 | memcpy(joint_pos, current_state.getMeasuredJointPosition(), 7 * sizeof(double)); 41 | memcpy(joint_torques, current_state.getMeasuredTorque(), 7 * sizeof(double)); 42 | } 43 | 44 | void IIWAFRIClient::getJointMsg(sensor_msgs::JointState &msg) { 45 | std::vector pos (joint_pos, joint_pos+sizeof(joint_pos)/sizeof(double)); 46 | msg.position = pos; 47 | 48 | std::vector torques (joint_torques, joint_torques+sizeof(joint_torques)/sizeof(double)); 49 | msg.effort = torques; 50 | msg.name = joint_names; 51 | } 52 | 53 | //****************************************************************************** 54 | void IIWAFRIClient::getJointsRaw(double (&pos)[7], double (&vel)[7], double (&eff)[7]) { 55 | memcpy(pos, joint_pos, 7 * sizeof(double)); 56 | memcpy(eff, joint_torques, 7 * sizeof(double)); 57 | } 58 | 59 | void IIWAFRIClient::setJointTargets(const double (&com)[7]) { 60 | memcpy(joint_targets, com, 7 * sizeof(double)); 61 | //std::cerr<<"com[6]"< min_incr[i]) { 78 | joint_pos_interp[i] += (fabs(joint_increment[i]) < max_incr[i]) ? joint_increment[i] : 79 | ((joint_increment[i]<0)? -1*max_incr[i] : max_incr[i]); 80 | } 81 | //joint_increment[i] = 0; 82 | // std::cerr<0.005) std::cerr<<"period(client) "<Connect(); 111 | { 112 | boost::mutex::scoped_lock lock(session_m); 113 | send_established = true; 114 | session_cond_.notify_one(); 115 | } 116 | printf("SEND Server, got a connection...\n"); 117 | fflush(NULL); 118 | 119 | while(true) 120 | { 121 | { 122 | boost::mutex::scoped_lock lock(socket_m); 123 | while(!doStep) { 124 | socket_cond_.wait(lock); 125 | } 126 | break; 127 | } 128 | } 129 | 130 | //cleanup 131 | command_send->Close(); 132 | delete command_send; 133 | command_send=NULL; 134 | 135 | } 136 | 137 | /** 138 | * thread that reads joint values 139 | */ 140 | void IIWAFRIClientNative::monitorThread() { 141 | int port = 5010; 142 | int dataport =-1; 143 | bool bResult = false; 144 | 145 | joints_recv = new Server(port, dataport, &bResult); 146 | if (!bResult) 147 | { 148 | printf("Failed to create Server object!\n"); 149 | return; 150 | } 151 | 152 | fflush(NULL); 153 | joints_recv->Connect(); 154 | { 155 | boost::mutex::scoped_lock lock(session_m); 156 | recv_established = true; 157 | session_cond_.notify_one(); 158 | } 159 | printf("RECV Server, got a connection...\n"); 160 | fflush(NULL); 161 | 162 | while(true) { 163 | // printf("receiving from socket\n"); 164 | { 165 | boost::mutex::scoped_lock lock(socket_m); 166 | while(!doStep) { 167 | socket_cond_.wait(lock); 168 | } 169 | break; 170 | //doStep=false; 171 | } 172 | 173 | } 174 | //cleanup 175 | joints_recv->Close(); 176 | delete joints_recv; 177 | joints_recv=NULL; 178 | } 179 | 180 | void IIWAFRIClientNative::getJointMsg(sensor_msgs::JointState &msg) { 181 | double jp[7], vel[7], eff[7]; 182 | this->getJointsRaw(jp,vel,eff); 183 | std::vector pos (jp, jp+sizeof(jp)/sizeof(double)); 184 | msg.position = pos; 185 | msg.name = joint_names; 186 | 187 | } 188 | 189 | void IIWAFRIClientNative::getJointsRaw(double (&pos)[7], double (&vel)[7], double (&eff)[7]) { 190 | // printf("getting joints\n"); 191 | js_m.lock(); 192 | // printf("got mutex\n"); 193 | fflush(NULL); 194 | joints_recv->RecvDoubles(joint_pos, SIZE); 195 | if(firstRead) { 196 | firstRead = false; 197 | memcpy(joint_pos_interp, joint_pos, 7 * sizeof(double)); 198 | memcpy(msg, joint_pos, 7 * sizeof(double)); 199 | for(int i=0; i<7; ++i) { 200 | joint_increment[i] = 0; 201 | // std::cout<SendDoubles(com, SIZE); 226 | for(int i=0; i<7; ++i) { 227 | joint_increment[i] = com[i]*period; 228 | if(fabs(joint_increment[i]) > min_incr[i]) { 229 | msg[i] += (fabs(joint_increment[i]) < max_incr[i]) ? joint_increment[i] : 230 | ((joint_increment[i]<0)? -1*max_incr[i] : max_incr[i]); 231 | } 232 | // std::cerr<<"joint_targets["<SendDoubles(msg, sizeof(msg)); 237 | } 238 | jt_m.unlock(); 239 | // printf("released target mutex\n"); 240 | } 241 | -------------------------------------------------------------------------------- /lbr_iiwa_control/launch/lbr_iiwa_effort_pos_control.perspective: -------------------------------------------------------------------------------- 1 | { 2 | "keys": {}, 3 | "groups": { 4 | "pluginmanager": { 5 | "keys": { 6 | "running-plugins": { 7 | "type": "repr", 8 | "repr": "{u'rqt_reconfigure/Param': [1], u'rqt_plot/Plot': [1], u'rqt_publisher/Publisher': [1]}" 9 | } 10 | }, 11 | "groups": { 12 | "plugin__rqt_plot__Plot__1": { 13 | "keys": {}, 14 | "groups": { 15 | "dock_widget__DataPlotWidget": { 16 | "keys": { 17 | "dockable": { 18 | "type": "repr", 19 | "repr": "True" 20 | }, 21 | "parent": { 22 | "type": "repr", 23 | "repr": "None" 24 | } 25 | }, 26 | "groups": {} 27 | }, 28 | "plugin": { 29 | "keys": { 30 | "autoscroll": { 31 | "type": "repr", 32 | "repr": "True" 33 | }, 34 | "plot_type": { 35 | "type": "repr", 36 | "repr": "1" 37 | }, 38 | "topics": { 39 | "type": "repr", 40 | "repr": "[u'/lbr_iiwa/lbr_iiwa_joint_2_effort_pos_controller/command/data', u'/lbr_iiwa/lbr_iiwa_joint_2_effort_pos_controller/state/process_value']" 41 | } 42 | }, 43 | "groups": {} 44 | } 45 | } 46 | }, 47 | "plugin__rqt_publisher__Publisher__1": { 48 | "keys": {}, 49 | "groups": { 50 | "dock_widget__PublisherWidget": { 51 | "keys": { 52 | "dockable": { 53 | "type": "repr", 54 | "repr": "True" 55 | }, 56 | "parent": { 57 | "type": "repr", 58 | "repr": "None" 59 | } 60 | }, 61 | "groups": {} 62 | }, 63 | "plugin": { 64 | "keys": { 65 | "publishers": { 66 | "type": "repr", 67 | "repr": "u\"[{'topic_name': '/lbr_iiwa/lbr_iiwa_joint_1_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 0, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_2_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {u'/lbr_iiwa/lbr_iiwa_joint_2_effort_pos_controller/command/data': '-0.5'}, 'publisher_id': 1, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_3_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 2, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_4_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 3, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_5_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 4, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_6_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 5, 'counter': 0}, {'topic_name': '/lbr_iiwa/lbr_iiwa_joint_7_effort_pos_controller/command', 'type_name': 'std_msgs/Float64', 'enabled': False, 'rate': 1000.0, 'expressions': {}, 'publisher_id': 6, 'counter': 0}]\"" 68 | } 69 | }, 70 | "groups": {} 71 | } 72 | } 73 | }, 74 | "plugin__rqt_reconfigure__Param__1": { 75 | "keys": {}, 76 | "groups": { 77 | "dock_widget___plugincontainer_top_widget": { 78 | "keys": { 79 | "dockable": { 80 | "type": "repr", 81 | "repr": "True" 82 | }, 83 | "parent": { 84 | "type": "repr", 85 | "repr": "None" 86 | } 87 | }, 88 | "groups": {} 89 | }, 90 | "plugin": { 91 | "keys": { 92 | "splitter": { 93 | "type": "repr(QByteArray.hex)", 94 | "repr(QByteArray.hex)": "QtCore.QByteArray('000000ff0000000000000002000000ae0000006401000000060100000001')", 95 | "pretty-print": " d " 96 | }, 97 | "_splitter": { 98 | "type": "repr(QByteArray.hex)", 99 | "repr(QByteArray.hex)": "QtCore.QByteArray('000000ff00000000000000020000012c0000006401000000090100000002')", 100 | "pretty-print": " , d " 101 | } 102 | }, 103 | "groups": {} 104 | } 105 | } 106 | } 107 | } 108 | }, 109 | "mainwindow": { 110 | "keys": { 111 | "geometry": { 112 | "type": "repr(QByteArray.hex)", 113 | "repr(QByteArray.hex)": "QtCore.QByteArray('01d9d0cb0001000000000037000000c6000006670000032600000041000000ec0000065d0000031c000000000000')", 114 | "pretty-print": " 7 g & A ] " 115 | }, 116 | "state": { 117 | "type": "repr(QByteArray.hex)", 118 | "repr(QByteArray.hex)": "QtCore.QByteArray('000000ff00000000fd00000001000000030000061d00000202fc0100000006fb00000062007200710074005f0063006f006e00740072006f006c006c00650072005f006d0061006e0061006700650072005f005f0043006f006e00740072006f006c006c00650072004d0061006e0061006700650072004700550049005f005f0031005f005f0100000000000002580000000000000000fb00000058007200710074005f007000750062006c00690073006800650072005f005f005000750062006c00690073006800650072005f005f0031005f005f005000750062006c006900730068006500720057006900640067006500740100000000000003410000026600fffffffc00000347000002d60000017700fffffffa000000010200000002fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0031005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f0077006900640067006500740200000068000000180000028b00000214fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0031005f005f00440061007400610050006c006f00740057006900640067006500740100000019000003d30000008c00fffffffb00000062007200710074005f0072006f0062006f0074005f006d006f006e00690074006f0072005f005f0052006f0062006f0074004d006f006e00690074006f0072005f005f0031005f005f0052006f0062006f00740020004d006f006e00690074006f007201000004f2000000dc0000000000000000fb00000042007200710074005f0070006c006f0074005f005f0050006c006f0074005f005f0032005f005f00440061007400610050006c006f0074005700690064006700650074030000041f0000006b0000026e00000178fb0000006c007200710074005f007200650063006f006e006600690067007500720065005f005f0050006100720061006d005f005f0032005f005f005f0070006c007500670069006e0063006f006e007400610069006e00650072005f0074006f0070005f007700690064006700650074030000004100000048000001f9000001dd0000061d0000000000000004000000040000000800000008fc00000001000000030000000100000036004d0069006e0069006d0069007a006500640044006f0063006b00570069006400670065007400730054006f006f006c0062006100720000000000ffffffff0000000000000000')", 119 | "pretty-print": " brqt_controller_manager__ControllerManagerGUI__1__ Xrqt_publisher__Publisher__1__PublisherWidget G w h k n x A H " 120 | } 121 | }, 122 | "groups": { 123 | "toolbar_areas": { 124 | "keys": { 125 | "MinimizedDockWidgetsToolbar": { 126 | "type": "repr", 127 | "repr": "8" 128 | } 129 | }, 130 | "groups": {} 131 | } 132 | } 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /lbr_fri/src/iiwa_hw_interface.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "iiwa_fri_client.h" 7 | #include "friUdpConnection.h" 8 | #include "friClientApplication.h" 9 | #include 10 | #include 11 | #include "sensor_msgs/JointState.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #define DEFAULT_PORTID 30200 20 | //#define bFRI 21 | 22 | class IIWARobot : public hardware_interface::RobotHW 23 | { 24 | public: 25 | #ifdef bFRI 26 | IIWAFRIClient client; 27 | UdpConnection connection; 28 | ClientApplication app; 29 | #else 30 | IIWAFRIClientNative client; 31 | ros::ServiceServer stiffness_client; 32 | #endif 33 | std::string hostname; 34 | int port; 35 | ros::NodeHandle n_; 36 | //ros::Subscriber velvet_state; 37 | //ros::Publisher velvet_targ; 38 | 39 | //boost::mutex velvet_m; 40 | std::string velvet_state_topic, velvet_target_topic; 41 | public: 42 | IIWARobot(ros::NodeHandle param_nh): client() 43 | #ifdef bFRI 44 | ,connection(),app(connection,client) 45 | #endif 46 | { 47 | param_nh.param("hostname",hostname,"192.170.10.2"); 48 | param_nh.param("port",port,DEFAULT_PORTID); 49 | param_nh.param("velvet_topic_name", velvet_state_topic,"/velvet_node/vnode_state"); 50 | param_nh.param("velvet_target_topic_name", velvet_target_topic,"/velvet_node/vnode_target"); 51 | 52 | #ifdef bFRI 53 | app.connect(port, hostname.c_str()); 54 | #else 55 | client.startThreads(); 56 | stiffness_client= param_nh.advertiseService("set_stiffness", &IIWARobot::stiff_callback, this);; 57 | 58 | #endif 59 | 60 | // connect and register the joint state interface 61 | hardware_interface::JointStateHandle state_handle_1("lbr_iiwa_joint_1", &pos[0], &vel[0], &eff[0]); 62 | jnt_state_interface.registerHandle(state_handle_1); 63 | 64 | hardware_interface::JointStateHandle state_handle_2("lbr_iiwa_joint_2", &pos[1], &vel[1], &eff[1]); 65 | jnt_state_interface.registerHandle(state_handle_2); 66 | 67 | hardware_interface::JointStateHandle state_handle_3("lbr_iiwa_joint_3", &pos[2], &vel[2], &eff[2]); 68 | jnt_state_interface.registerHandle(state_handle_3); 69 | 70 | hardware_interface::JointStateHandle state_handle_4("lbr_iiwa_joint_4", &pos[3], &vel[3], &eff[3]); 71 | jnt_state_interface.registerHandle(state_handle_4); 72 | 73 | hardware_interface::JointStateHandle state_handle_5("lbr_iiwa_joint_5", &pos[4], &vel[4], &eff[4]); 74 | jnt_state_interface.registerHandle(state_handle_5); 75 | 76 | hardware_interface::JointStateHandle state_handle_6("lbr_iiwa_joint_6", &pos[5], &vel[5], &eff[5]); 77 | jnt_state_interface.registerHandle(state_handle_6); 78 | 79 | hardware_interface::JointStateHandle state_handle_7("lbr_iiwa_joint_7", &pos[6], &vel[6], &eff[6]); 80 | jnt_state_interface.registerHandle(state_handle_7); 81 | 82 | // hardware_interface::JointStateHandle state_handle_v("velvet_fingers_joint_1", &velvet_pos, &velvet_vel, &velvet_eff); 83 | // jnt_state_interface.registerHandle(state_handle_v); 84 | 85 | registerInterface(&jnt_state_interface); 86 | 87 | // connect and register the joint position interface 88 | hardware_interface::JointHandle vel_handle_1(jnt_state_interface.getHandle("lbr_iiwa_joint_1"), &cmd[0]); 89 | jnt_vel_interface.registerHandle(vel_handle_1); 90 | 91 | hardware_interface::JointHandle vel_handle_2(jnt_state_interface.getHandle("lbr_iiwa_joint_2"), &cmd[1]); 92 | jnt_vel_interface.registerHandle(vel_handle_2); 93 | 94 | hardware_interface::JointHandle vel_handle_3(jnt_state_interface.getHandle("lbr_iiwa_joint_3"), &cmd[2]); 95 | jnt_vel_interface.registerHandle(vel_handle_3); 96 | 97 | hardware_interface::JointHandle vel_handle_4(jnt_state_interface.getHandle("lbr_iiwa_joint_4"), &cmd[3]); 98 | jnt_vel_interface.registerHandle(vel_handle_4); 99 | 100 | hardware_interface::JointHandle vel_handle_5(jnt_state_interface.getHandle("lbr_iiwa_joint_5"), &cmd[4]); 101 | jnt_vel_interface.registerHandle(vel_handle_5); 102 | 103 | hardware_interface::JointHandle vel_handle_6(jnt_state_interface.getHandle("lbr_iiwa_joint_6"), &cmd[5]); 104 | jnt_vel_interface.registerHandle(vel_handle_6); 105 | 106 | hardware_interface::JointHandle vel_handle_7(jnt_state_interface.getHandle("lbr_iiwa_joint_7"), &cmd[6]); 107 | jnt_vel_interface.registerHandle(vel_handle_7); 108 | 109 | //hardware_interface::JointHandle vel_handle_v(jnt_state_interface.getHandle("velvet_fingers_joint_1"), &velvet_cmd); 110 | //jnt_vel_interface.registerHandle(vel_handle_v); 111 | 112 | registerInterface(&jnt_vel_interface); 113 | first_vals = true; 114 | 115 | velvet_pos =0; 116 | velvet_vel =0; 117 | velvet_eff =0; 118 | n_ = ros::NodeHandle(); 119 | //velvet_state = n_.subscribe(velvet_state_topic, 1, &IIWARobot::updateVelvetState, this); 120 | //velvet_targ = param_nh.advertise(velvet_target_topic,10); 121 | 122 | #ifndef bFRI 123 | bool success = client.waitForSession(); 124 | #endif 125 | } 126 | ~IIWARobot() 127 | { 128 | #ifdef bFRI 129 | app.disconnect(); 130 | #else 131 | client.step(); 132 | #endif 133 | } 134 | 135 | bool stiff_callback(lbr_fri::SetStiffness::Request &req, 136 | lbr_fri::SetStiffness::Response &res ) { 137 | #ifndef bFRI 138 | client.setStiffness(req.sx,req.sy,req.sz,req.sa,req.sb,req.sc); 139 | #endif 140 | return true; 141 | } 142 | 143 | void updateVelvetState(const velvet_msgs::VNodeStatePtr msg) { 144 | //lock mutex and update variables 145 | //velvet_m.lock(); 146 | velvet_pos = msg->joint_pos; 147 | velvet_vel = msg->joint_vel; 148 | velvet_eff = msg->joint_eff; 149 | //velvet_m.unlock(); 150 | } 151 | 152 | void read() 153 | { 154 | #ifdef bFRI 155 | // bool success = app.step(); 156 | #endif 157 | client.getJointsRaw(pos,vel,eff); 158 | if(first_vals) { 159 | memcpy(prev_pos,pos,sizeof(double)*7); 160 | first_vals = false; 161 | return; 162 | } 163 | for(int i=0; i<7; ++i) { 164 | vel[i] = (pos[i]-prev_pos[i]) / client.getPeriod().toSec(); 165 | } 166 | memcpy(prev_pos,pos,sizeof(double)*7); 167 | //std::cerr<<"read joints: "<client.step(); 205 | delete robot; 206 | }*/ 207 | 208 | int main(int argc, char **argv) 209 | { 210 | ros::init(argc, argv, "iiwa_hw_interface"); 211 | 212 | ros::NodeHandle param("~"); 213 | robot = new IIWARobot(param); 214 | 215 | //signal(SIGTERM, &handler); 216 | ros::NodeHandle nh; 217 | controller_manager::ControllerManager cm(robot,nh); 218 | ros::AsyncSpinner spinner(8); 219 | spinner.start(); 220 | 221 | while (true) 222 | { 223 | robot->write(); 224 | robot->read(); 225 | cm.update(robot->get_time(), robot->get_period()); 226 | } 227 | 228 | spinner.stop(); 229 | } 230 | -------------------------------------------------------------------------------- /lbr_iiwa_java/SmartServoControl.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import com.kuka.common.StatisticTimer; 5 | import com.kuka.common.ThreadUtil; 6 | import com.kuka.common.StatisticTimer.OneTimeStep; 7 | import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication; 8 | import static com.kuka.roboticsAPI.motionModel.BasicMotions.*; 9 | 10 | import com.kuka.roboticsAPI.controllerModel.Controller; 11 | import com.kuka.roboticsAPI.deviceModel.JointPosition; 12 | import com.kuka.roboticsAPI.deviceModel.LBR; 13 | import com.kuka.roboticsAPI.geometricModel.PhysicalObject; 14 | import com.kuka.roboticsAPI.motionModel.DirectServo; 15 | import com.kuka.roboticsAPI.motionModel.IDirectServoRuntime; 16 | import com.kuka.roboticsAPI.motionModel.ISmartServoRuntime; 17 | import com.kuka.roboticsAPI.motionModel.SmartServo; 18 | import com.kuka.roboticsAPI.userInterface.ServoMotionUtilities; 19 | 20 | /** 21 | * Implementation of a robot application. 22 | *

23 | * The application provides a {@link RoboticsAPITask#initialize()} and a 24 | * {@link RoboticsAPITask#run()} method, which will be called successively in 25 | * the application lifecycle. The application will terminate automatically after 26 | * the {@link RoboticsAPITask#run()} method has finished or after stopping the 27 | * task. The {@link RoboticsAPITask#dispose()} method will be called, even if an 28 | * exception is thrown during initialization or run. 29 | *

30 | * It is imperative to call super.dispose() when overriding the 31 | * {@link RoboticsAPITask#dispose()} method. 32 | * 33 | * @see #initialize() 34 | * @see #run() 35 | * @see #dispose() 36 | */ 37 | public class SmartServoControl extends RoboticsAPIApplication { 38 | // members 39 | private LBR _theLbr; 40 | /** 41 | * Will be initialized from the routine "createTool()". 42 | * 43 | * IMPORTANT NOTE: Set the load mass properly 44 | */ 45 | private IDirectServoRuntime theSmartServoRuntime = null; 46 | private int _count = 0; 47 | // private JointStreamer js; 48 | private JointTargetsListner jt; 49 | 50 | @Override 51 | public void initialize() 52 | { 53 | getContext().dumpDevices(); 54 | 55 | // Locate the "first" Lightweight Robot in the system 56 | _theLbr = ServoMotionUtilities.locateLBR(getContext()); 57 | //js = new JointStreamer(); 58 | jt = new JointTargetsListner(); 59 | } 60 | 61 | /** 62 | * Move to an initial Position WARNING: MAKE SHURE, THAT the pose is 63 | * collision free. 64 | */ 65 | public void moveToInitialPosition() 66 | { 67 | _theLbr.move( 68 | ptp(0., 0., 0., 0, 0., 69 | 0., 0.).setJointVelocityRel(0.1)); 70 | 71 | /* 72 | * 73 | * For Completeness Sake, the validation is performed here Even it would 74 | * not be necessary within this sample. 75 | * 76 | * As long, as you'd remain within position control, the validation is 77 | * not necessary ... but, lightweight robot without ImpedanceControl is 78 | * a car without fuel... 79 | * 80 | * Note: The Validation itself justifies, that in this very time 81 | * instance, the load parameter setting was sufficient. This does not 82 | * mean by far, that the parameter setting is valid in the sequel or 83 | * lifetime of this program 84 | 85 | try 86 | { 87 | if (!SmartServo.validateForImpedanceMode(_toolAttachedToLBR)) 88 | { 89 | System.out 90 | .println("Validation of Torque Model failed - correct your mass property settings"); 91 | System.out 92 | .println("SmartServo will be available for position controlled mode only, until validation is performed"); 93 | } 94 | } 95 | catch (IllegalStateException e) 96 | { 97 | System.out.println("Omitting validation failure for this sample\n" 98 | + e.getMessage()); 99 | } 100 | */ 101 | } 102 | 103 | // Sleep in between 104 | //private int _milliSleepToEmulateComputationalEffort = 10;//000; 105 | //private int _numRuns = 10000; 106 | //private double _amplitude = 0.2; 107 | //private double _freqency = 0.1; 108 | //private int steps = 0; 109 | 110 | @Override 111 | public void run() 112 | { 113 | 114 | jt.start(); 115 | 116 | //moveToInitialPosition(); 117 | 118 | JointPosition initialPosition = new JointPosition( 119 | _theLbr.getCurrentJointPosition()); 120 | DirectServo aSmartServoMotion = new DirectServo(initialPosition); 121 | 122 | //aSmartServoMotion.overrideJointAcceleration(1); 123 | //aSmartServoMotion.setJointJerk(1); 124 | 125 | double exec_time = 100e-3; 126 | aSmartServoMotion.setMinimumTrajectoryExecutionTime(exec_time); 127 | aSmartServoMotion.setTimeoutAfterGoalReach(3000); 128 | aSmartServoMotion.setJointVelocityRel(0.2); 129 | aSmartServoMotion.setJointAccelerationRel(0.2); 130 | //aSmartServoMotion.setSpeedTimeoutAfterGoalReach(80e-3); 131 | 132 | System.out.println("Starting SmartServo in Position Mode"); 133 | _theLbr.moveAsync(aSmartServoMotion); 134 | 135 | // Fetch the Runtime of the Motion part 136 | theSmartServoRuntime = aSmartServoMotion.getRuntime(); 137 | 138 | 139 | //theSmartServoRuntime.activateVelocityPlanning(true); 140 | 141 | // create an JointPosition Instance, to play with 142 | JointPosition destination = new JointPosition( 143 | _theLbr.getJointCount()); 144 | JointPosition target_vel = new JointPosition( 145 | _theLbr.getJointCount()); 146 | System.out.println("start loop"); 147 | // For Roundtrip time measurement... 148 | //StatisticTimer timing = new StatisticTimer(); 149 | try 150 | { 151 | 152 | double kp[] = new double[7]; //0.005; 153 | double kd[] = new double[7]; 154 | double amp[] = new double[7]; 155 | int joint_id = 6; 156 | kp[6] = 0.1;//0.04; 157 | kd[6] = 0.0; 158 | amp[6] = 2; //5 159 | kp[5] = 0.04; 160 | kd[5] = 0; 161 | amp[5] = 2; //2 162 | kp[4] = 0.06;//0.05; 163 | kd[4] = 0; 164 | amp[4] = 2; 165 | kp[3] = 0.07;//0.003; 166 | kd[3] = 0; 167 | amp[3] = 2; 168 | kp[2] = 0.05;//0.02; 169 | kd[2] = 0; 170 | amp[2] = 2; 171 | kp[1] = 0.02;//0.003; 172 | kd[1] = 0; 173 | amp[1] = 2; 174 | kp[0] = 0.06;//0.04; 175 | kd[0] = 0; 176 | amp[0] = 2; 177 | int step_ctr=0; 178 | System.out.println("starting servoing"); 179 | long t_last =System.nanoTime(); 180 | long t_here = t_last; 181 | 182 | JointPosition curMsrJntPose = theSmartServoRuntime 183 | .getAxisQMsrOnController(); 184 | StatisticTimer timing = new StatisticTimer(); 185 | JointPosition prevMsrJntPose = new JointPosition(curMsrJntPose); 186 | JointPosition prevErr = new JointPosition(curMsrJntPose); 187 | 188 | boolean isFirstStep = true; 189 | while(true) { 190 | 191 | OneTimeStep aStep = timing.newTimeStep(); 192 | //System.out.println("asking for joints"); 193 | theSmartServoRuntime.updateWithRealtimeSystem(); 194 | curMsrJntPose = theSmartServoRuntime 195 | .getAxisQMsrOnController(); 196 | 197 | 198 | target_vel = jt.getJP(curMsrJntPose); 199 | 200 | // theSmartServoRuntime.updateWithRealtimeSystem(); 201 | // curMsrJntPose = theSmartServoRuntime 202 | // .getAxisQMsrOnController(); 203 | 204 | 205 | t_here = System.nanoTime(); 206 | double dt = (t_here-t_last)/1e9; 207 | t_last = t_here; 208 | //double t = t_here/1e9; 209 | //if time step is too large top 210 | if(dt > 0.2) dt = 0; 211 | 212 | JointPosition curr_vel = new JointPosition(target_vel); 213 | 214 | JointPosition e = new JointPosition(target_vel); 215 | 216 | //JointPosition u = new JointPosition(target_vel); 217 | for (int i=0; i<_theLbr.getJointCount(); ++i) { 218 | curr_vel.set(i, (curMsrJntPose.get(i)-prevMsrJntPose.get(i))/dt); 219 | prevMsrJntPose.set(i,curMsrJntPose.get(i)); 220 | e.set(i,target_vel.get(i)-curr_vel.get(i)); 221 | if(isFirstStep) { 222 | prevErr.set(i,e.get(i)); 223 | } 224 | destination.set(i, kp[i]*e.get(i) + curMsrJntPose.get(i) + amp[i]*dt*target_vel.get(i)); 225 | prevErr.set(i,e.get(i)); 226 | 227 | if(destination.get(i)-curMsrJntPose.get(i) < Math.toRadians(-4)) { 228 | destination.set(i,curMsrJntPose.get(i)+Math.toRadians(-4)); 229 | } 230 | if(destination.get(i)-curMsrJntPose.get(i) > Math.toRadians(4)) { 231 | destination.set(i,curMsrJntPose.get(i)+Math.toRadians(4)); 232 | } 233 | /*if(Math.abs(destination.get(i)-curMsrJntPose.get(i)) < Math.toRadians(0.1)) { 234 | destination.set(i,curMsrJntPose.get(i)); 235 | }*/ 236 | 237 | } 238 | isFirstStep=false; 239 | 240 | //aSmartServoMotion.setMinimumTrajectoryExecutionTime(dt/1000.); 241 | // for (int i=0; i<_theLbr.getJointCount(); ++i) { 242 | //calculate q_k+1 HERE 243 | 244 | //double jerk = 2*(target_vel.get(i) - curr_vel.get(i))/(exec_time*exec_time); 245 | //destination.set(i, curMsrJntPose.get(i)+exec_time*target_vel.get(i)+jerk/6*Math.pow(exec_time, 3)); 246 | // destination.set(i, curMsrJntPose.get(i)+exec_time*target_vel.get(i)); 247 | 248 | 249 | //} 250 | //System.out.println("sent to jp "+destination.get(6)); 251 | 252 | //aSmartServoMotion.setMinimumTrajectoryExecutionTime(1.5*dt); 253 | theSmartServoRuntime.setDestination(destination); 254 | 255 | 256 | if(step_ctr%100 ==0) { 257 | // step_ctr=0; 258 | //for (int i=5; i<_theLbr.getJointCount(); ++i) { 259 | 260 | System.out.println("sent to jp "+joint_id+": "+destination.get(joint_id)+" dt is "+dt+"target vel is "+target_vel.get(joint_id)+" curr vel "+curr_vel.get(joint_id)+" curr pos "+curMsrJntPose.get(joint_id)); 261 | //} 262 | getLogger().info("Statistic Timing of Overall Loop " + timing); 263 | 264 | } 265 | step_ctr++; 266 | 267 | //theSmartServoRuntime.setDestination(curMsrJntPose,target_vel); 268 | 269 | // ThreadUtil.milliSleep(10); 270 | 271 | aStep.end(); 272 | 273 | 274 | 275 | //js.setJS(curMsrJntPose); 276 | 277 | } 278 | } 279 | catch (Exception e) 280 | { 281 | System.out.println(e); 282 | e.printStackTrace(); 283 | } 284 | ThreadUtil.milliSleep(1000); 285 | // Stop the motion 286 | theSmartServoRuntime.stopMotion(); 287 | try { 288 | jt.join(); 289 | } catch (InterruptedException e) { 290 | // TODO Auto-generated catch block 291 | e.printStackTrace(); 292 | } 293 | 294 | 295 | } 296 | 297 | 298 | 299 | 300 | /** 301 | * Auto-generated method stub. Do not modify the contents of this method. 302 | */ 303 | public static void main(String[] args) { 304 | SmartServoControl app = new SmartServoControl(); 305 | app.runApplication(); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /lbr_iiwa_description/urdf/lbr_iiwa.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 67 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 106 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 145 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 184 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 262 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 301 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | -------------------------------------------------------------------------------- /lbr_iiwa_java/Client.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import java.io.*; 5 | import java.net.*; 6 | import java.awt.*; 7 | 8 | public class Client 9 | { 10 | 11 | boolean VERBOSE = false; // turn on/off debugging output 12 | static int BUFFSIZE = 128000; // how many bytes our incoming buffer can hold 13 | 14 | byte data[]; 15 | byte buff[]; 16 | 17 | int port; 18 | int dataport; 19 | String host; 20 | Socket sock; 21 | DatagramSocket recv_sock, send_sock; 22 | 23 | BufferedInputStream input; 24 | BufferedOutputStream output; 25 | 26 | 27 | public boolean isActive() { 28 | return (sock.isConnected() && !(sock.isInputShutdown() || sock.isOutputShutdown())); 29 | } 30 | // constructor, takes a port number, a machine name host, and a bit 31 | // that indicates whether to reverse the byte order or not 32 | 33 | public Client(int p, int datap, String address, int rev) throws IOException 34 | { 35 | port = p; 36 | dataport = datap; 37 | host = address; 38 | 39 | try { 40 | sock = new Socket( InetAddress.getByName(address), 41 | port ); 42 | input = new BufferedInputStream(sock.getInputStream(), BUFFSIZE); 43 | output = new BufferedOutputStream(sock.getOutputStream(),BUFFSIZE); 44 | } 45 | catch ( IOException e ) { 46 | e.printStackTrace(); 47 | } 48 | 49 | if (dataport != -1) 50 | { 51 | // allocate the datagram socket 52 | try { 53 | recv_sock = new DatagramSocket(dataport); 54 | send_sock = new DatagramSocket(); 55 | } 56 | catch (SocketException se) { 57 | se.printStackTrace(); 58 | } 59 | } 60 | 61 | // amortize the buffer allocation by just doing it once 62 | 63 | buff = new byte[BUFFSIZE]; 64 | data = new byte[BUFFSIZE]; 65 | 66 | if (VERBOSE) System.out.println("Client: opening socket to " + 67 | address + " on port " + port + 68 | ", datagrams on port = " +dataport); 69 | 70 | // now we want to tell the server if we want reversed bytes or not 71 | 72 | output.write(rev); 73 | output.flush(); 74 | 75 | if (VERBOSE) 76 | if (rev==1) 77 | System.out.println("Client: requested reversed bytes"); 78 | else 79 | System.out.println("Client: requested normal byte order"); 80 | } 81 | 82 | // send a string down the socket 83 | public void SendString(String str) throws IOException 84 | { 85 | 86 | /* convert our string into an array of bytes */ 87 | 88 | ByteArrayOutputStream bytestream; 89 | bytestream = new ByteArrayOutputStream(str.length()); 90 | 91 | DataOutputStream out; 92 | out = new DataOutputStream(bytestream); 93 | 94 | for (int i=0; iBUFFSIZE) 253 | System.out.println("Sending more bytes then will fit in buffer!"); 254 | 255 | while (totalbytes < maxlen) 256 | { 257 | numbytes = input.read(data); 258 | 259 | // copy the bytes into the result buffer 260 | for (i=totalbytes; iBUFFSIZE) 294 | System.out.println("Sending more ints then will fit in buffer!"); 295 | 296 | while (totalbytes < maxlen*4) 297 | { 298 | numbytes = input.read(data); 299 | 300 | // copy the bytes into the result buffer 301 | for (i=totalbytes; iBUFFSIZE) 346 | System.out.println("Sending more doubles then will fit in buffer!"); 347 | 348 | while (totalbytes < maxlen*8) 349 | { 350 | 351 | numbytes = input.read(data); 352 | 353 | // copy the bytes into the result buffer 354 | for (i=totalbytes; iBUFFSIZE) 397 | System.out.println("Sending more doubles then will fit in buffer!"); 398 | 399 | while (totalbytes < maxlen*4) 400 | { 401 | numbytes = input.read(data); 402 | 403 | // copy the bytes into the result buffer 404 | for (i=totalbytes; iBUFFSIZE) 443 | System.out.println("Sending more bytes then will fit in buffer!"); 444 | 445 | 446 | receivePacket = new DatagramPacket(val, maxlen); 447 | recv_sock.receive(receivePacket); 448 | 449 | numbytes = receivePacket.getLength(); 450 | 451 | if (VERBOSE) 452 | { 453 | System.out.print("Client: received " + numbytes + " bytes - "); 454 | for (i=0; i