svh_ros_control_node.cpp
Go to the documentation of this file.
1 //
3 // © Copyright 2022 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
4 // © Copyright 2022 FZI Forschungszentrum Informatik, Karlsruhe, Germany
5 //
6 // This file is part of the Schunk SVH Driver.
7 //
8 // The Schunk SVH Driver is free software: you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or (at your
11 // option) any later version.
12 //
13 // The Schunk SVH Driver is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 // Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // the Schunk SVH Driver. If not, see <https://www.gnu.org/licenses/>.
20 //
22 
23 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 
32 
33 // ROS includes
34 #include <ros/ros.h>
35 
36 // package includes
38 
39 // other includes
40 
41 int main(int argc, char** argv)
42 {
43  ros::init(argc, argv, "schunk_svh");
44 
46  spinner.start();
47 
48  ros::NodeHandle nh("~");
49 
50  // Create the hardware interface
52  svh_hw.init(nh, nh);
53 
55 
56  ros::Time timestamp_now = ros::Time::now();
57  ros::Time timestamp_last = ros::Time::now();
58  ros::Duration period;
59 
60  ros::Rate rate(125);
61  while (ros::ok())
62  {
63  // Get current time and elapsed time since last read
64  timestamp_now = ros::Time::now();
65  period = timestamp_now - timestamp_last;
66  timestamp_last = timestamp_now;
67 
68  svh_hw.read(timestamp_now, period);
69  cm.update(timestamp_now, period, !svh_hw.isEnabled());
70  svh_hw.write(timestamp_now, period);
71  rate.sleep();
72  }
73 
74  return 0;
75 }
controller_manager::ControllerManager
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
ros::AsyncSpinner
ros::ok
ROSCPP_DECL bool ok()
SVHRosControlHWInterface::init
virtual bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh)
Initialize the hardware interface.
Definition: SVHRosControlHWInterface.cpp:54
spinner
void spinner()
SVHRosControlHWInterface.h
main
int main(int argc, char **argv)
Definition: svh_ros_control_node.cpp:41
ros::Rate::sleep
bool sleep()
SVHRosControlHWInterface::read
virtual void read(const ros::Time &time, const ros::Duration &period)
Read the state from the robot hardware.
Definition: SVHRosControlHWInterface.cpp:104
SVHRosControlHWInterface
This class defines a ros-control hardware interface.
Definition: SVHRosControlHWInterface.h:51
ros::Time
ros::Rate
SVHRosControlHWInterface::write
virtual void write(const ros::Time &time, const ros::Duration &period)
write the command to the robot hardware.
Definition: SVHRosControlHWInterface.cpp:146
SVHRosControlHWInterface::isEnabled
bool isEnabled() const
Definition: SVHRosControlHWInterface.cpp:191
ros::Duration
controller_manager::ControllerManager::update
void update(const ros::Time &time, const ros::Duration &period, bool reset_controllers=false)
ros::NodeHandle
ros::Time::now
static Time now()


schunk_svh_driver
Author(s): Georg Heppner , Felix Exner , Pascal Becker , Johannes Mangler
autogenerated on Sat Apr 15 2023 02:24:55