KinectMappingState.cpp
Go to the documentation of this file.
2 
3 namespace rsm {
4 
6 }
7 
9 }
10 
12  _joint_states_subscriber = _nh.subscribe("joint_states", 10,
14  _kinect_joint_controller = _nh.advertise<std_msgs::Float64>(
15  "kinect_controller/command", 1, true);
16  ros::NodeHandle nh("rsm");
17  _reset_kinect_position_client = nh.serviceClient<std_srvs::Trigger>(
18  "resetKinectPosition");
19  _navigation_goal_completed_service = nh.serviceClient<
20  rsm_msgs::GoalCompleted>("navigationGoalCompleted");
21  _name = "E: Kinect Mapping";
22  _swivel_state = -1;
23  _position_reached = false;
24  _message_send = false;
25  _navigation_completed_status = rsm_msgs::GoalStatus::ABORTED;
26 }
27 
30 }
31 
33  switch (_swivel_state) {
34  case MOVE_LEFT: {
35  if (_position_reached) {
37  _position_reached = false;
38  _message_send = false;
39  } else {
40  if (!_message_send) {
41  std_msgs::Float64 kinect_command;
42  kinect_command.data = KINECT_LEFT_LIMIT;
43  _kinect_joint_controller.publish(kinect_command);
44  ros::spinOnce();
45  _message_send = true;
46  }
47  }
48  break;
49  }
50  case MOVE_RIGHT: {
51  if (_position_reached) {
53  _position_reached = false;
54  _message_send = false;
55  } else {
56  if (!_message_send) {
57  std_msgs::Float64 kinect_command;
58  kinect_command.data = KINECT_RIGHT_LIMIT;
59  _kinect_joint_controller.publish(kinect_command);
60  _message_send = true;
61  }
62  }
63  break;
64  }
65  case MOVE_TO_CENTER: {
66  if (_position_reached) {
67  if (!_interrupt_occured) {
68  _navigation_completed_status = rsm_msgs::GoalStatus::REACHED;
71  }
72  } else {
73  if (!_message_send) {
74  std_msgs::Float64 kinect_command;
75  kinect_command.data = KINECT_CENTER_POSITION;
76  _kinect_joint_controller.publish(kinect_command);
77  _message_send = true;
78  }
79  }
80  break;
81  }
82  default: {
83  break;
84  }
85  }
86 }
87 
89  if (!_position_reached) {
90  std_srvs::Trigger srv;
92  ROS_ERROR("Failed to call Reset Kinect Position service");
93  }
94  }
95  rsm_msgs::GoalCompleted srv;
96  srv.request.status.goal_status = _navigation_completed_status;
98  ROS_ERROR("Failed to call Complete Navigation Goal service");
99  }
100 }
101 
103  std::string &message) {
104  success = false;
105  message = "Exploration running";
106 }
107 
109  std::string &message) {
110  success = true;
111  message = "Exploration stopped";
112  _stateinterface->transitionToVolatileState(boost::make_shared<IdleState>());
113 }
114 
116  std::string &message) {
117  success = false;
118  message = "Exploration running";
119 }
120 
122  std::string &message) {
123  success = false;
124  message = "Exploration running";
125 }
126 
127 void KinectMappingState::onInterrupt(int interrupt) {
128  switch (interrupt) {
131  boost::make_shared<EmergencyStopState>());
132  _interrupt_occured = true;
133  break;
136  boost::make_shared<TeleoperationState>());
137  _interrupt_occured = true;
138  break;
142  _interrupt_occured = true;
143  break;
144  }
145 }
146 
148  sensor_msgs::JointState::ConstPtr joint_state) {
149  switch (_swivel_state) {
150  case MOVE_LEFT: {
151  if (joint_state->position[0] >= KINECT_LEFT_LIMIT - POS_TOLERANCE) {
152  _position_reached = true;
153  }
154  break;
155  }
156  case MOVE_RIGHT: {
157  if (joint_state->position[0] <= KINECT_RIGHT_LIMIT + POS_TOLERANCE) {
158  _position_reached = true;
159  }
160  break;
161  }
162  case MOVE_TO_CENTER: {
163  if (joint_state->position[0] >= KINECT_CENTER_POSITION - POS_TOLERANCE
164  && joint_state->position[0]
166  _position_reached = true;
167  }
168  break;
169  }
170  }
171 }
172 
173 }
174 
void publish(const boost::shared_ptr< M > &message) const
boost::shared_ptr< rsm::BaseState > getPluginState(int plugin_type, std::string routine="")
Dummy state for mapping at a reached goal during exploration. Only initiates transition to CalculateG...
ros::ServiceClient _reset_kinect_position_client
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
#define NAVIGATION_STATE
ros::Publisher _kinect_joint_controller
ros::ServiceClient _navigation_goal_completed_service
bool call(MReq &req, MRes &res)
void transitionToVolatileState(boost::shared_ptr< rsm::BaseState > next_state)
bool _interrupt_occured
void onWaypointFollowingStart(bool &success, std::string &message)
#define TELEOPERATION_INTERRUPT
#define MOVE_LEFT
#define MOVE_TO_CENTER
ros::Subscriber _joint_states_subscriber
#define MOVE_RIGHT
#define KINECT_CENTER_POSITION
#define CALCULATEGOAL_STATE
std::string _name
StateInterface * _stateinterface
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void onExplorationStop(bool &success, std::string &message)
#define EMERGENCY_STOP_INTERRUPT
#define KINECT_LEFT_LIMIT
void onInterrupt(int interrupt)
Called when an operation mode interrupt was received.
#define KINECT_RIGHT_LIMIT
#define SIMPLE_GOAL_INTERRUPT
void onExplorationStart(bool &success, std::string &message)
ROSCPP_DECL void spinOnce()
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void onWaypointFollowingStop(bool &success, std::string &message)
#define ROS_ERROR(...)
#define POS_TOLERANCE
void jointStateCallback(sensor_msgs::JointState::ConstPtr joint_state)


rsm_additions
Author(s): Marco Steinbrink
autogenerated on Tue Mar 16 2021 02:44:35