Skip to content

Commit 926392f

Browse files
Backport changes from #753
1 parent 6d9504e commit 926392f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

example_7/controller/r6bot_controller.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ void interpolate_trajectory_point(
138138
const trajectory_msgs::msg::JointTrajectory & traj_msg, const rclcpp::Duration & cur_time,
139139
trajectory_msgs::msg::JointTrajectoryPoint & point_interp)
140140
{
141-
double traj_len = traj_msg.points.size();
142-
auto last_time = traj_msg.points[traj_len - 1].time_from_start;
141+
double traj_len = static_cast<double>(traj_msg.points.size());
142+
auto last_time = traj_msg.points.back().time_from_start;
143143
double total_time = last_time.sec + last_time.nanosec * 1E-9;
144144

145-
size_t ind = cur_time.seconds() * (traj_len / total_time);
146-
ind = std::min(static_cast<double>(ind), traj_len - 2);
147-
double delta = cur_time.seconds() - ind * (total_time / traj_len);
145+
size_t ind = static_cast<size_t>(cur_time.seconds() * (traj_len / total_time));
146+
ind = std::min(ind, static_cast<size_t>(traj_len) - 2);
147+
double delta = cur_time.seconds() - static_cast<double>(ind) * (total_time / traj_len);
148148
interpolate_point(traj_msg.points[ind], traj_msg.points[ind + 1], point_interp, delta);
149149
}
150150

example_7/reference_generator/send_trajectory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main(int argc, char ** argv)
4848

4949
trajectory_msgs::msg::JointTrajectory trajectory_msg;
5050
trajectory_msg.header.stamp = node->now();
51-
for (size_t i = 0; i < chain.getNrOfSegments(); i++)
51+
for (unsigned int i = 0; i < chain.getNrOfSegments(); i++)
5252
{
5353
auto joint = chain.getSegment(i).getJoint();
5454
if (joint.getType() != KDL::Joint::Fixed)
@@ -63,7 +63,7 @@ int main(int argc, char ** argv)
6363

6464
double total_time = 3.0;
6565
int trajectory_len = 200;
66-
int loop_rate = trajectory_len / total_time;
66+
int loop_rate = static_cast<int>(std::round(trajectory_len / total_time));
6767
double dt = 1.0 / loop_rate;
6868

6969
for (int i = 0; i < trajectory_len; i++)

0 commit comments

Comments
 (0)