Starting Lidar from Cloud IDE for Rosbot 2.0

I tried to use rosbot.initDistanceSensors(sensor_type) function to turn on the lidar on the cloud IDE in C++, but it didn’t appear to do anything. Is there another way for me to turn on the lidar and access its data from the cloud IDE? All I want are the distance values at the four cardinal directions.

I also tried to use this guide How to read LaserScan data (ROS python) | The Construct to do it without using the cloud IDE, but I’m getting permission errors even when running from root.

Here’s the exact error message:
unable to launch [/home/husarion/ros_workspace/src/laser_values/src/scan.py __name:=scan_values __log:=/home/husarion/.ros/log/b7049d34-a965-11e9-82dc-80c5f2ba9bc5/scan_values-1.log]: Permission denied

Hello Gabriel_Chen,

It is not possible to access lidar data in cloud IDE.

Method rosbot.initDistanceSensors(sensor_type) is for controlling ROSbot proximity sensors, these are four sensors, two front facing and two rear facing.

RpLidar is a high level sensor and it must be handled by ROS.

It should be possible to use script as normal user. Did you set file as executable?

chmod +x src/scan.py

Regards,
Łuaksz

Thanks for the quick response,

I ran the chmod command, but it said Permissions Denied.
I did change this line in scan.py:
sub = rospy.Subscriber(’/kobuki/laser/scan’, LaserScan, callback)
to:
sub = rospy.Subscriber(’/laser/scan’, LaserScan, callback)
because I’m not using kobuki as far as I’m aware
Would that cause any permissions errors?

Thanks

In ROSbot, the laser scans are published under /scan topic, then this line should be:

sub = rospy.Subscriber(’/scan’, LaserScan, callback)

Regardless of topic name, this will not stop node from being started.

We should check file permissions, please post here output of:

ls -l src/scan.py

Regards,
Łukasz

Here’s my output:
-rwxrwxr-x 1 husarion husarion 348 Jul 18 14:15 src/scan.py

Hello Gabriel,

It looks like there is something else in workspace or package that prevents from launching the script.
Could you try to create workspace and package from scratch. For the test, let new workspace contain only scan.py and laser.launch files.

Regards,
Łukasz

I created a new workspace and package and tested it, but I’m still getting the same permission error.
My output for ls -l src/scan.py is still
-rwxrwxr-x 1 husarion husarion 348 Jul 23 15:43 src/scan.py

Could you post here full console output, beginning with roslaunch until last line?

Regards,
Łukasz

Here’s everything after roslaunch:
roslaunch laser_values laser.launch
… logging to /home/husarion/.ros/log/e0ffd9ac-ae13-11e9-89aa-80c5f2ba9bc5/roslaunch-husarion-21601.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:37283/

SUMMARY

PARAMETERS

  • /rosdistro: kinetic
  • /rosversion: 1.12.14

NODES
/
scan_values (laser_values/scan.py)

ROS_MASTER_URI=http://master:11311

unable to launch [/home/husarion/ros_workspace/src/laser_values/src/scan.py __name:=scan_values __log:=/home/husarion/.ros/log/e0ffd9ac-ae13-11e9-89aa-80c5f2ba9bc5/scan_values-1.log]: Permission denied
The traceback for the exception was written to the log file
[scan_values-1] killing on exit

Did you try to start scan.py with rosrun?

rosrun laser_values scan.py

Are you able launch any other nodes?

/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyCORE2
roslaunch astra_launch astra.launch
rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Are they launching without warnings and errors?

Regards,
Łukasz

When I used rosrun laser_values scan.py I got this output:
rosrun laser_values scan.py
/opt/ros/kinetic/bin/rosrun: /home/husarion/ros_workspace/src/laser_values/src/scan.py: /usr/bin/: bad interpreter: Permission denied
/opt/ros/kinetic/bin/rosrun: line 109: /home/husarion/ros_workspace/src/laser_values/src/scan.py: Success

and I was able to launch the other nodes.

BTW, I checked the simple kinematics husarion rosbot tutorial, and they used the cloud IDE to publish and subscribe to some ros nodes, so the IDE is using ROS right? Is there no way for me to access the lidar using the cloud? If not, how can I use the rosbot.setSpeed() command when using ssh? If that’s not possible, what other way could I get the wheels moving?

The bad interpreter error is caused by wrong shebang line.
What is the first line of your scan.py file?

Cloud IDE:
To be precise cloud IDE itself is not using nor communicating with ROS, the applications created with cloud IDE does, they can access ROS topics almost like any other node.

System architecture is as follow:

  • ROS system is running on SBC (TinkerBoard for ROSbot 2.0 and UpBoard for ROSbot 2.0 PRO).
  • High level sensors (camera and lidar) are connected directly to SBC.
  • Low level sensors (IMU, encoders, distance sensors) are connected to CORE2 controller.
  • CORE2 is communicating with SBC over serial port.
  • CORE2 is based on STM32 processor

Above points entail limitations:

  • serial port speed is 500000 bps
  • STM32 has 192KB of RAM

While it is possible to code and compile CORE2 application which subscribe to scan message, it will fail due to size of that message. Retrieving the message would take lots of time, not to mention processing it.

Regards,
Łukasz

My first line is:
#! /usr/bin python

Thanks for the explaining the lidar problem.
BTW, is there a way I can get the rosbot moving without using the Cloud IDE? For example, could I use the rosbot.setSpeed() command while using ssh? I tried to publish to cmd_vel but the robot didn’t move.

Change the line to:

#!/usr/bin/env python

It is not possible to use rosbot.setSpeed() through SSH or console.
The only way is to use /cmd_vel.
Simple kinematics tutorial that you already mentioned, describes how to drive ROSbot with use of teleop_twist_keyboard, it is compatible with SSH.
Please describe in accordance with tutorial, at which step did you encounter problem with publishing /cmd_vel?

Regards,
Łukasz

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.

Error /usr/bin/env: ‘python\r’: No such file or directory means that your script has Windows line endings.
This can happen when file was originally created on Windows or edited on Windows and copied to Linux.

You may edit it with:

sed -i.bak 's/\r$//' scan.py

For the /cmd_vel:
You are advertising to /cmd_vel twice, in main() and in scanCallback(). Also you create node handle twice, again in main() and in scanCallback(). Clean up your code not to duplicate, it will be easier to analyse it and debug.

Regards,
Łukasz

Nevermind, I figured it out. Turns out the Core2 wasn’t connecting properly but I relinked it and its working fine now. Thanks for all your help, I would’ve been lost without it.