28 #include <gtest/gtest.h> 36 TEST(rtde_parser, request_protocol_version)
39 unsigned char raw_data[] = { 0x00, 0x04, 0x56, 0x01 };
42 std::vector<std::unique_ptr<rtde_interface::RTDEPackage>> products;
44 parser.
parse(bp, products);
46 EXPECT_EQ(products.size(), 1);
49 dynamic_cast<rtde_interface::RequestProtocolVersion*>(products[0].
get()))
51 EXPECT_EQ(data->accepted_,
true);
55 TEST(rtde_parser, get_urcontrol_version)
58 unsigned char raw_data[] = { 0x00, 0x13, 0x76, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
59 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
62 std::vector<std::unique_ptr<rtde_interface::RTDEPackage>> products;
64 parser.
parse(bp, products);
66 EXPECT_EQ(products.size(), 1);
70 EXPECT_EQ(data->version_information_.major, 5);
71 EXPECT_EQ(data->version_information_.minor, 8);
72 EXPECT_EQ(data->version_information_.bugfix, 0);
73 EXPECT_EQ(data->version_information_.build, 0);
77 TEST(rtde_parser, test_to_string)
80 unsigned char raw_data[] = { 0x00, 0x05, 0x02, 0x00, 0x00 };
83 std::vector<std::unique_ptr<rtde_interface::RTDEPackage>> products;
85 parser.
parse(bp, products);
87 EXPECT_EQ(products.size(), 1);
89 std::stringstream expected;
90 expected <<
"Type: 2" << std::endl;
91 expected <<
"Raw byte stream: 0 0 " << std::endl;
93 EXPECT_EQ(products[0]->toString(), expected.str());
96 TEST(rtde_parser, test_illegal_length)
99 unsigned char raw_data[] = { 0x00, 0x06, 0x02, 0x00, 0x00 };
102 std::vector<std::unique_ptr<rtde_interface::RTDEPackage>> products;
104 EXPECT_FALSE(parser.parse(bp, products));
107 int main(
int argc,
char* argv[])
109 ::testing::InitGoogleTest(&argc, argv);
111 return RUN_ALL_TESTS();
The BinParser class handles a byte buffer and functionality to iteratively parse the content...
This class handles the package detailing the UR control version sent by the robot.
bool parse(comm::BinParser &bp, std::vector< std::unique_ptr< RTDEPackage >> &results)
Uses the given BinParser to create package objects from the contained serialization.
The RTDE specific parser. Interprets a given byte stream as serialized RTDE packages and parses it ac...
int main(int argc, char *argv[])
This class handles the robot's response after trying to set the used RTDE protocol version...
TEST(rtde_parser, request_protocol_version)