1 #include "gtest/gtest.h" 5 #define protected public 13 class PacketTests :
public ::testing::Test {
15 virtual void SetUp() {
36 TEST_F(PacketTests, IgnoresChannelB) {
39 segway_rmp->ParsePacket_(pck, ss);
41 ASSERT_FALSE(ss->touched);
44 TEST_F(PacketTests, IgnoresCommandRequest) {
45 segway_rmp->ParsePacket_(pck,ss);
47 ASSERT_FALSE(ss->touched);
50 TEST_F(PacketTests, ParsesPitchRollCorrectly) {
61 segway_rmp->ParsePacket_(pck,ss);
62 EXPECT_TRUE(ss->touched);
63 EXPECT_NEAR(-0.897,ss->pitch,0.128);
64 EXPECT_NEAR(1.923,ss->pitch_rate,0.128);
65 EXPECT_NEAR(-0.128,ss->roll,0.128);
66 EXPECT_NEAR(1.154,ss->roll_rate,0.128);
69 TEST_F(PacketTests, ParsesWheelSpeedsYawRatesServoFramesCorrectly) {
80 segway_rmp->ParsePacket_(pck,ss);
81 EXPECT_TRUE(ss->touched);
82 EXPECT_NEAR(0.0361,ss->left_wheel_speed,0.003);
83 EXPECT_NEAR(-0.0422,ss->right_wheel_speed,0.003);
84 EXPECT_NEAR(9.6154,ss->yaw_rate,0.128);
85 EXPECT_NEAR(63.56,ss->servo_frames,0.01);
88 TEST_F(PacketTests, ParsesIntegratedWheelsCorrectly) {
99 segway_rmp->ParsePacket_(pck,ss);
100 EXPECT_TRUE(ss->touched);
101 EXPECT_NEAR(-0.0152341,ss->integrated_left_wheel_position,0.00003);
102 EXPECT_NEAR(0.0023784,ss->integrated_right_wheel_position,0.00003);
105 TEST_F(PacketTests, ParsesIntegratedDistanceTurnCorrectly) {
120 segway_rmp->ParsePacket_(pck,ss);
121 EXPECT_TRUE(ss->touched);
122 EXPECT_NEAR(-0.0300768,ss->integrated_forward_position,0.00003);
123 EXPECT_NEAR(-0.268452,ss->integrated_turn_position,0.00001);
126 TEST_F(PacketTests, ParsesMotorTorqueCorrectly) {
139 segway_rmp->ParsePacket_(pck,ss);
140 EXPECT_TRUE(ss->touched);
141 EXPECT_NEAR(-0.006399,ss->left_motor_torque,0.0009);
142 EXPECT_NEAR(0.152651,ss->right_motor_torque,0.0009);
145 TEST_F(PacketTests, ParsesStatusesCorrectly) {
157 segway_rmp->ParsePacket_(pck,ss);
158 EXPECT_TRUE(ss->touched);
161 EXPECT_NEAR(9.325,ss->ui_battery_voltage,0.25);
162 EXPECT_NEAR(78.0,ss->powerbase_battery_voltage,0.25);
169 int main(
int argc,
char **argv) {
170 ::testing::InitGoogleTest(&argc, argv);
171 return RUN_ALL_TESTS();
boost::shared_ptr< SegwayStatus > Ptr
int main(int argc, char **argv)