rm_hw.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2021, Qiayuan Liao
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 are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *******************************************************************************/
33 
34 //
35 // Created by qiayuan on 12/27/20.
36 //
37 
38 #include "rm_hw/control_loop.h"
39 
40 int main(int argc, char** argv)
41 {
42  ros::init(argc, argv, "rm_hw");
43  ros::NodeHandle nh;
44 
45  // Run the hardware interface node
46  // -------------------------------
47 
48  // We run the ROS loop in a separate thread as external calls, such
49  // as service callbacks loading controllers, can block the (main) control loop
50 
52  spinner.start();
53 
54  try
55  {
56  // Create the hardware interface specific to your robot
57  std::shared_ptr<rm_hw::RmRobotHW> rm_hw_hw_interface = std::make_shared<rm_hw::RmRobotHW>();
58 
59  // Start the control loop
60  rm_hw::RmRobotHWLoop control_loop(nh, rm_hw_hw_interface);
61 
62  // Wait until shutdown signal received
64  }
65  catch (const ros::Exception& e)
66  {
67  ROS_FATAL_STREAM("Error in the hardware interface:\n"
68  << "\t" << e.what());
69  return 1;
70  }
71 
72  return 0;
73 }
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ROS_FATAL_STREAM
#define ROS_FATAL_STREAM(args)
ros::AsyncSpinner
ros::Exception
control_loop.h
spinner
void spinner()
rm_hw::RmRobotHWLoop
Definition: control_loop.h:84
ros::waitForShutdown
ROSCPP_DECL void waitForShutdown()
main
int main(int argc, char **argv)
Definition: rm_hw.cpp:40
ros::NodeHandle


rm_hw
Author(s): Qiayuan Liao
autogenerated on Tue May 6 2025 02:23:44