5 #include <ram_msgs/AdditiveManufacturingTrajectory.h> 6 #include <ram_trajectory_buffer/BufferParams.h> 7 #include <ram_trajectory_buffer/UnmodifiedTrajectory.h> 22 std::vector<ram_msgs::AdditiveManufacturingTrajectory>
msgs;
86 ram_trajectory_buffer::BufferParams::Response &res)
90 ram_msgs::AdditiveManufacturingTrajectory trajectory;
91 switch (req.button_id)
99 res.error =
"Start of the buffer";
109 res.error =
"End of the buffer";
127 ram_trajectory_buffer::UnmodifiedTrajectory::Response &res)
132 if (msg.generated == req.generated)
134 res.trajectory = msg;
149 bool error_in_first_bag =
false;
150 bool error_in_second_bag =
false;
156 std::vector<std::string> topics;
157 topics.push_back(std::string(
"ram/trajectory"));
163 ram_msgs::AdditiveManufacturingTrajectory::ConstPtr
s =
164 m.instantiate<ram_msgs::AdditiveManufacturingTrajectory>();
177 std::string file(getenv(
"HOME"));
178 file +=
"/.ros/ram_buffer_trajectory.bag";
180 if (std::remove(file.c_str()) == 0)
183 error_in_first_bag =
true;
190 std::vector<std::string> topics;
191 topics.push_back(std::string(
"ram/trajectory"));
197 ram_msgs::AdditiveManufacturingTrajectory::ConstPtr
s =
198 m.instantiate<ram_msgs::AdditiveManufacturingTrajectory>();
209 std::string file(getenv(
"HOME"));
210 file +=
"/.ros/ram_buffer_unmodified_trajectory.bag";
212 if (std::remove(file.c_str()) == 0)
215 error_in_second_bag =
true;
218 if (error_in_first_bag || error_in_second_bag)
225 pub = nh.
advertise<ram_msgs::AdditiveManufacturingTrajectory>(
"ram/trajectory",
msg_to_keep,
true);
void publish(const boost::shared_ptr< M > &message) const
void open(std::string const &filename, uint32_t mode=bagmode::Read)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
std::vector< ram_msgs::AdditiveManufacturingTrajectory > msgs
void saveTrajectoryCallback(const ros::MessageEvent< ram_msgs::AdditiveManufacturingTrajectory > &msg_event)
void mySigintHandler(int)
const std::string & getPublisherName() const
bool trajectoryBufferCallback(ram_trajectory_buffer::BufferParams::Request &req, ram_trajectory_buffer::BufferParams::Response &res)
std::mutex unmodified_msgs_mutex
std::shared_ptr< ros::NodeHandle > nh
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_WARN_STREAM(args)
int main(int argc, char **argv)
bool getUnmodifiedTrajectoryCallback(ram_trajectory_buffer::UnmodifiedTrajectory::Request &req, ram_trajectory_buffer::UnmodifiedTrajectory::Response &res)
ROSCPP_DECL void shutdown()
const unsigned msg_to_keep(10)
std::vector< ram_msgs::AdditiveManufacturingTrajectory > unmodified_msgs
void write(std::string const &topic, ros::MessageEvent< T > const &event)
boost::shared_ptr< M > getMessage() const
ROSCPP_DECL void waitForShutdown()
unsigned last_msg_published