Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PINTO0309 authored May 2, 2018
1 parent 386d734 commit a39c3e4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "ros/ros.h"
#include "sensor_msgs/LaserScan.h"
#include "std_srvs/Empty.h"
#include "rplidar_ros/StartMotor.h"
#include "rplidar.h"

#ifndef _countof
Expand Down Expand Up @@ -169,14 +170,14 @@ bool stop_motor(std_srvs::Empty::Request &req,
return true;
}

bool start_motor(std_srvs::Empty::Request &req,
std_srvs::Empty::Response &res)
bool start_motor(rplidar_ros::StartMotor::Request &req,
rplidar_ros::StartMotor::Response &res)
{
if(!drv)
return false;
ROS_DEBUG("Start motor");
drv->startMotor();
drv->startScan();;
ROS_DEBUG("Start motor (%d)", req.pwm.data);
drv->startMotor(req.pwm.data);
drv->startScan();
return true;
}

Expand All @@ -185,6 +186,7 @@ int main(int argc, char * argv[]) {

std::string serial_port;
int serial_baudrate = 115200;
int motor_pwm;
std::string frame_id;
bool inverted = false;
bool angle_compensate = true;
Expand All @@ -193,7 +195,8 @@ int main(int argc, char * argv[]) {
ros::Publisher scan_pub = nh.advertise<sensor_msgs::LaserScan>("scan", 1000);
ros::NodeHandle nh_private("~");
nh_private.param<std::string>("serial_port", serial_port, "/dev/ttyUSB0");
nh_private.param<int>("serial_baudrate", serial_baudrate, 115200);
nh_private.param<int>("serial_baudrate", serial_baudrate, 115200);
nh_private.param<int>("motor_pwm", motor_pwm, DEFAULT_MOTOR_PWM);
nh_private.param<std::string>("frame_id", frame_id, "laser_frame");
nh_private.param<bool>("inverted", inverted, false);
nh_private.param<bool>("angle_compensate", angle_compensate, true);
Expand Down Expand Up @@ -233,7 +236,7 @@ int main(int argc, char * argv[]) {
ros::ServiceServer stop_motor_service = nh.advertiseService("stop_motor", stop_motor);
ros::ServiceServer start_motor_service = nh.advertiseService("start_motor", start_motor);

drv->startMotor();
drv->startMotor(motor_pwm);
drv->startScan();

ros::Time start_scan_time;
Expand Down

0 comments on commit a39c3e4

Please sign in to comment.