23 #include <sensor_msgs/JointState.h> 24 #include <sensor_msgs/PointCloud2.h> 25 #include <visualization_msgs/MarkerArray.h> 35 int main(
int argc,
char** argv)
40 std::cerr << std::endl;
41 std::cerr <<
"usage:" << std::endl;
42 std::cerr <<
" viz calibration_data.bag [offsets.yaml]" << std::endl;
43 std::cerr << std::endl;
46 std::string bag_name = argv[1];
49 ros::init(argc, argv,
"robot_calibration_viz");
53 std_msgs::String description_msg;
54 std::vector<robot_calibration_msgs::CalibrationData> data;
71 ROS_FATAL(
"Failed to construct KDL tree");
82 std::map<std::string, robot_calibration::ChainModel*> models;
83 std::map<std::string, ros::Publisher> camera_pubs;
84 std::vector<std::string> model_names;
85 for (
size_t i = 0; i < params.
models.size(); ++i)
87 if (params.
models[i].type ==
"chain")
91 params.
models[i].params[
"frame"]);
93 models[params.
models[i].name] = model;
94 model_names.push_back(params.
models[i].name);
96 else if (params.
models[i].type ==
"camera3d")
99 params.
models[i].params[
"frame"]);
101 models[params.
models[i].name] = model;
102 model_names.push_back(params.
models[i].name);
103 camera_pubs[params.
models[i].name] = nh.
advertise<sensor_msgs::PointCloud2>(params.
models[i].name, 1);
112 std::vector<std_msgs::ColorRGBA> model_colors;
115 std_msgs::ColorRGBA color;
120 model_colors.push_back(color);
121 while (model_colors.size() < model_names.size() + 1)
124 std_msgs::ColorRGBA color;
129 model_colors.push_back(color);
135 model_colors.push_back(color);
141 model_colors.push_back(color);
146 for (
size_t i = 0; i < params.
free_params.size(); ++i)
150 for (
size_t i = 0; i < params.
free_frames.size(); ++i)
178 std::string offsets_yaml = argv[2];
181 ROS_FATAL(
"Unable to load offsets from YAML");
191 for (
size_t i = 0; i < data.size(); ++i)
198 visualization_msgs::MarkerArray markers;
199 for (
size_t m = 0; m < model_names.size(); ++m)
202 std::vector<geometry_msgs::PointStamped> points;
203 points = models[model_names[m]]->project(data[i], offsets);
206 visualization_msgs::Marker msg;
209 msg.ns = model_names[m];
211 msg.type = msg.SPHERE_LIST;
212 msg.pose.orientation.w = 1.0;
216 msg.points.push_back(points[0].point);
217 msg.colors.push_back(model_colors[0]);
218 for (
size_t p = 1; p < points.size(); ++p)
220 msg.points.push_back(points[p].point);
221 msg.colors.push_back(model_colors[m+1]);
223 markers.markers.push_back(msg);
225 pub.publish(markers);
228 sensor_msgs::JointState state_msg = data[i].joint_states;
229 for (
size_t j = 0; j < state_msg.name.size(); ++j)
231 double offset = offsets.
get(state_msg.name[j]);
232 state_msg.position[j] += offset;
237 for (
size_t obs = 0; obs < data[i].observations.size(); ++obs)
239 if (data[i].observations[obs].cloud.height != 0)
241 auto pub = camera_pubs.find(data[i].observations[obs].sensor_name);
242 if (pub != camera_pubs.end())
244 pub->second.publish(data[i].observations[obs].cloud);
250 std::cout <<
"Press enter to continue...";
251 std::string throwaway;
252 std::getline(std::cin, throwaway);
void publish(const boost::shared_ptr< M > &message) const
URDF_EXPORT bool initString(const std::string &xmlstring)
KDL_PARSER_PUBLIC bool treeFromUrdfModel(const urdf::ModelInterface &robot_model, KDL::Tree &tree)
Class to hold parameters for optimization.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::vector< FreeFrameInitialValue > free_frames_initial_values
Combined parser and configuration for calibration offsets. Holds the configuration of what is to be c...
std::vector< std::string > free_params
bool LoadFromROS(ros::NodeHandle &nh)
bool add(const std::string name)
Tell the parser we wish to calibrate an active joint or other single parameter.
bool setFrame(const std::string name, double x, double y, double z, double roll, double pitch, double yaw)
Set the values for a frame.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
double get(const std::string name) const
Get the offset.
bool addFrame(const std::string name, bool calibrate_x, bool calibrate_y, bool calibrate_z, bool calibrate_roll, bool calibrate_pitch, bool calibrate_yaw)
Tell the parser we wish to calibrate a fixed joint.
std::vector< FreeFrameParams > free_frames
Model of a camera on a kinematic chain.
std::vector< Params > models
bool load_bag(const std::string &file_name, std_msgs::String &description_msg, std::vector< robot_calibration_msgs::CalibrationData > &data)
Load a bagfile of calibration data.
int main(int argc, char **argv)
#define ROS_INFO_STREAM(args)
#define ROS_ERROR_STREAM(args)
bool loadOffsetYAML(const std::string &filename)
Load all the current offsets from a YAML.
Model of a kinematic chain. This is the basic instance where we transform the world observations into...