mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 18:10:47 +02:00
Sending commands to the robot is now async of reading
This commit is contained in:
@@ -74,9 +74,11 @@ void UrRealtimeCommunication::addCommandToQueue(std::string inp) {
|
|||||||
if (inp.back() != '\n') {
|
if (inp.back() != '\n') {
|
||||||
inp.append("\n");
|
inp.append("\n");
|
||||||
}
|
}
|
||||||
command_string_lock_.lock();
|
write(sockfd_, inp.c_str(), inp.length());
|
||||||
|
/*command_string_lock_.lock();
|
||||||
command_ += inp;
|
command_ += inp;
|
||||||
command_string_lock_.unlock();
|
command_string_lock_.unlock();*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UrRealtimeCommunication::setSpeed(double q0, double q1, double q2,
|
void UrRealtimeCommunication::setSpeed(double q0, double q1, double q2,
|
||||||
@@ -106,18 +108,18 @@ void UrRealtimeCommunication::run() {
|
|||||||
setsockopt(sockfd_, IPPROTO_TCP, TCP_NODELAY, (char *) &flag_,
|
setsockopt(sockfd_, IPPROTO_TCP, TCP_NODELAY, (char *) &flag_,
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
robot_state_->unpack(buf);
|
robot_state_->unpack(buf);
|
||||||
command_string_lock_.lock();
|
/*command_string_lock_.lock();
|
||||||
if (command_.length() != 0) {
|
if (command_.length() != 0) {
|
||||||
write(sockfd_, command_.c_str(), command_.length());
|
write(sockfd_, command_.c_str(), command_.length());
|
||||||
command_ = "";
|
command_ = "";
|
||||||
}
|
}*/
|
||||||
if (safety_count_ == safety_count_max_) {
|
if (safety_count_ == safety_count_max_) {
|
||||||
setSpeed(0., 0., 0., 0., 0., 0.);
|
setSpeed(0., 0., 0., 0., 0., 0.);
|
||||||
write(sockfd_, command_.c_str(), command_.length());
|
//write(sockfd_, command_.c_str(), command_.length());
|
||||||
command_ = "";
|
//command_ = "";
|
||||||
}
|
}
|
||||||
safety_count_ += 1;
|
safety_count_ += 1;
|
||||||
command_string_lock_.unlock();
|
///command_string_lock_.unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
setSpeed(0., 0., 0., 0., 0., 0.);
|
setSpeed(0., 0., 0., 0., 0., 0.);
|
||||||
|
|||||||
Reference in New Issue
Block a user