[indemind binocular inertial camera debugging] command cannot be found after sudo, environment variable problem

Question 1

report error

kanhao100@ubuntu-x86 ~ % roslaunch imsee_ros_wrapper start.launch
RLException: [start.launch] is neither a launch file in package [imsee_ros_wrapper] nor is [imsee_ros_wrapper] a launch file name
The traceback for the exception was written to the log file

solve

source /home/kanhao100/IMSEE-SDK/ros/devel/setup.zsh 

Question 2

report error

kanhao100@ubuntu-x86 ~ % roslaunch imsee_ros_wrapper start.launch              
... logging to /home/kanhao100/.ros/log/f3bd5ef2-d2f4-11ed-ba51-f09e4ab0090f/roslaunch-ubuntu-x86-8178.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu-x86:36885/

SUMMARY
========

PARAMETERS
 * /imsee/imsee_wrapper_node/enable_depth: False
 * /imsee/imsee_wrapper_node/enable_detector: False
 * /imsee/imsee_wrapper_node/enable_disparity: False
 * /imsee/imsee_wrapper_node/enable_point: False
 * /imsee/imsee_wrapper_node/enable_rectified: False
 * /imsee/imsee_wrapper_node/framerate: 50
 * /imsee/imsee_wrapper_node/imu_frequency: 100
 * /imsee/imsee_wrapper_node/resolution_index: 1
 * /rosdistro: melodic
 * /rosversion: 1.14.13

NODES
  /imsee/
    imsee_wrapper_node (imsee_ros_wrapper/imsee_wrapper_node)

ROS_MASTER_URI=http://localhost:11311

process[imsee/imsee_wrapper_node-1]: started with pid [8193]
[ INFO] [1680618804.215470243]: Initializing nodelet with 8 worker threads.
Module Parameters Load Fail!
[imsee/imsee_wrapper_node-1] process has died [pid 8193, exit code -11, cmd /home/kanhao100/IMSEE-SDK/ros/devel/lib/imsee_ros_wrapper/imsee_wrapper_node __name:=imsee_wrapper_node __log:=/home/kanhao100/.ros/log/f3bd5ef2-d2f4-11ed-ba51-f09e4ab0090f/imsee-imsee_wrapper_node-1.log].
log file: /home/kanhao100/.ros/log/f3bd5ef2-d2f4-11ed-ba51-f09e4ab0090f/imsee-imsee_wrapper_node-1*.log
[imsee/imsee_wrapper_node-1] restarting process
process[imsee/imsee_wrapper_node-1]: started with pid [8222]
[ INFO] [1680618814.521321294]: Initializing nodelet with 8 worker threads.
Module Parameters Load Fail!
[imsee/imsee_wrapper_node-1] process has died [pid 8222, exit code -11, cmd /home/kanhao100/IMSEE-SDK/ros/devel/lib/imsee_ros_wrapper/imsee_wrapper_node __name:=imsee_wrapper_node __log:=/home/kanhao100/.ros/log/f3bd5ef2-d2f4-11ed-ba51-f09e4ab0090f/imsee-imsee_wrapper_node-1.log].
log file: /home/kanhao100/.ros/log/f3bd5ef2-d2f4-11ed-ba51-f09e4ab0090f/imsee-imsee_wrapper_node-1*.log

problem analysis

This problem is caused by the lack of root privileges. The SDK of indemind camera needs root privileges to run (very speechless), so you need to add sudo, or sudo suwait for the command

Question 3

report error

Command does not exist after running with root privileges

kanhao100@ubuntu-x86 ~ % sudo roslaunch imsee_ros_wrapper start.launch
[sudo] kanhao100 的密码: 
sudo: roslaunch:找不到命令

problem analysis

This problem is caused by problems with environment variables. In general, sudocommands use the root user's environment variables, not the current user's environment variables. This problem occurs if the current user's environment variable already contains the required path, but the root user's environment variable does not.
The example illustrates the difference between the root environment and the normal user environment:

kanhao100@ubuntu-x86 ~ % cmake -version                               
cmake version 3.17.0
kanhao100@ubuntu-x86 ~ % sudo cmake -version
cmake version 3.10.2

run:

sudo -E roslaunch <package> <launch_file>

This command will use the environment variables of the current user to run the roslaunch command, thus solving the problem that the command cannot be found.

If it still prompts that the command cannot be found

Paths can be added by editing sudo's configuration file. Open a terminal and enter the following command:

sudo visudo

This opens the sudo configuration file. Add the following lines at the end of the file:

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/ros/melodic/bin"

Where /opt/ros/melodic/bin is the path where roslaunch is located. Save and exit the file, then try running the command again.
If you don't know the path where the command is located, you can use the following command to find it:

which roslaunch

This will show the path where the command is located.

Question 4

report error

kanhao100@ubuntu-x86 ~ % sudo -E roslaunch imsee_ros_wrapper start.launch
Traceback (most recent call last):
  File "/opt/ros/melodic/bin/roslaunch", line 34, in <module>
    import roslaunch
ImportError: No module named roslaunch

problem analysis

It is speculated that it is still a problem of environment variables. Although roslaunch was added to the trusted path in the previous question 3, it still needs environment variables related to the Python interpreter during execution. These environment variables may also have changed.

Final solution:

kanhao100@ubuntu-x86 ~ % sudo su -
root@ubuntu-x86:~# source /home/kanhao100/IMSEE-SDK/ros/devel/setup.bash
root@ubuntu-x86:~# roslaunch imsee_ros_wrapper start.launch

suBoth the and su -commands can be used to switch users, but there are some differences between them.

sucommand is for switching users, but it doesn't fully switch to the new user's environment variables. That is, it preserves the current user's environment variables instead of using the new user's environment variables. This can cause issues such as command not found errors when using commands from new users.

su -command is also used to switch users, but it completely switches to the new user's environment variables. That is, it uses the new user's environment variables instead of preserving the current user's environment variables. This avoids issues with commands not being found and ensures that the correct environment variables are used to run the command.

Guess you like

Origin blog.csdn.net/kanhao100/article/details/129963820