1 #include <gtest/gtest.h> 37 unsigned int count = 0;
42 struct timeval timeout = { 10, 0 };
43 int ret = select(
master_fd+1, &fds, NULL, NULL, &timeout);
52 unsigned int count_out = 8;
53 while (count_out > 0) {
54 ASSERT_NE(-1, ioctl(
master_fd, TIOCOUTQ, &count_out));
56 EXPECT_EQ(0, count_out);
77 ASSERT_NE(-1, ioctl(
master_fd, FIONREAD, &aval));
78 ASSERT_EQ(out.size(), aval);
79 ASSERT_EQ(out.size(), read(
master_fd, out.c_array(), out.size()));
98 ASSERT_NE(-1, ioctl(
master_fd, FIONREAD, &aval));
99 ASSERT_EQ(out.size(), aval);
100 ASSERT_EQ(out.size(), read(
master_fd, out.c_array(), out.size()));
105 int16_t left = (mm.
getData() >> 16) & 0xffff;
106 int16_t right = mm.
getData() & 0xffff;
118 mm.
setData((50 << 16) | (-50 & 0x0000ffff));
121 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
134 mm.
setData((0 << 16) | (0 & 0x0000ffff));
136 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
145 mm.
setData((50 << 16) | (-50 & 0x0000ffff));
147 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
156 mm.
setData((-50 << 16) | (50 & 0x0000ffff));
158 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
171 mm.
setData((std::numeric_limits<int16_t>::max() << 16) |
172 (std::numeric_limits<int16_t>::min() & 0x0000ffff));
175 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
188 mm.
setData((0 << 16) | (0 & 0x0000ffff));
190 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
199 mm.
setData((std::numeric_limits<int16_t>::max() << 16) |
200 (std::numeric_limits<int16_t>::min() & 0x0000ffff));
202 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
211 mm.
setData((std::numeric_limits<int16_t>::min() << 16) |
212 (std::numeric_limits<int16_t>::max() & 0x0000ffff));
214 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
232 ASSERT_NE(-1, ioctl(
master_fd, FIONREAD, &aval));
233 ASSERT_EQ(out.size(), aval);
234 ASSERT_EQ(out.size(), read(
master_fd, out.c_array(), out.size()));
249 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
262 ASSERT_NE(-1, ioctl(
master_fd, FIONREAD, &aval));
263 ASSERT_EQ(out.size(), aval);
264 ASSERT_EQ(out.size(), read(
master_fd, out.c_array(), out.size()));
285 for (
int i; i < 5; ++i) {
289 ASSERT_NE(-1, ioctl(
master_fd, FIONREAD, &aval));
290 ASSERT_EQ(out.size(), aval);
291 ASSERT_EQ(out.size(), read(
master_fd, out.c_array(), out.size()));
298 ASSERT_EQ(10, data.data);
303 ASSERT_EQ(-10, data.data);
313 mm.
setRegister(static_cast<MotorMessage::Registers>(0x50));
317 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
334 mm.
setRegister(static_cast<MotorMessage::Registers>(0x50));
338 ASSERT_EQ(out.size(), write(
master_fd, out.c_array(), out.size()));
349 int main(
int argc,
char **argv) {
350 testing::InitGoogleTest(&argc, argv);
352 return RUN_ALL_TESTS();
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void setData(int32_t data)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
MotorMessage::Registers getRegister() const
boost::array< uint8_t, 8 > RawMotorMessage
void callbackS(const std_msgs::Int32 &data)
int32_t pid_moving_buffer_size
struct MotorHardware::Joint joints_[2]
void setDeadmanTimer(int32_t deadman)
RawMotorMessage serialize() const
void setParams(FirmwareParams firmware_params)
void setRegister(MotorMessage::Registers reg)
int main(int argc, char **argv)
TEST_F(MotorHardwareTests, writeSpeedsOutputs)
void setType(MotorMessage::MessageTypes type)
void callbackU(const std_msgs::UInt32 &data)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
int deserialize(const RawMotorMessage &serialized)
ROSCPP_DECL void spinOnce()