38 namespace joint_trajectory_streamer
42 const std::map<std::string, double> &velocity_limits)
46 ROS_INFO(
"JointTrajectoryStreamer: init");
68 ROS_INFO(
"Receiving joint trajectory message");
76 if (msg->points.empty())
77 ROS_INFO(
"Empty trajectory received, canceling current trajectory");
79 ROS_ERROR(
"Trajectory splicing not yet implemented, stopping current motion.");
87 if (msg->points.empty())
89 ROS_INFO(
"Empty trajectory received while in IDLE state, nothing is done");
94 std::vector<JointTrajPtMessage> new_traj_msgs;
104 ROS_INFO(
"Loading trajectory, setting state to streaming");
107 ROS_INFO(
"Executing trajectory of size: %d", (
int)messages.size());
129 msgs->push_back(msgs->back());
139 int connectRetryCount = 1;
141 ROS_INFO(
"Starting joint trajectory streamer thread");
147 if (connectRetryCount-- > 0)
149 ROS_INFO(
"Connecting to robot motion server");
154 connectRetryCount = 0;
155 else if (connectRetryCount <= 0)
157 ROS_ERROR(
"Timeout connecting to robot controller. Send new motion command to retry.");
176 ROS_INFO(
"Trajectory streaming complete, setting state to IDLE");
183 ROS_DEBUG(
"Robot disconnected. Attempting reconnect...");
184 connectRetryCount = 5;
191 ROS_DEBUG(
"Sending joint trajectory point");
195 ROS_INFO(
"Point[%d of %d] sent to controller",
199 ROS_WARN(
"Failed sent joint point, will try again");
203 ROS_ERROR(
"Joint trajectory streamer: unknown state");
211 ROS_WARN(
"Exiting trajectory streamer thread");
218 ROS_DEBUG(
"Stop command sent, entering idle mode");
SmplMsgConnection * connection_
virtual bool toRequest(industrial::simple_message::SimpleMessage &msg)
void trajectoryStop()
Send a stop command to the robot.
ros::Time streaming_start_
bool sendAndReceiveMsg(industrial::simple_message::SimpleMessage &send, industrial::simple_message::SimpleMessage &recv, bool verbose=false)
bool send_to_robot(const std::vector< JointTrajPtMessage > &messages)
Send trajectory to robot, using this node's robot-connection. Specific method must be implemented in ...
virtual bool init(std::string default_ip="", int default_port=StandardSocketPorts::MOTION)
Initialize robot connection using default method.
virtual void trajectoryStop()
Send a stop command to the robot.
virtual bool init(SmplMsgConnection *connection, const std::vector< std::string > &joint_names, const std::map< std::string, double > &velocity_limits=std::map< std::string, double >())
Class initializer.
virtual bool isConnected()=0
virtual void jointTrajectoryCB(const trajectory_msgs::JointTrajectoryConstPtr &msg)
Callback function registered to ROS topic-subscribe. Transform message into SimpleMessage objects and...
std::vector< JointTrajPtMessage > current_traj_
~JointTrajectoryStreamer()
boost::thread * streaming_thread_
virtual bool trajectory_to_msgs(const trajectory_msgs::JointTrajectoryConstPtr &traj, std::vector< JointTrajPtMessage > *msgs)
Convert ROS trajectory message into stream of JointTrajPtMessages for sending to robot. Also includes various joint transforms that can be overridden for robot-specific behavior.
virtual bool trajectory_to_msgs(const trajectory_msgs::JointTrajectoryConstPtr &traj, std::vector< JointTrajPtMessage > *msgs)
Convert ROS trajectory message into stream of JointTrajPtMessages for sending to robot. Also includes various joint transforms that can be overridden for robot-specific behavior.
virtual bool makeConnect()=0