1 #include "urdf_parser/urdf_parser.h" 8 #include <geometry_msgs/PoseArray.h> 20 std::shared_ptr<interactive_markers::InteractiveMarkerServer>
server_;
37 typedef std::shared_ptr<UrdfModelMarker>
umm_ptr;
43 std_msgs::Header
header = msg->header;
44 geometry_msgs::PoseStamped ps;
47 int msg_size = msg->poses.size();
48 int umm_vec_size = umm_vec_.
size();
50 if (msg_size <= umm_vec_size) {
51 for (
int i = 0; i < msg_size; i++) {
53 ps.pose = msg->poses[i];
54 umm_vec_[i]->setRootPose(ps);
56 for (
int i = msg_size; i< umm_vec_size; i++) {
58 ps.pose.position.x = ps.pose.position.y = ps.pose.position.z = 1000000;
59 ps.pose.orientation.w = 1;
60 umm_vec_[i]->setRootPose(ps);
64 for (
int i = 0; i < umm_vec_size; i++) {
66 ps.pose = msg->poses[i];
67 umm_vec_[i]->setRootPose(ps);
69 for (
int i = umm_vec_size; i < msg_size; i++) {
71 ps.pose = msg->poses[i];
72 umm_vec_.push_back(umm_ptr(
new UrdfModelMarker(model_name_, model_description_, model_file_, header.frame_id, ps, root_offset_, scale_factor_, mode_ , robot_mode_, registration_,fixed_link_, use_robot_description_, use_visible_color_, initial_pose_map_, i, server_)));
79 model_name_.assign(model_config_[
"name"]);
82 model_description_ =
"";
83 if (model_config_.
hasMember(
"description")) {
84 model_description_.assign(model_config_[
"description"]);
89 scale_factor_ =
getXmlValue(model_config_[
"scale"]);
93 pose_stamped_.pose =
getPose(model_config_[
"pose"]);
96 pose_stamped_.pose = geometry_msgs::Pose();
97 pose_stamped_.pose.orientation.w = 1.0;
102 root_offset_ =
getPose(model_config_[
"offset"]);
105 root_offset_ = geometry_msgs::Pose();
106 root_offset_.orientation.w = 1.0;
110 use_visible_color_ =
false;
111 if (model_config_.
hasMember(
"use_visible_color")) {
112 use_visible_color_ = model_config_[
"use_visible_color"];
116 frame_id_.assign(model_config_[
"frame-id"]);
121 registration_ =
false;
122 if (model_config_.
hasMember(
"registration")) {
123 registration_ = model_config_[
"registration"];
124 mode_ =
"registration";
127 if (model_config_.
hasMember(
"fixed_link")) {
130 fixed_link_.push_back( fixed_links );
133 for(
int i=0; i< fixed_links.
size(); i++) {
134 fixed_link_.push_back(fixed_links[i]);
140 model_file_.assign(model_config_[
"model"]);
142 use_robot_description_ =
false;
143 if (model_config_.
hasMember(
"use_robot_description")) {
144 model_file_ =
"/robot_description";
145 use_robot_description_ = model_config_[
"use_robot_description"];
147 if (model_config_.
hasMember(
"model_param")) {
148 use_robot_description_ =
true;
149 model_file_.assign(model_config_[
"model_param"]);
151 if (model_config_[
"robot"]) {
155 mode_.assign(model_config_[
"mode"]);
158 robot_mode_ = model_config_[
"robot"];
161 if (model_config_.
hasMember(
"initial_joint_state")) {
163 for(
int i=0; i< initial_pose.
size(); i++) {
168 name.assign(v[
"name"]);
170 initial_pose_map_[name] = position;
176 if (model_config_.
hasMember(
"display")) {
177 display_ = model_config_[
"display"];
183 ROS_INFO(
"model_name: %s", model_name_.c_str());
184 ROS_INFO(
"model_description: %s", model_description_.c_str());
185 ROS_INFO(
"scale_factor: %f", scale_factor_);
199 new UrdfModelMarker(model_name_, model_description_, model_file_, frame_id_, pose_stamped_ ,root_offset_, scale_factor_, mode_ , robot_mode_, registration_,fixed_link_, use_robot_description_, use_visible_color_,initial_pose_map_, -1, server_);
203 model_config_ = model;
216 int main(
int argc,
char** argv)
218 ros::init(argc, argv,
"jsk_model_marker_interface");
223 pnh_.
param(
"server_name", server_name, std::string (
"") );
224 if (server_name ==
"") {
228 std::shared_ptr<interactive_markers::InteractiveMarkerServer>
server;
232 pnh_.
param(
"model_config", v, v);
233 for (
int i=0; i< v.
size(); i++) {
ros::Subscriber display_marker_sub_
vector< umm_ptr > umm_vec
bool use_robot_description_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server_
int main(int argc, char **argv)
geometry_msgs::PoseStamped pose_stamped_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
map< string, double > initial_pose_map_
Type const & getType() const
ROSCPP_DECL void spin(Spinner &spinner)
UrdfModelSettings(XmlRpc::XmlRpcValue model, std::shared_ptr< interactive_markers::InteractiveMarkerServer > server)
geometry_msgs::Pose root_offset_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void displayMarkerArrayCB(const geometry_msgs::PoseArrayConstPtr &msg)
std::shared_ptr< UrdfModelMarker > umm_ptr
vector< string > fixed_link_
bool hasMember(const std::string &name) const
XmlRpc::XmlRpcValue model_config_
#define ROS_INFO_STREAM(args)
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server
string model_description_