Skip to content

Commit

Permalink
Add conversion tests
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
shiveshkhaitan committed Aug 8, 2019
1 parent 04802ec commit eab66ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace gazebo_plugins
class GazeboRosJointPoseTrajectoryPrivate;

/// Set the trajectory of points to be followed by joints in simulation.
/// Currently only positions specified in the trajectory_msgs are handled.
/**
Example Usage:
\code{.xml}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gazebo ROS joint pose trajectory plugin demo
Try for example:
ros2 topic pub /demo/set_trajectory_demo trajectory_msgs/msg/JointTrajectory
ros2 topic pub /demo/set_trajectory_demo trajectory_msgs/msg/JointTrajectory \
'{header: {frame_id: world}, joint_names: {upper_joint}, points: [{positions: {-1.57}}]}'
-->
<sdf version="1.6">
Expand Down
17 changes: 17 additions & 0 deletions gazebo_ros/test/test_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ TEST(TestConversions, Time)
auto time_msg = gazebo_ros::Convert<builtin_interfaces::msg::Time>(time);
EXPECT_EQ(200, time_msg.sec);
EXPECT_EQ(100u, time_msg.nanosec);

// to Gazebo time
auto gazebo_time = gazebo_ros::Convert<gazebo::common::Time>(time_msg);
EXPECT_EQ(200, gazebo_time.sec);
EXPECT_EQ(100, gazebo_time.nsec);
}

// Gazebo msg
Expand All @@ -100,6 +105,18 @@ TEST(TestConversions, Time)
EXPECT_EQ(200, time_msg.sec);
EXPECT_EQ(100u, time_msg.nanosec);
}

// ROS Duration
{
auto duration = builtin_interfaces::msg::Duration();
duration.sec = 200;
duration.nanosec = 100u;

// to Gazebo time
auto gazebo_time = gazebo_ros::Convert<gazebo::common::Time>(duration);
EXPECT_EQ(200, gazebo_time.sec);
EXPECT_EQ(100, gazebo_time.nsec);
}
}

int main(int argc, char ** argv)
Expand Down

0 comments on commit eab66ae

Please sign in to comment.