Comments (10)
I did ask the same question over on the forum (https://robodk.com/forum/Thread-Solve-for-a-given-configuration). It looks like you have to solve for all configurations :
robot = rdk.Item("", robolink.ITEM_TYPE_ROBOT)
pose = robot.Pose()
joints = robot.SolveIK_All(pose)
and then filter based on the output of JointsConfig. But the function (at least in Python) does not return the same size of filter as documented
robot.JointsConfig(joints[:,0])
and then you apply the chosen solution to the target's robot joints
I really hope there is a better way to manage this but could not find either
from robodk-api.
This is not really efficient (in terms of computing time)
I have almost 50 targets to setup ......
I will try it. But is there a better way when we know configuration to apply.?
from robodk-api.
I tried the following snippet , It replies with [[ ]] 😟
# This macro shows an example to draw a polygon of radius R and n_sides vertices using the RoboDK API for Python
from robolink import * # API to communicate with RoboDK for simulation and offline/online programming
from robodk import * # Robotics toolbox for industrial robots
import math
# Any interaction with RoboDK must be done through RDK:
RDK = Robolink("localhost",port=20501)
# Select a robot (popup is displayed if more than one robot is available)
robot = RDK.ItemUserPick('Select a robot', ITEM_TYPE_ROBOT)
if not robot.Valid():
raise Exception('No robot selected or available')
Target =RDK.Item("Target_10")
if Target.Valid():
pose = Target.Pose()
joints = robot.SolveIK_All(pose)
print(joints)
from robodk-api.
@c3dff , this not really what I need finally,
I know for each points of my FANUC robot I want to setup : F/N U/D T/B configs.
Here I may receive joints positions .....only . I can't filter anything
from robodk-api.
You can do Mat.list() to return a one dimensional list of doubles. Example:
joints = robot.SolveIK_All(pose)
joints = joints.list() # convert Mat type to list
valid_solution = (len(joints) == 0)
print(joints)
from robodk-api.
To properly find your desired configuration you should use JointsConfig, you can use the first 3 values as [Rear, Lower, Flip] flags. The 4th value is used for turn count on certain robots. This shows an example:
# Retrieve all solutions for a given pose:
all_solutions = robot.SolveIK_All(pose, toolpose, framepose)
joints = []
# Iterate through each solution
for j in all_solutions:
# Retrieve flags as a list for each solution
conf_RLF = robot.JointsConfig(j).list()
# Breakdown of flags:
rear = conf_RLF[0] # 1 if Rear , 0 if Front
lower = conf_RLF[1] # 1 if Lower, 0 if Upper (elbow)
flip = conf_RLF[2] # 1 if Flip , 0 if Non flip (Flip is usually when Joint 5 is negative)
# Look for a solution with Front and Elbow up configuration
#if conf_RLF[0:2] == [0,0]:
if rear == 0 and lower == 0:
print("Solution found!")
joints = j
break
from robodk-api.
Thanks, but the joint values I can get with SolveIk_All() are not the same as what is displayed in Robodk (Bug ?)
joints = robot.SolveIK_All(pose,robot.PoseTool(),reference=framepose.Pose())
but robot joint values correspond to robot tab values:
from robodk-api.
To remove the possibility of pose reference error, I wrote this generic filter (not the prettiest code, but should work). It takes a target ITEM as an input and applies the filter in the same way the GUI allows (Both=None as args to fd, ud and fn). for those args, the value mirrors the output of JointsConfig
so [0,0,0] means [front, upper arm and non-flip].
I'd really wish to have a low-level command to the solver. Having to solve for all is very inefficient for large target counts.
def filter_configurations(target, fb=None, ud=None, fn=None):
robot = target.getLink()
target_pose_abs = target.PoseAbs()
flange_pose = target_pose_abs * robodk.invH(robot.PoseTool())
pose = robodk.invH(robot.PoseAbs()) * flange_pose
joints_list = robot.SolveIK_All(pose)
njoint = robot.Joints().size(dim=0)
valid_configs = []
for i in range(joints_list.size(dim=1)):
sol = joints_list[0:njoint, i]
# conf_RLF (int list)
# robot configuration as a list of 3 ints: [REAR, LOWER-ARM, FLIP]
# [0,0,0] means [front, upper arm and non-flip] configuration.
conf_rlf = robot.JointsConfig(sol)
results = list(map(int, conf_rlf.list()))
valid = True
# Checks front-rear
if fb is not None:
test = results[0] == int(fb)
valid = valid and test
# Checks up-down
if ud is not None:
test = results[1] == int(ud)
valid = valid and test
# Checks flip-nonflip
if fn is not None:
test = results[2] == int(fn)
valid = valid and test
if valid:
valid_configs.append(sol.list())
return valid_configs
from robodk-api.
Ok, we are not so far from what I need.
Now, to activate my configuration, I have to set point as a Joint Target instead of cartesian and give joint positions corresponding to desired configuration?
from robodk-api.
I'm sorry we never got back to you on this thread.
When programming robots I recommend you to clearly distinguish between joint movements given joint values and linear movements using Cartesian data. Using the RoboDK API you can set the joint values of a target. If the target is a Cartesian target, the joint values will only be used to calculate the configuration flags when the program is generated.
I recommend you to contact us via our Forum to make sure we don't miss your questions:
https://robodk.com/forum/
Albert
from robodk-api.
Related Issues (20)
- Wrong string format for double type HOT 4
- Access real robot camera and gripper. HOT 1
- C API: RoboDK_Collisions does not appear in robodk_api_c.h HOT 1
- C API: Extraneous console prints present in robodk_api_c.c HOT 1
- Problem in controlling the robotic arm from the software HOT 3
- Possible to overwrite motion planning module as a plugin? HOT 1
- Using RoboDK Docker image HOT 3
- Difference between Disconnect() and Finish() HOT 1
- RoboDK License in docker container HOT 1
- MakeProgram freeze HOT 6
- Copied Rotational Matrices in Degree and not Rad HOT 2
- RoboDK Python interface does not support v3.11 HOT 1
- Incorrect CMake build instructions in ReadMe HOT 1
- Python API: In robomath.py, multiple issues with transl function HOT 1
- MoveJ can not simulate HOT 1
- ERROR: Package 'robodk' requires a different Python: 3.8.10 not in '<3.5' HOT 9
- Asking about online programming for Denso robot arm, not included in RoboDK library HOT 1
- robolink.Robolink modifies list passed to args HOT 2
- `robolink.Robolink.ShowMessage()` prints message in command line HOT 2
- robolink.py type-hinting missing for setAsJointTarget and setAsCartesianTarget methods HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robodk-api.