[[ROS 05-02 Error with Lidar – Summary|👉 Next page]]
# ROS 05-01 Setting up Lidar for ROS on Jetson Nano
%%Do not copy the code-snippet for the red box below, please. I just randomly got something to work here under time pressure, so this is not how you should do it properly.%%
<div id = "not_a_tutorial_box">
<p style ="background-color: #ffcccb; padding: 20 px; border: 1px solid red; width: 338px; height: 28px; insert: Test"> ☝️ This is <i>not</i> a tutorial, but a <b>labbook-entry</b>.</p>
</div>
<div>
<p style="font-size:11pt; color:grey">
For instructions on to how do this yourself please refer to the tutorial I used:   <a href="https://automaticaddison.com/how-to-build-an-indoor-map-using-ros-and-lidar-based-slam/">https://automaticaddison.com/how-to-build-an-indoor-map-using-ros-and-lidar-based-slam/</a><br><br>
</p></div>
---
## Preliminaries
Once again I am working with a [tutorial](https://automaticaddison.com/how-to-build-an-indoor-map-using-ros-and-lidar-based-slam/) from automaticaddison. They seem to work very nicely into one another, so my hopes are up that this might function as intended.
It is now time to connect the Lidar sensor to the Jetson Nano and to get ROS to work, receiving data from the Lidar to create a map.
On a second level this tutorial should allow us to use data from Lidar later on to guide a robot or at least use a robot to map the environment it is moving through. It should also be possible to just slowly carry the device with you by hand to map a room.
I still have no fan available at this point, so overheating could be a problem.
## Following the tutorial
### Testing the power bank
I already did that, it worked. But I should not forget to __change the J48 Jumper__ when reconnecting the Jetson Nano with the power bank.
I will not use the power bank, for now.
### Connecting your RPLIDAR
Now the fun part begins:
![[thn-jetson-lidar_1.jpg]]
Putting the cable into the Lidar:
![[thn-jetson-lidar_2.jpg]]
![[thn-jetson-lidar_3.jpg]]
As everything is connected according to the [tutorial](https://automaticaddison.com/how-to-build-an-indoor-map-using-ros-and-lidar-based-slam/), I start up the Nano.
The Lidar's head immediately starts to spin.
![[thn-jetson-lidar_4.jpg]]
So far everything worked out. But how to put the Lidar on pause, I do not know yet. I will have to shutdown the Nano to do that.
I try that now, I shutdown the Nano.
Starting it up again and the Lidar spins again.
Note: There are few seconds before the Nano has booted. So I have to wait before I connect remotely to it.
### Set Up a Catkin Workspace and Install RPLIDAR ROS Packages
I was double-checking the new entry in the .bashrc file I have to create.
Note: the first line given in the tutorial was already there, I only added the second one. I also added a comment below with `#`.
The tutorial saw an error in the node.cpp file. I did not encounter this error so I proceed after the instructions in question.
---
#### An error! Oh horror!
The command `roslaunch rplidar_ros rplidar.launch` produces an error.
![[thn-jetson-error-lidar.png]]
Two reasons come to my mind:
Either I have to go back in the tutorial and to the changes I just omitted. Or the hint given from #Schmiedel_Alex applies here, that I have to add the serial number of the Lidar.
I first check, if the instructions I did not follow show resemblance to the error that I got.
On first glance, this seems to cover something different connected directly with the `catkin_make` command.
Well, it may be pointless, but as the Lidar is already spinning, I try to read data from it by jumping even further into the tutorial.
I use `Ctrl + shift + n` to #open_new_terminal_window
I type `rostopic echo /scan`
But the message is, that the device is unable to communicate with master!
So I have to go a few steps back, again.
Let's check the other tutorial that seemed to cover nicely what we need: https://www.hackster.io/shahizat/building-a-map-using-lidar-with-ros-melodic-on-jetson-nano-2f92dd
The other tutorial uses the same command to launch the Lidar but takes a few different steps before:
- `echo "source $HOME/catkin_ws/devel/setup.bash" >> ~/.bashrc
- to source it to bashrc
- Maybe this does the same as changing the file in the other tutorial?
- `source devel/setup.bash`
- this happens right before the Lidar is launched
I will try the last command up there, oh my…
It produced no error.
I try to launch Lidar again.
The same error again:
`RLExeption: [rplidar.launch] is neither a launch file in package [rplidar_ros] nor is [rplidar_ros] a launch file name`
Searching for this error on the internet:
- https://answers.ros.org/question/143496/roslaunch-is-neither-a-launch-file-in-package-nor-is-a-launch-file-name/
- different files but same problem
- solution there is `source /home/gabriel/catkin_ws/devel/setup.bash`
- which would mean for me `source /home/thomas/catkin_ws/devel/setup.bash` or not?
- There are also these questions mentioned:
- “Does the file actually exists?” Yes, the file is in the launch folder.
- “Did you source the setup.bash file?” “Do you mean `source /opt/ros/hydro/setup.bash`” ? Yes, I did.
- “What does `rospack find tb_tables` output?” `\[rospack\] Error: stack/package tb_tables not found`
- I can use this too, I have to go for: `rospack find rplidar`
So I have some things to check on from that first hit on the internet:
- Does the file exist?
- I have to find `rplidar.launch`
- Where is it?
- I go out of the folder `catkin_ws` with `cd ..`
- I list the folders of the Nano with `ls`
- I check all folders. They are empty or not related
- I check the `catkin_ws` folder
- 3 folder in it, `build`, `devel` and `src`
- `devel` is the same as in the instructions for this error
- the folder ==`rplidar_ros`== is in `/catkin_ws/build`
- but here is ==no `rplidar.launch`== in it
- So the first question, if the file exists, seems to be answered negative
- Does setup.bash exist?
- yes, it is in the `devel` folder
- In the `src` folder is another folder `rplidar_ros`
- there is stuff connected to Lidar and
- there is a ==folder named `launch`==
- no file named just `rplidar.launch`, but:
![[Rplidar.launch.png]]
I could now:
- proceed with the instructions from the website just sighted
- i.e. try the command that solved their problems adapted to my problem
- or before that follow the question raised there
- try the command with one of the files I just found on the Jetson
- I mean, these files are in the folder `rplidar_ros`, are they not?
- ==Does the a1 in `rplidar_a1.launch` stand for the version? For the Lidar A1 that I have?==
- see also here, launch files:
- http://wiki.ros.org/rplidar#Launch_File_Examples
- they use for the A1:
- `$ roslaunch rplidar_ros view_rplidar.launch`
- but they use rviz
- think I don't have that yet on the Nano or does it come automatically? There is folder called `rviz` in `rplidar_ros` in `src` (see Screenshot above)
- could I just use in my command:
- `view_rplidar.launch` as above? I.e.: `roslaunch rplidar_ros view_rplidar.launch`
- or – also adapted from the tutorial – I could try `roslaunch rplidar_ros rplidar_a1.launch`
- but there is no mentioning of that command so far
I decide to go with the website's solution first:
- Checking if `setup.bash` is in `devel`
- it is
- Using the command `source /home/thomas/catkin_ws/devel/setup.bash`
- no errors or such things
- Then I try the command from the tutorial I am following again: `roslaunch rplidar_ros rplidar.launch`
- that produces the same error
After all, not too surprising: If I understand the command correctly now, I just saw before that the file `rpidar.launch` is not in the folder `rplidar_ros`. So the error is – as they usually do – quite correct.
I try the command once again nonetheless, because I am still in the `devel` folder in the terminal, just to be sure I change to `catkin_ws` and…
- get the same error
So now it is time to try the command obtained from http://wiki.ros.org/rplidar#Launch_File_Examples
- I go with `roslaunch rplidar_ros view_rplidar.launch`
- I hesitate before pressing enter
- As the site states, the command I used before _should_ work, too.
- This means, the new command might work – or not. But the other one should have worked either way, as it is on the website of ROS.
- I try the command now to see the error:
- Same error with the new file I addressed
So, it is time to [[ROS 05-02 Error with Lidar – Summary|summarise and get some distance to the problem]], before I proceed.
---
[[ROS 05-02 Error with Lidar – Summary|👉 Next page]]
# Back to:
[[ROS 04-02 Improvising a Fan for Jetson Nano?]]