31 #include <gtest/gtest.h> 32 #include <condition_variable> 59 std::lock_guard<std::mutex> lk(connect_mutex_);
60 client_fd_ = filedescriptor;
61 connect_cv_.notify_one();
62 connection_callback_ =
true;
67 std::unique_lock<std::mutex> lk(connect_mutex_);
68 if (connect_cv_.wait_for(lk, std::chrono::milliseconds(milliseconds)) == std::cv_status::no_timeout ||
69 connection_callback_ ==
true)
71 connection_callback_ =
false;
84 bool connection_callback_ =
false;
90 std::vector<std::string> recipe = {
"timestamp" };
96 waitForConnectionCallback();
100 uint8_t data_package[] = { 0x00, 0x0c, 0x55, 0x01, 0x40, 0xbb, 0xbf, 0xdb, 0xa5, 0xe3, 0x53, 0xf7 };
102 server_->write(client_fd_, data_package,
sizeof(data_package), written);
104 std::vector<std::unique_ptr<rtde_interface::RTDEPackage>> products;
105 EXPECT_EQ(producer.
tryGet(products),
true);
110 data->getData(
"timestamp", timestamp);
111 EXPECT_FLOAT_EQ(timestamp, 7103.86);
115 std::cout <<
"Failed to get data package" << std::endl;
122 int main(
int argc,
char* argv[])
124 ::testing::InitGoogleTest(&argc, argv);
126 return RUN_ALL_TESTS();
void setProtocolVersion(uint16_t protocol_version)
void setupProducer() override
Triggers the stream to connect to the robot.
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
TEST_F(ProducerTest, get_data_package)
Wrapper class for a TCP socket server.
bool waitForConnectionCallback(int milliseconds=100)
void connectionCallback(const int filedescriptor)
int main(int argc, char *argv[])
bool tryGet(std::vector< std::unique_ptr< T >> &products) override
Attempts to read byte stream from the robot and parse it as a URPackage.
The RTDE specific parser. Interprets a given byte stream as serialized RTDE packages and parses it ac...
void startProducer() override
void stopProducer() override
Stops the producer. Currently no functionality needed.
std::condition_variable connect_cv_
std::unique_ptr< comm::TCPServer > server_
std::mutex connect_mutex_
The DataPackage class handles communication in the form of RTDE data packages both to and from the ro...
A general producer for URPackages. Implements funcionality to produce packages by reading and parsing...