This is what I get when i change it to #!/usr/bin/env python
roslaunch laser_values laser.launch
… logging to /home/husarion/.ros/log/d34bca52-ae16-11e9-80f7-80c5f2ba9bc5/roslaunch-husarion-18511.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://husarion:36158/
SUMMARY
PARAMETERS
- /rosdistro: kinetic
- /rosversion: 1.12.14
NODES
/
scan_values (laser_values/scan.py)
ROS_MASTER_URI=http://master:11311
process[scan_values-1]: started with pid [18554]
/usr/bin/env: ‘python\r’: No such file or directory
[scan_values-1] process has died [pid 18554, exit code 127, cmd /home/husarion/catkin_ws/src/laser_values/src/scan.py __name:=scan_values __log:=/home/husarion/.ros/log/d34bca52-ae16-11e9-80f7-80c5f2ba9bc5/scan_values-1.log].
log file: /home/husarion/.ros/log/d34bca52-ae16-11e9-80f7-80c5f2ba9bc5/scan_values-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor…
… shutting down processing monitor complete
done
As for the /cmd_vel thing this is my code:
#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>
#include <geometry_msgs/Twist.h>
#include
void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan_msg)
{
geometry_msgs::Twist vel;
ros::NodeHandle n;
ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>(“cmd_vel”, 1);
ros::Rate loop_rate(50);
for(int x = 0; x < scan_msg->ranges.size();x++)
{
if(scan_msg->ranges[x] >= 0)
{
vel.linear.x = 0.3;
vel.angular.z = 0.0;
vel_pub_.publish(vel);
//std::cout << “Working!” << std::endl;
}
//std::cout << “Working!” << std::endl;
}
}
int main(int argc,char **argv)
{
ros::init(argc,argv,“scan_node”);
ros::NodeHandle n;
ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
//Create a subscriber object
ros::Subscriber sub = n.subscribe("/scan",1, scanCallback);
//Let ROS take over
ros::spin();
return 0;
}
With this code, I’m able to access the lidar data now, and I’m not getting any error messages but it doesn’t cause the Rosbot to move at all.