ros_driver.cpp
Go to the documentation of this file.
1 
34 #include <functional>
35 
36 #include <multisense_ros/laser.h>
37 #include <multisense_ros/camera.h>
38 #include <multisense_ros/pps.h>
39 #include <multisense_ros/imu.h>
40 #include <multisense_ros/status.h>
42 #include <ros/ros.h>
43 
44 using namespace crl::multisense;
45 
46 int main(int argc, char** argvPP)
47 {
48  ros::init(argc, argvPP, "multisense_driver");
49  ros::NodeHandle nh;
50  ros::NodeHandle nh_private_("~");
51 
52  //
53  // Get parameters from ROS/command-line
54 
55  std::string sensor_ip;
56  std::string tf_prefix;
57  int sensor_mtu;
58 
59 
60  nh_private_.param<std::string>("sensor_ip", sensor_ip, "10.66.171.21");
61  nh_private_.param<std::string>("tf_prefix", tf_prefix, "multisense");
62  nh_private_.param<int>("sensor_mtu", sensor_mtu, 7200);
63 
64  Channel *d = NULL;
65 
66  try {
67 
68  d = Channel::Create(sensor_ip);
69  if (NULL == d) {
70  ROS_ERROR("multisense_ros: failed to create communication channel to sensor @ \"%s\"",
71  sensor_ip.c_str());
72  return -2;
73  }
74 
75  Status status = d->setMtu(sensor_mtu);
76  if (Status_Ok != status) {
77  ROS_ERROR("multisense_ros: failed to set sensor MTU to %d: %s",
78  sensor_mtu, Channel::statusString(status));
80  return -3;
81  }
82 
83  //
84  // Anonymous namespace so objects can deconstruct before channel is destroyed
85  {
86  multisense_ros::Laser laser(d, tf_prefix);
87  multisense_ros::Camera camera(d, tf_prefix);
88  multisense_ros::Pps pps(d);
89  multisense_ros::Imu imu(d, tf_prefix);
90  multisense_ros::Status status(d);
92  std::bind(&multisense_ros::Camera::updateConfig, &camera, std::placeholders::_1),
94  std::placeholders::_1, std::placeholders::_2),
96  std::placeholders::_1));
97  ros::spin();
98  }
99 
100  Channel::Destroy(d);
101  return 0;
102 
103  } catch (const std::exception& e) {
104  ROS_ERROR("multisense_ros: caught exception: %s", e.what());
105  Channel::Destroy(d);
106  return -4;
107  }
108 }
d
void maxPointCloudRangeChanged(double range)
Definition: camera.cpp:725
static const char * statusString(Status status)
static Channel * Create(const std::string &sensorAddress)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
void borderClipChanged(const BorderClip &borderClipType, double borderClipValue)
Definition: camera.cpp:716
void updateConfig(const crl::multisense::image::Config &config)
Definition: camera.cpp:1877
bool param(const std::string &param_name, T &param_val, const T &default_val) const
static CRL_CONSTEXPR Status Status_Ok
int main(int argc, char **argvPP)
Definition: ros_driver.cpp:46
static void Destroy(Channel *instanceP)
int32_t Status
#define ROS_ERROR(...)


multisense_ros
Author(s):
autogenerated on Sun Mar 14 2021 02:34:55