27 #ifndef UR_CONTROLLERS_SCALED_TRAJECTORY_CONTROLLER_H_INCLUDED 28 #define UR_CONTROLLERS_SCALED_TRAJECTORY_CONTROLLER_H_INCLUDED 35 template <
class SegmentImpl,
class HardwareInterface>
53 time_data.
time = time;
68 for (
unsigned int i = 0; i < this->
joints_.size(); ++i)
74 typename Base::TrajectoryPerJoint::const_iterator segment_it =
76 if (curr_traj[i].end() == segment_it)
79 ROS_ERROR_NAMED(this->
name_,
"Unexpected error: No trajectory defined at current time. Please contact the " 104 if (time_data.
uptime.
toSec() < segment_it->endTime())
108 segment_it->getTolerances();
116 rt_segment_goal->preallocated_result_->error_code =
117 control_msgs::FollowJointTrajectoryResult::PATH_TOLERANCE_VIOLATED;
118 rt_segment_goal->setAborted(rt_segment_goal->preallocated_result_);
123 else if (segment_it == --curr_traj[i].end())
127 "Finished executing last segment, checking goal " 135 segment_it->getTolerances();
136 const bool inside_goal_tolerances =
139 if (inside_goal_tolerances)
156 rt_segment_goal->preallocated_result_->error_code =
157 control_msgs::FollowJointTrajectoryResult::GOAL_TOLERANCE_VIOLATED;
158 rt_segment_goal->setAborted(rt_segment_goal->preallocated_result_);
170 current_active_goal->preallocated_result_->error_code = control_msgs::FollowJointTrajectoryResult::SUCCESSFUL;
171 current_active_goal->setSucceeded(current_active_goal->preallocated_result_);
172 current_active_goal.reset();
181 if (current_active_goal)
183 current_active_goal->preallocated_feedback_->header.stamp = this->
time_data_.readFromRT()->time;
184 current_active_goal->preallocated_feedback_->desired.positions = this->
desired_state_.position;
185 current_active_goal->preallocated_feedback_->desired.velocities = this->
desired_state_.velocity;
186 current_active_goal->preallocated_feedback_->desired.accelerations = this->
desired_state_.acceleration;
187 current_active_goal->preallocated_feedback_->actual.positions = this->
current_state_.position;
188 current_active_goal->preallocated_feedback_->actual.velocities = this->
current_state_.velocity;
189 current_active_goal->preallocated_feedback_->error.positions = this->
state_error_.position;
190 current_active_goal->preallocated_feedback_->error.velocities = this->
state_error_.velocity;
191 current_active_goal->setFeedback(current_active_goal->preallocated_feedback_);
207 #endif // ifndef UR_CONTROLLERS_SCALED_TRAJECTORY_CONTROLLER_H_INCLUDED Segment::State current_state_
StateTolerances< Scalar > state_tolerance
#define ROS_ERROR_STREAM_NAMED(name, args)
Segment::State state_error_
HwIfaceAdapter hw_iface_adapter_
Segment::State desired_joint_state_
Trajectory::const_iterator sample(const Trajectory &trajectory, const typename Trajectory::value_type::Time &time, typename Trajectory::value_type::State &state)
std::vector< TrajectoryPerJoint > Trajectory
ScaledJointTrajectoryController()=default
Segment::State desired_state_
virtual ~ScaledJointTrajectoryController()=default
bool checkStateTolerancePerJoint(const State &state_error, const StateTolerances< typename State::Scalar > &state_tolerance, bool show_errors=false)
Scalar goal_time_tolerance
std::vector< JointHandle > joints_
void publishState(const ros::Time &time)
StateTolerances< Scalar > goal_state_tolerance
void update(const ros::Time &time, const ros::Duration &period)
RealtimeGoalHandlePtr rt_active_goal_
void updateCommand(const ros::Time &, const ros::Duration &, const typename Segment::State &, const typename Segment::State &)
Segment::State state_joint_error_
std::shared_ptr< Trajectory > TrajectoryPtr
realtime_tools::RealtimeBuffer< TimeData > time_data_
std::vector< std::string > joint_names_
boost::dynamic_bitset successful_joint_traj_
#define ROS_ERROR_NAMED(name,...)
#define ROS_DEBUG_STREAM_THROTTLE_NAMED(period, name, args)
def shortest_angular_distance(from_angle, to_angle)
TrajectoryBox curr_trajectory_box_