urdf_model_marker.h
Go to the documentation of this file.
1 #ifndef _URDF_MODEL_MARKER_H_
2 #define _URDF_MODEL_MARKER_H_
3 
4 
5 #include <ros/ros.h>
6 
7 #include <tf/tf.h>
10 
12 
14 #include <jsk_interactive_marker/SetPose.h>
15 #include <jsk_interactive_marker/MarkerSetPose.h>
16 
17 #include <math.h>
18 #include <jsk_interactive_marker/MarkerMenu.h>
19 #include <jsk_interactive_marker/MarkerPose.h>
20 #include <jsk_interactive_marker/MoveObject.h>
21 #include <jsk_interactive_marker/MoveModel.h>
22 
23 #include <std_msgs/Int8.h>
24 #include <std_msgs/String.h>
25 #include <std_srvs/Empty.h>
26 #include <sensor_msgs/JointState.h>
27 
28 #include "urdf_parser/urdf_parser.h"
29 #include <iostream>
30 #include <fstream>
31 
34 
35 #include <jsk_recognition_msgs/Int32Stamped.h>
36 
38 
39 #if ROS_VERSION_MINIMUM(1,12,0) // kinetic
40 #include <urdf_model/types.h>
41 #include <urdf_world/types.h>
42 #else
43 namespace urdf {
47 }
48 #endif
49 
50 using namespace urdf;
51 using namespace std;
52 
53 
55  public:
56  // UrdfModelMarker(string file);
57  UrdfModelMarker(string file, std::shared_ptr<interactive_markers::InteractiveMarkerServer> server);
58  UrdfModelMarker(string model_name, string model_description, string model_file, string frame_id, geometry_msgs::PoseStamped root_pose, geometry_msgs::Pose root_offset, double scale_factor, string mode, bool robot_mode, bool registration, vector<string> fixed_link, bool use_robot_description, bool use_visible_color, map<string, double> initial_pose_map, int index, std::shared_ptr<interactive_markers::InteractiveMarkerServer> server);
60 
61  void addMoveMarkerControl(visualization_msgs::InteractiveMarker &int_marker, LinkConstSharedPtr link, bool root);
62  void addInvisibleMeshMarkerControl(visualization_msgs::InteractiveMarker &int_marker, LinkConstSharedPtr link, const std_msgs::ColorRGBA &color);
63  void addGraspPointControl(visualization_msgs::InteractiveMarker &int_marker, std::string link_frame_name_);
64 
65  void publishBasePose( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
66  void publishBasePose( geometry_msgs::Pose pose, std_msgs::Header header);
67  void publishMarkerPose ( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback);
68  void publishMarkerPose ( geometry_msgs::Pose pose, std_msgs::Header header, std::string marker_name);
69  void publishMarkerMenu( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback, int menu );
70  void publishMoveObject( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
71  void publishJointState( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
72  void republishJointState( sensor_msgs::JointState js);
73 
74  void proc_feedback( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback, string parent_frame_id, string frame_id);
75 
76  void graspPoint_feedback( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback, string link_name);
77  void moveCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
78  void setPoseCB();
79  void setPoseCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
80  void hideMarkerCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
81  void hideAllMarkerCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
82 
83  void hideModelMarkerCB( const std_msgs::EmptyConstPtr &msg);
84  void showModelMarkerCB( const std_msgs::EmptyConstPtr &msg);
85  void setUrdfCB( const std_msgs::StringConstPtr &msg);
86 
87  visualization_msgs::InteractiveMarkerControl makeMeshMarkerControl(const std::string &mesh_resource, const geometry_msgs::PoseStamped &stamped, geometry_msgs::Vector3 scale, const std_msgs::ColorRGBA &color, bool use_color);
88  visualization_msgs::InteractiveMarkerControl makeMeshMarkerControl(const std::string &mesh_resource, const geometry_msgs::PoseStamped &stamped, geometry_msgs::Vector3 scale);
89  visualization_msgs::InteractiveMarkerControl makeMeshMarkerControl(const std::string &mesh_resource, const geometry_msgs::PoseStamped &stamped, geometry_msgs::Vector3 scale, const std_msgs::ColorRGBA &color);
90 
91 
92 
93  visualization_msgs::InteractiveMarkerControl makeCylinderMarkerControl(const geometry_msgs::PoseStamped &stamped, double length, double radius, const std_msgs::ColorRGBA &color, bool use_color);
94  visualization_msgs::InteractiveMarkerControl makeBoxMarkerControl(const geometry_msgs::PoseStamped &stamped, Vector3 dim, const std_msgs::ColorRGBA &color, bool use_color);
95  visualization_msgs::InteractiveMarkerControl makeSphereMarkerControl(const geometry_msgs::PoseStamped &stamped, double rad, const std_msgs::ColorRGBA &color, bool use_color);
96  //joint state methods
97  void publishJointState();
98  void getJointState();
99  void getJointState(LinkConstSharedPtr link);
100 
101  void setJointState(LinkConstSharedPtr link, const sensor_msgs::JointStateConstPtr &js);
102  void setJointAngle(LinkConstSharedPtr link, double joint_angle);
103  geometry_msgs::Pose getRootPose(geometry_msgs::Pose pose);
104  geometry_msgs::PoseStamped getOriginPoseStamped();
105  void setOriginalPose(LinkConstSharedPtr link);
106  void addChildLinkNames(LinkConstSharedPtr link, bool root, bool init);
107  void addChildLinkNames(LinkConstSharedPtr link, bool root, bool init, bool use_color, int color_index);
108 
109  void callSetDynamicTf(string parent_frame_id, string frame_id, geometry_msgs::Transform transform);
110  void callPublishTf();
111 
112  int main(string file);
113 
114  void graspPointCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
115  void jointMoveCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
116  void resetMarkerCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
117  void resetBaseMarkerCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
118  void resetBaseMsgCB( const std_msgs::EmptyConstPtr &msg);
119  void resetBaseCB();
120 
121  void resetRobotBase();
122  void resetRootForVisualization();
123  void registrationCB( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
124 
125  void setRootPoseCB( const geometry_msgs::PoseStampedConstPtr &msg );
126  void setRootPose( geometry_msgs::PoseStamped ps);
127  void resetJointStatesCB( const sensor_msgs::JointStateConstPtr &msg, bool update_root);
128  void updateDiagnostic(diagnostic_updater::DiagnosticStatusWrapper &stat);
129  bool lockJointStates(std_srvs::EmptyRequest& req,
130  std_srvs::EmptyRequest& res);
131  bool unlockJointStates(std_srvs::EmptyRequest& req,
132  std_srvs::EmptyRequest& res);
133 
134  protected:
137  std::shared_ptr<interactive_markers::InteractiveMarkerServer> server_;
138 
139  /* diagnostics */
140  std::shared_ptr<diagnostic_updater::Updater> diagnostic_updater_;
143 
144  /* publisher */
153 
154  /* subscriber */
161 
171 
174 
177 
178  std::string server_name;
179  std::string base_frame;
180  std::string move_base_frame;
181  std::string target_frame;
182 
183 
185  std::string model_name_;
186  std::string model_description_;
187  std::string frame_id_;
188  std::string model_file_;
189  geometry_msgs::Pose root_pose_;
190  geometry_msgs::Pose root_pose_origin_;
191  geometry_msgs::Pose root_offset_;
192  geometry_msgs::Pose fixed_link_offset_; //used when fixel_link_ is used
197  string mode_;
201  std::string tf_prefix_;
202  map<string, double> initial_pose_map_;
203  int index_;
205 
206  //joint states
207  sensor_msgs::JointState joint_state_;
208  sensor_msgs::JointState joint_state_origin_;
209 
210  struct graspPoint{
212  displayMoveMarker = false;
213  displayGraspPoint = false;
214  pose.orientation.x = 0;
215  pose.orientation.y = 0;
216  pose.orientation.z = 0;
217  pose.orientation.w = 1;
218  }
221  geometry_msgs::Pose pose;
222  };
223 
224 
225  struct linkProperty{
227  displayMoveMarker = false;
228  displayModelMarker = true;
229  mesh_file = "";
230  }
234  string frame_id;
235  string movable_link;
236  //pose from frame_id
237  geometry_msgs::Pose pose;
238  geometry_msgs::Pose origin;
239  geometry_msgs::Pose initial_pose;
240  urdf::Vector3 joint_axis;
241  double joint_angle;
243  string mesh_file;
244  };
245 
246  map<string, linkProperty> linkMarkerMap;
247 };
248 
249 #endif
ros::ServiceServer serv_markers_del_
msg
visualization_msgs::InteractiveMarkerControl makeBoxMarkerControl(const geometry_msgs::PoseStamped &stamped, Vector3 dim, const std_msgs::ColorRGBA &color, bool use_color)
ros::Publisher pub_move_
ros::Publisher pub_base_pose_
ros::Subscriber sub_reset_joints_
boost::mutex joint_states_mutex_
ros::ServiceServer serv_markers_set_
geometry_msgs::Pose root_pose_
ros::Publisher pub_
std::string tf_prefix_
ros::Subscriber show_marker_
ros::Publisher pub_move_model_
ros::Subscriber sub_set_root_pose_
geometry_msgs::Pose root_pose_origin_
ros::Subscriber sub_reset_joints_and_root_
geometry_msgs::Pose initial_pose
ros::Publisher pub_move_object_
ModelInterfaceSharedPtr model
pose
std::string model_file_
std::string frame_id_
ros::ServiceClient dynamic_tf_publisher_client
sensor_msgs::JointState joint_state_origin_
file
scale
jsk_topic_tools::TimeAccumulator reset_joint_states_check_time_acc_
mode
TFSIMD_FORCE_INLINE Vector3()
boost::shared_ptr< ModelInterface > ModelInterfaceSharedPtr
header
std::string model_description_
sensor_msgs::JointState joint_state_
std::string target_frame
std::string base_frame
ros::ServiceServer serv_unlock_joint_states_
ros::ServiceClient dynamic_tf_publisher_publish_tf_client
map< string, double > initial_pose_map_
std::string model_name_
ros::ServiceServer serv_set_
ros::NodeHandle pnh_
ros::Subscriber hide_marker_
void init(void)
jsk_topic_tools::TimeAccumulator dynamic_tf_check_time_acc_
menu
boost::shared_ptr< const Link > LinkConstSharedPtr
geometry_msgs::Pose root_offset_
ros::ServiceServer serv_lock_joint_states_
char * index(char *sp, char c)
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server_
int main(int argc, char **argv)
interactive_markers::MenuHandler model_menu_
ros::Publisher pub_selected_index_
ros::Subscriber sub_set_urdf_
tf::TransformBroadcaster tfb_
geometry_msgs::Pose fixed_link_offset_
map< string, linkProperty > linkMarkerMap
visualization_msgs::InteractiveMarkerControl makeMeshMarkerControl(const std::string &mesh_resource, const geometry_msgs::PoseStamped &stamped, geometry_msgs::Vector3 scale, const std_msgs::ColorRGBA &color, bool use_color)
tf::TransformListener tfl_
ros::Publisher pub_joint_state_
std::shared_ptr< diagnostic_updater::Updater > diagnostic_updater_
ros::ServiceServer serv_reset_
vector< string > fixed_link_
std::string server_name
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server
ros::NodeHandle nh_
visualization_msgs::InteractiveMarkerControl makeSphereMarkerControl(const geometry_msgs::PoseStamped &stamped, double rad, const std_msgs::ColorRGBA &color, bool use_color)
GLdouble radius
boost::mutex mutex
std::string move_base_frame
visualization_msgs::InteractiveMarkerControl makeCylinderMarkerControl(const geometry_msgs::PoseStamped &stamped, double length, double radius, const std_msgs::ColorRGBA &color, bool use_color)
boost::shared_ptr< Joint > JointSharedPtr
ros::Publisher pub_selected_


jsk_interactive_marker
Author(s): furuta
autogenerated on Sat Mar 20 2021 03:03:33