@@ -63,16 +63,15 @@ class TrajectoryPointInterfaceTest : public ::testing::Test
6363 int32_t & blend_radius_or_spline_type, int32_t & motion_type)
6464 {
6565 // Read message
66- uint8_t buf[sizeof (int32_t ) * 21 ];
66+ uint8_t buf[sizeof (int32_t ) * urcl::control::TrajectoryPointInterface::MESSAGE_LENGTH ];
6767 uint8_t * b_pos = buf;
6868 size_t read = 0 ;
69- size_t remainder = sizeof (int32_t ) * 21 ;
69+ size_t remainder = sizeof (int32_t ) * urcl::control::TrajectoryPointInterface::MESSAGE_LENGTH ;
7070 while (remainder > 0 )
7171 {
7272 if (!TCPSocket::read (b_pos, remainder, read))
7373 {
74- std::cout << " Failed to read from socket, this should not happen during a test!" << std::endl;
75- break ;
74+ throw (std::runtime_error (" Failed to read from socket, this should not happen during a test!" ));
7675 }
7776 b_pos += read;
7877 remainder -= read;
@@ -135,6 +134,14 @@ class TrajectoryPointInterfaceTest : public ::testing::Test
135134 return vel;
136135 }
137136
137+ vector6int32_t getAcceleration ()
138+ {
139+ int32_t goal_time, blend_radius_or_spline_type, motion_type;
140+ vector6int32_t pos, vel, acc;
141+ readMessage (pos, vel, acc, goal_time, blend_radius_or_spline_type, motion_type);
142+ return acc;
143+ }
144+
138145 int32_t getGoalTime ()
139146 {
140147 int32_t goal_time, blend_radius_or_spline_type, motion_type;
@@ -218,13 +225,13 @@ class TrajectoryPointInterfaceTest : public ::testing::Test
218225private:
219226 std::condition_variable trajectory_end_;
220227 std::mutex trajectory_end_mutex_;
221- control::TrajectoryResult result_;
228+ control::TrajectoryResult result_ = control::TrajectoryResult::TRAJECTORY_RESULT_UNKNOWN ;
222229};
223230
224231TEST_F (TrajectoryPointInterfaceTest, write_postions)
225232{
226233 urcl::vector6d_t send_positions = { 1.2 , 3.1 , 2.2 , -3.4 , -1.1 , -1.2 };
227- traj_point_interface_->writeTrajectoryPoint (&send_positions, 0 , 0 , 0 );
234+ traj_point_interface_->writeTrajectoryPoint (&send_positions, 0 , 0 , false );
228235 vector6int32_t received_positions = client_->getPosition ();
229236
230237 EXPECT_EQ (send_positions[0 ], ((double )received_positions[0 ]) / traj_point_interface_->MULT_JOINTSTATE );
@@ -361,17 +368,38 @@ TEST_F(TrajectoryPointInterfaceTest, write_goal_time)
361368{
362369 urcl::vector6d_t send_positions = { 0 , 0 , 0 , 0 , 0 , 0 };
363370 float send_goal_time = 0.5 ;
364- traj_point_interface_->writeTrajectoryPoint (&send_positions, send_goal_time, 0 , 0 );
371+ traj_point_interface_->writeTrajectoryPoint (&send_positions, send_goal_time, 0 , false );
372+ int32_t received_goal_time = client_->getGoalTime ();
373+
374+ EXPECT_EQ (send_goal_time, ((float )received_goal_time) / traj_point_interface_->MULT_TIME );
375+ }
376+
377+ TEST_F (TrajectoryPointInterfaceTest, write_acceleration_velocity)
378+ {
379+ urcl::vector6d_t send_positions = { 0 , 0 , 0 , 0 , 0 , 0 };
380+ float send_move_acceleration = 0.123 ;
381+ float send_move_velocity = 0.456 ;
382+ float send_goal_time = 0.5 ;
383+ traj_point_interface_->writeTrajectoryPoint (&send_positions, send_move_acceleration, send_move_velocity,
384+ send_goal_time, 0 , 0 );
385+ int32_t received_move_acceleration = client_->getAcceleration ()[0 ];
386+ traj_point_interface_->writeTrajectoryPoint (&send_positions, send_move_acceleration, send_move_velocity,
387+ send_goal_time, 0 , 0 );
388+ int32_t received_move_velocity = client_->getVelocity ()[0 ];
389+ traj_point_interface_->writeTrajectoryPoint (&send_positions, send_move_acceleration, send_move_velocity,
390+ send_goal_time, 0 , 0 );
365391 int32_t received_goal_time = client_->getGoalTime ();
366392
393+ EXPECT_EQ (send_move_acceleration, ((float )received_move_acceleration) / traj_point_interface_->MULT_JOINTSTATE );
394+ EXPECT_EQ (send_move_velocity, ((float )received_move_velocity) / traj_point_interface_->MULT_JOINTSTATE );
367395 EXPECT_EQ (send_goal_time, ((float )received_goal_time) / traj_point_interface_->MULT_TIME );
368396}
369397
370398TEST_F (TrajectoryPointInterfaceTest, write_blend_radius)
371399{
372400 urcl::vector6d_t send_positions = { 0 , 0 , 0 , 0 , 0 , 0 };
373401 float send_blend_radius = 0.5 ;
374- traj_point_interface_->writeTrajectoryPoint (&send_positions, 0 , send_blend_radius, 0 );
402+ traj_point_interface_->writeTrajectoryPoint (&send_positions, 0 , send_blend_radius, false );
375403 int32_t received_blend_radius = client_->getBlendRadius ();
376404
377405 EXPECT_EQ (send_blend_radius, ((float )received_blend_radius) / traj_point_interface_->MULT_TIME );
0 commit comments