catkin_make: command not found when using SSHClient().exec_command to operate in a cloud server

16 views Asked by At

everyone. I'm tying to upload ros packages to a cloud server and run them using paramiko.SSHClient().exec_command(). The function is attached below:

def connectMyServer_and_launch(zip_paths, server_ip, username, password, port, launch_file_dir, env_script, magic_int, env_command= ""):
    ssh_client = paramiko.SSHClient()
    ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh_client.connect(hostname=server_ip, username=username, password=password, port=port)

    stdin, stdout, stderr = ssh_client.exec_command("mkdir -p ~/catkin_ws/src", get_pty=True)
    with SCPClient(ssh_client.get_transport()) as scp:
        # transfer all the zip files to the server's workspace
        for zip_file in zip_paths:
            scp.put(zip_file, '~/catkin_ws/src')

        scp.put(env_script, "~/setup.bash")

        # use SSH to unzip them to the catkin workspace
        stdin, stdout, stderr = ssh_client.exec_command("cd ~/catkin_ws/src && for i in *.zip; do unzip -o \"$i\" -d . ; done " , get_pty=True)

        # use SCP to upload the launch script
        scp.put("/tmp/to_cloud" + magic_int + ".launch", "~/catkin_ws/src/FogROS/launch/to_cloud.launch")

        # catkin_make all the uploaded packages
        stdin, stdout, stderr = ssh_client.exec_command('cd ~/catkin_ws && catkin init && catkin build && source ./devel/setup.bash' , get_pty=True)

However, the catkin build command failed. The feedback was

CMake Error at /home/username/catkin_ws/build/catkin_tools_prebuild/CMakeLists.txt:12 (message): The catkin CMake module was not found, but it is required to build a linked workspace.  To resolve this, please do one of the following, and try building again.

I've already installed ros noetic and set up the environment, and if I ssh the server in a terminal, I can successfully run catkin build under ~/catkin_ws. I have no idea why this error or how to fix it. Could someone help me? Really appreciate it!

0

There are 0 answers