Robowflex  v0.1
Making MoveIt Easy
ur5_io.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
7 
8 using namespace robowflex;
9 
10 /* \file ur5_io.cpp
11  * Simple test of IO::Bag for loading and saving messages.
12  */
13 
14 int main(int argc, char **argv)
15 {
16  // Startup ROS
17  ROS ros(argc, argv);
18 
19  // Create the default UR5 robot.
20  auto ur5 = std::make_shared<UR5Robot>();
21  ur5->initialize();
22 
23  // Load a scene from a file.
24  auto scene = std::make_shared<Scene>(ur5);
25  scene->fromYAMLFile("package://robowflex_library/yaml/test.yml");
26 
27  // Output scene to a rosbag file.
28  {
29  IO::Bag bag_out("scene.bag", IO::Bag::WRITE);
30  bag_out.addMessage("scene", scene->getMessage());
31  }
32 
33  // Load the same scene from the rosbag file.
34  {
35  IO::Bag bag_in("scene.bag", IO::Bag::READ);
36 
37  // Load all `moveit_msgs::PlanningScene` from the topic `scene`.
38  auto msgs = bag_in.getMessages<moveit_msgs::PlanningScene>({"scene"});
39  }
40 
41  return 0;
42 }
rosbag management class to ease message saving and loading.
Definition: bag.h:23
@ WRITE
Write-only.
Definition: bag.h:30
@ READ
Read-only.
Definition: bag.h:29
bool addMessage(const std::string &topic, const T &msg)
Adds a message to the bag under topic.
Definition: bag.h:50
std::vector< T > getMessages(const std::vector< std::string > &topics)
Gets messages from an opened bag. Returns all messages of type T from a list of topics topics.
Definition: bag.h:67
RAII-pattern for starting up ROS.
Definition: util.h:52
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
Functions for loading and animating scenes in Blender.
int main(int argc, char **argv)
Definition: ur5_io.cpp:14