roboteq_diff_drive.cpp
Go to the documentation of this file.
1 //
2 // Created by armadillo2 on 04/12/17.
3 //
4 
5 #include "roboteq_diff_drive.h"
6 
7 
9 {
10  nh_ = &nh;
11 
12  /* get roboteq params */
13  ros::param::get("~load_roboteq_hw", load_roboteq_hw_);
14 
15  if (load_roboteq_hw_)
16  {
18  {
19  ROS_ERROR(
20  "[armadillo2_hw/roboteq_diff_drive]: %s param is missing on param server. make sure that this param exist in ricboard_config.yaml "
21  "and that your launch includes this param file. shutting down...", ROBOTEQ_PORT_PARAM);
22  ros::shutdown();
23  exit(EXIT_FAILURE);
24  }
25 
27  {
28  ROS_ERROR(
29  "[armadillo2_hw/roboteq_diff_drive]: %s param is missing on param server. make sure that this param exist in ricboard_config.yaml "
30  "and that your launch includes this param file. shutting down...", ROBOTEQ_BAUD_PARAM);
31  ros::shutdown();
32  exit(EXIT_FAILURE);
33  }
34 
36  {
37  ROS_ERROR(
38  "[armadillo2_hw/roboteq_diff_drive]: %s param is missing on param server. make sure that this param exist in ricboard_config.yaml "
39  "and that your launch includes this param file. shutting down...", RIGHT_WHEEL_JOINT_PARAM);
40  ros::shutdown();
41  exit(EXIT_FAILURE);
42  }
43 
45  {
46  ROS_ERROR(
47  "[armadillo2_hw/roboteq_diff_drive]: %s param is missing on param server. make sure that this param exist in ricboard_config.yaml "
48  "and that your launch includes this param file. shutting down...", LEFT_WHEEL_JOINT_PARAM);
49  ros::shutdown();
50  exit(EXIT_FAILURE);
51  }
52 
53  /* try connect to roboteq */
55  /* run the serial controller */
56  bool start = roboteq_serial_->start();
57  if (!start)
58  {
59  ROS_ERROR(
60  "[armadillo2_hw/roboteq_diff_drive]: failed opening roboteq port. make sure roboteq is connected. shutting down...");
61  ros::shutdown();
62  exit(1);
63  }
64  ROS_INFO("[armadillo2_hw/roboteq_diff_drive]: roboteq port opened successfully \nport name: %s \nbaudrate: %d",
65  roboteq_port_.c_str(), roboteq_baud_);
66  /* initialize roboteq controller */
68 
69  /* initialize the motor parameters */
70  roboteq_->initialize();
71 
72  ROS_INFO("[armadillo2_hw/roboteq_diff_drive]: roboteq is up");
73  ROS_INFO("[armadillo2_hw/ricboard_pub]: ricboard is up");
74  espeak_pub_ = nh.advertise<std_msgs::String>("/espeak_node/speak_line", 10);
75  /* speakMsg("robotek is up", 1); */
76  }
77  else
78  ROS_WARN("[armadillo2_hw/roboteq_diff_drive]: roboteq hardware is disabled");
79 
80 }
81 
83 {
84  if (!load_roboteq_hw_)
85  return;
86  roboteq_->write(ros::Time::now(), elapsed);
87 }
88 
90 {
91  if (!load_roboteq_hw_)
92  return;
93  roboteq_->read(ros::Time::now(), elapsed);
94 }
95 
97  hardware_interface::VelocityJointInterface &velocity_joint_interface)
98 {
99  if (!load_roboteq_hw_)
100  return;
101  /* initialize all interfaces and setup diagnostic messages */
102  roboteq_->initializeInterfaces(joint_state_interface, velocity_joint_interface);
103 }
void read(const ros::Time &time, const ros::Duration &period)
RoboteqDiffDrive(ros::NodeHandle &nh)
void registerHandles(hardware_interface::JointStateInterface &joint_state_interface, hardware_interface::VelocityJointInterface &velocity_joint_interface)
std::string left_wheel_joint_
#define ROS_WARN(...)
std::string right_wheel_joint_
void write(const ros::Time &time, const ros::Duration &period)
#define ROBOTEQ_BAUD_PARAM
#define LEFT_WHEEL_JOINT_PARAM
ros::Publisher espeak_pub_
ROSCPP_DECL bool get(const std::string &key, std::string &s)
#define ROS_INFO(...)
ros::NodeHandle * nh_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define RIGHT_WHEEL_JOINT_PARAM
void read(const ros::Duration elapsed)
roboteq::Roboteq * roboteq_
void write(const ros::Duration elapsed)
roboteq::serial_controller * roboteq_serial_
std::string roboteq_port_
#define ROBOTEQ_PORT_PARAM
static Time now()
ROSCPP_DECL void shutdown()
void initializeInterfaces(hardware_interface::JointStateInterface &joint_state_interface, hardware_interface::VelocityJointInterface &velocity_joint_interface)
#define ROS_ERROR(...)


armadillo2_hw
Author(s):
autogenerated on Wed Jan 3 2018 03:48:27