joint_trajectory_downloader.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Southwest Research Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
33 
35 {
36 namespace joint_trajectory_downloader
37 {
38 
41 
42 bool JointTrajectoryDownloader::send_to_robot(const std::vector<JointTrajPtMessage>& messages)
43 {
44  bool rslt=true;
45  std::vector<JointTrajPtMessage> points(messages);
46  SimpleMessage msg;
47 
48  // Trajectory download requires at least two points (START/END)
49  if (points.size() < 2)
50  points.push_back(JointTrajPtMessage(points[0]));
51 
52  // The first and last points are assigned special sequence values
53  points.begin()->setSequence(SpecialSeqValues::START_TRAJECTORY_DOWNLOAD);
54  points.back().setSequence(SpecialSeqValues::END_TRAJECTORY);
55 
56  if (!this->connection_->isConnected())
57  {
58  ROS_WARN("Attempting robot reconnection");
59  this->connection_->makeConnect();
60  }
61 
62  ROS_INFO("Sending trajectory points, size: %d", (int)points.size());
63 
64  for (int i = 0; i < (int)points.size(); ++i)
65  {
66  ROS_DEBUG("Sending joints trajectory point[%d]", i);
67 
68  points[i].toTopic(msg);
69  bool ptRslt = this->connection_->sendMsg(msg);
70  if (ptRslt)
71  ROS_DEBUG("Point[%d] sent to controller", i);
72  else
73  ROS_WARN("Failed sent joint point, skipping point");
74 
75  rslt &= ptRslt;
76  }
77 
78  return rslt;
79 }
80 
81 } //joint_trajectory_downloader
82 } //industrial_robot_client
83 
industrial_robot_client::joint_trajectory_interface::JointTrajectoryInterface::connection_
SmplMsgConnection * connection_
Definition: joint_trajectory_interface.h:246
joint_trajectory_downloader.h
ROS_DEBUG
#define ROS_DEBUG(...)
industrial::joint_traj_pt::SpecialSeqValues
industrial::simple_message::SimpleMessage
ROS_WARN
#define ROS_WARN(...)
industrial::smpl_msg_connection::SmplMsgConnection::isConnected
virtual bool isConnected()=0
industrial_robot_client::joint_trajectory_downloader::JointTrajectoryDownloader::send_to_robot
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 ...
Definition: joint_trajectory_downloader.cpp:42
industrial::smpl_msg_connection::SmplMsgConnection::makeConnect
virtual bool makeConnect()=0
industrial_robot_client
Definition: joint_relay_handler.h:46
industrial::joint_traj_pt_message::JointTrajPtMessage
ROS_INFO
#define ROS_INFO(...)
industrial::smpl_msg_connection::SmplMsgConnection::sendMsg
virtual bool sendMsg(industrial::simple_message::SimpleMessage &message)


industrial_robot_client
Author(s): Jeremy Zoss
autogenerated on Wed Mar 2 2022 00:24:59