From 2e37fb00df56487dad7f9e0cdcdc90796c8ce27b Mon Sep 17 00:00:00 2001 From: Thomas Timm Andersen Date: Wed, 28 Oct 2015 11:27:38 +0100 Subject: [PATCH] Code cleanup --- include/ur_modern_driver/ur_driver.h | 5 +-- src/ur_communication.cpp | 1 - src/ur_driver.cpp | 54 ---------------------------- src/ur_realtime_communication.cpp | 1 - 4 files changed, 1 insertion(+), 60 deletions(-) diff --git a/include/ur_modern_driver/ur_driver.h b/include/ur_modern_driver/ur_driver.h index 6bc1405..f2d9b7b 100644 --- a/include/ur_modern_driver/ur_driver.h +++ b/include/ur_modern_driver/ur_driver.h @@ -63,10 +63,7 @@ public: void setSpeed(double q0, double q1, double q2, double q3, double q4, double q5, double acc = 100.); - /* void addTraj( - std::vector inp_timestamps, //DEPRECATED - std::vector > positions, - std::vector > velocities); */ + bool doTraj(std::vector inp_timestamps, std::vector > inp_positions, std::vector > inp_velocities); diff --git a/src/ur_communication.cpp b/src/ur_communication.cpp index 0f27cc7..cf04cc3 100644 --- a/src/ur_communication.cpp +++ b/src/ur_communication.cpp @@ -155,7 +155,6 @@ void UrCommunication::run() { while (keepalive_ && !connected_) { std::this_thread::sleep_for(std::chrono::seconds(10)); fd_set writefds; - keepalive_ = true; connect(sec_sockfd_, (struct sockaddr *) &sec_serv_addr_, sizeof(sec_serv_addr_)); diff --git a/src/ur_driver.cpp b/src/ur_driver.cpp index c748334..d2252bf 100644 --- a/src/ur_driver.cpp +++ b/src/ur_driver.cpp @@ -73,61 +73,7 @@ std::vector UrDriver::interp_cubic(double t, double T, } return positions; } -/* - void UrDriver::addTraj(std::vector inp_timestamps, - std::vector > inp_positions, - std::vector > inp_velocities) { - // DEPRECATED - printf("!! addTraj is deprecated !!\n"); - std::vector timestamps; - std::vector > positions; - std::string command_string = "def traj():\n"; - for (unsigned int i = 1; i < inp_timestamps.size(); i++) { - timestamps.push_back(inp_timestamps[i - 1]); - double dt = inp_timestamps[i] - inp_timestamps[i - 1]; - unsigned int steps = (unsigned int) ceil(dt / maximum_time_step_); - double step_size = dt / steps; - for (unsigned int j = 1; j < steps; j++) { - timestamps.push_back(inp_timestamps[i - 1] + step_size * j); - } - } - // //make sure we come to a smooth stop - // while (timestamps.back() < inp_timestamps.back()) { - // timestamps.push_back(timestamps.back() + 0.008); - // } - // timestamps.pop_back(); - - unsigned int j = 0; - for (unsigned int i = 0; i < timestamps.size(); i++) { - while (inp_timestamps[j] <= timestamps[i]) { - j += 1; - } - positions.push_back( - UrDriver::interp_cubic(timestamps[i] - inp_timestamps[j - 1], - inp_timestamps[j] - inp_timestamps[j - 1], - inp_positions[j - 1], inp_positions[j], - inp_velocities[j - 1], inp_velocities[j])); - } - - timestamps.push_back(inp_timestamps[inp_timestamps.size() - 1]); - positions.push_back(inp_positions[inp_positions.size() - 1]); - /// This is actually faster than using a stringstream :-o - for (unsigned int i = 1; i < timestamps.size(); i++) { - char buf[128]; - sprintf(buf, - "\tservoj([%1.5f, %1.5f, %1.5f, %1.5f, %1.5f, %1.5f], t=%1.5f)\n", - positions[i][0], positions[i][1], positions[i][2], - positions[i][3], positions[i][4], positions[i][5], - timestamps[i] - timestamps[i - 1]); - command_string += buf; - } - command_string += "end\n"; - //printf("%s", command_string.c_str()); - rt_interface_->addCommandToQueue(command_string); - - } - */ bool UrDriver::doTraj(std::vector inp_timestamps, std::vector > inp_positions, std::vector > inp_velocities) { diff --git a/src/ur_realtime_communication.cpp b/src/ur_realtime_communication.cpp index c4881c0..f841455 100644 --- a/src/ur_realtime_communication.cpp +++ b/src/ur_realtime_communication.cpp @@ -156,7 +156,6 @@ void UrRealtimeCommunication::run() { while (keepalive_ && !connected_) { std::this_thread::sleep_for(std::chrono::seconds(10)); fd_set writefds; - keepalive_ = true; connect(sockfd_, (struct sockaddr *) &serv_addr_, sizeof(serv_addr_));