remote_control.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, PickNik Consulting
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the PickNik Consulting nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman <dave@dav.ee>
36  Desc: Tool for creating break points and user verification points through
37  manipulation pipelines or other live robotitc tool.
38  Think GDB for robots, or like, a state machine.
39 */
40 
41 #ifndef RVIZ_VISUAL_TOOLS_REMOTE_CONTROL_H
42 #define RVIZ_VISUAL_TOOLS_REMOTE_CONTROL_H
43 
44 // C++
45 #include <string>
46 
47 // ROS
48 #include <ros/ros.h>
49 #include <sensor_msgs/Joy.h>
50 
51 namespace rviz_visual_tools
52 {
53 typedef std::function<void(bool)> DisplayWaitingState;
54 
56 {
57 public:
61  explicit RemoteControl(const ros::NodeHandle& nh);
62 
66  void rvizDashboardCallback(const sensor_msgs::Joy::ConstPtr& msg);
67 
72  bool setReadyForNextStep();
73 
77  void setAutonomous(bool autonomous = true);
78  void setFullAutonomous(bool autonomous = true);
79 
84  bool getAutonomous();
85  bool getFullAutonomous();
86 
90  void setStop(bool stop = true);
91 
95  bool getStop();
96 
101  bool waitForNextStep(const std::string& caption = "go to next step");
102  bool waitForNextFullStep(const std::string& caption = "go to next full step");
103 
105  bool isWaiting()
106  {
107  return is_waiting_;
108  }
109 
110  void setDisplayWaitingState(DisplayWaitingState displayWaitingState)
111  {
112  displayWaitingState_ = displayWaitingState;
113  }
114 
115 private:
116  // A shared node handle
118 
119  // Short name for this class
120  std::string name_ = "remote_control";
121 
122  // Input
124 
125  // Debug interface
126  bool is_waiting_ = false;
127  bool next_step_ready_ = false;
128  bool autonomous_ = false;
129  bool full_autonomous_ = false;
130  bool stop_ = false;
131 
132  // Callback to visualize waiting state
133  DisplayWaitingState displayWaitingState_;
134 }; // end class
135 
136 typedef std::shared_ptr<RemoteControl> RemoteControlPtr;
137 typedef std::shared_ptr<const RemoteControl> RemoteControlConstPtr;
138 
139 } // namespace rviz_visual_tools
140 
141 #endif // RVIZ_VISUAL_TOOLS_REMOTE_CONTROL_H
void setAutonomous(bool autonomous=true)
Enable autonomous mode.
bool getStop()
See if we are in stop mode.
bool setReadyForNextStep()
Step to next step.
std::shared_ptr< RemoteControl > RemoteControlPtr
void setDisplayWaitingState(DisplayWaitingState displayWaitingState)
bool waitForNextFullStep(const std::string &caption="go to next full step")
void rvizDashboardCallback(const sensor_msgs::Joy::ConstPtr &msg)
Callback from ROS topic.
void setStop(bool stop=true)
Stop something in pipeline.
DisplayWaitingState displayWaitingState_
RemoteControl(const ros::NodeHandle &nh)
Constructor.
bool getAutonomous()
Get the autonomous mode.
bool waitForNextStep(const std::string &caption="go to next step")
Wait until user presses a button.
std::shared_ptr< const RemoteControl > RemoteControlConstPtr
void setFullAutonomous(bool autonomous=true)
bool isWaiting()
Return true if debug interface is waiting for user input.
std::function< void(bool)> DisplayWaitingState


rviz_visual_tools
Author(s): Dave Coleman
autogenerated on Mon Feb 25 2019 03:54:12