Skip to content

Fix: handle exception in get_link_names for single-link group #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 502 additions & 0 deletions src/compas_fab/robots/newenv/Scripts/Activate.ps1

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions src/compas_fab/robots/newenv/Scripts/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file must be used with "source bin/activate" *from bash*
# You cannot run it directly

deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi

# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null

if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# unset irrelevant variables
deactivate nondestructive

# on Windows, a path can contain colons and backslashes and has to be converted:
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
export VIRTUAL_ENV=$(cygpath "D:\LOCAL-CODE COPY\compas_fab\src\compas_fab\robots\newenv")
else
# use the path as-is
export VIRTUAL_ENV="D:\LOCAL-CODE COPY\compas_fab\src\compas_fab\robots\newenv"
fi

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/Scripts:$PATH"
export PATH

# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(newenv) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(newenv) "
export VIRTUAL_ENV_PROMPT
fi

# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
34 changes: 34 additions & 0 deletions src/compas_fab/robots/newenv/Scripts/activate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off

rem This file is UTF-8 encoded, so we need to update the current code page while executing it
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
set _OLD_CODEPAGE=%%a
)
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" 65001 > nul
)

set VIRTUAL_ENV=D:\LOCAL-CODE COPY\compas_fab\src\compas_fab\robots\newenv

if not defined PROMPT set PROMPT=$P$G

if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%

set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=(newenv) %PROMPT%

if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%

set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
set VIRTUAL_ENV_PROMPT=(newenv)

:END
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
set _OLD_CODEPAGE=
)
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/cftp.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/ckeygen.exe
Binary file not shown.
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/conch.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions src/compas_fab/robots/newenv/Scripts/deactivate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
)
set _OLD_VIRTUAL_PROMPT=

if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)

if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
)

set _OLD_VIRTUAL_PATH=

set VIRTUAL_ENV=
set VIRTUAL_ENV_PROMPT=

:END
Binary file added src/compas_fab/robots/newenv/Scripts/f2py.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/pip.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/pip3.12.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/pip3.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/python.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/pythonw.exe
Binary file not shown.
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/tkconch.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/trial.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/twist.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/twistd.exe
Binary file not shown.
Binary file added src/compas_fab/robots/newenv/Scripts/wamp.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions src/compas_fab/robots/newenv/pyvenv.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
home = C:\Program Files\Python312
include-system-site-packages = false
version = 3.12.4
executable = D:\myenv\myenv\Scripts\python.exe
command = D:\myenv\myenv\Scripts\python.exe -m venv D:\LOCAL-CODE COPY\compas_fab\src\compas_fab\robots\newenv
10 changes: 8 additions & 2 deletions src/compas_fab/robots/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,14 @@ def get_link_names(self, group=None):
base_link_name = self.get_base_link_name(group)
end_effector_link_name = self.get_end_effector_link_name(group)
link_names = []
for link in self.model.iter_link_chain(base_link_name, end_effector_link_name):
link_names.append(link.name)
if not base_link_name or not end_effector_link_name:
raise ValueError("Invalid base or end effector link name for the specified group.")
try:
for link in self.model.iter_link_chain(base_link_name, end_effector_link_name):
link_names.append(link.name)
except Exception as e:
raise Exception(f"No chain found between the specified elements: {str(e)}")

return link_names

def get_link_names_with_collision_geometry(self):
Expand Down
18 changes: 18 additions & 0 deletions src/compas_fab/robots/test_robot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Import necessary modules
try:
from compas_fab.robots.ur5 import Robot # Attempt to import the UR5 robot directly
robot = Robot() # Instantiate the UR5 robot
except ImportError: # Catch the specific ImportError
from compas_fab.robots import RobotLibrary # Fall back to RobotLibrary
robot = RobotLibrary.ur5() # Instantiate the UR5 robot from the library

# Check if robot has been initialized successfully
if robot:
# List all group names in the robot model
print("Available Groups:", robot.group_names) # Print available group names
else:
print("Failed to initialize the robot.")

if __name__ == "__main__":
# Place the script's main code here if needed
pass # Placeholder for any additional code