We want to get a joint pose array into the scripting code. Have tried reading a port directly, and the program wandered off into Never-Never-Land and didn't come back. Tried returning it from a method, and got similar behavior. Is this possible and if so, how do you do it?
We want to do something like this.
{{{
export function MoveRelative(double j1, double j2, double j3, double j4, double j5, double j6, double j7, double t)
{
var array pose(7)
set pose = getnAxesPosition_meas() // a method returning nAxesSensorPosition_port
// set pose = nAxesSensorPosition.Get() // not work
set pose[0] = pose[0] + j1
set pose[1] = pose[1] + j2
set pose[2] = pose[2] + j3
set pose[3] = pose[3] + j4
set pose[4] = pose[4] + j5
set pose[5] = pose[5] + j6
set pose[6] = pose[6] + j7
do MoveToPose(pose, t)
}
}}}
Thanks
S
How can you return an array into a script program
On Friday 30 May 2008 22:21:51 snrkiwi wrote:
> We want to get a joint pose array into the scripting code. Have tried
> reading a port directly, and the program wandered off into Never-Never-Land
> and didn't come back. Tried returning it from a method, and got similar
> behavior. Is this possible and if so, how do you do it?
An incredible st*d bug in the type system checked in an incredible st*d way if
the assignment was valid: it checked for the opposite.
$ svn di src/TemplateTypeInfo.hpp
Index: src/TemplateTypeInfo.hpp
===================================================================
--- src/TemplateTypeInfo.hpp (revision 29325)
+++ src/TemplateTypeInfo.hpp (working copy)
@@ -342,8 +342,8 @@
{
bool operator()(const T& v1, const T& v2) const
{
- // v1 may be assigned to v2 if it has sufficient capacity.
- return v1.capacity() < v2.size();
+ // v2 may be assigned to v1 if it has sufficient capacity.
+ return v1.capacity() >= v2.size();
}
};
$ svn ci src/TemplateTypeInfo.hpp -m"Fix assignment of fixed-size arrays."
Sending src/TemplateTypeInfo.hpp
Transmitting file data .
Committed revision 29353.
$ svn ci tests/types_test.cpp -m"Test also for array assignment."
Sending tests/types_test.cpp
Transmitting file data .
Committed revision 29354.
It's like no-one has been using this software before :-)
Peter
How can you return an array into a script program
On Friday 30 May 2008 22:21:51 snrkiwi wrote:
> We want to get a joint pose array into the scripting code. Have tried
> reading a port directly, and the program wandered off into Never-Never-Land
You mean, the function gets into the 'Error' status ? (the exported function
should 'fail' when invoked as a command)
> and didn't come back. Tried returning it from a method, and got similar
> behavior. Is this possible and if so, how do you do it?
I could reproduce this behaviour with a port. Looks like a bug. I could remove
the error by declaring the array as:
var array pose; // which always works
You could also have written
var array pose = array(7); // (not) real-time...
See also in the 'array' section here:
Peter
>
> We want to do something like this.
> {{{
> export function MoveRelative(double j1, double j2, double j3, double j4,
> double j5, double j6, double j7, double t) {
> var array pose(7)
> set pose = getnAxesPosition_meas() // a method returning
> nAxesSensorPosition_port // set pose = nAxesSensorPosition.Get() // not
> work
> set pose[0] = pose[0] + j1
> set pose[1] = pose[1] + j2
> set pose[2] = pose[2] + j3
> set pose[3] = pose[3] + j4
> set pose[4] = pose[4] + j5
> set pose[5] = pose[5] + j6
> set pose[6] = pose[6] + j7
> do MoveToPose(pose, t)
> }
> }}}
>
> Thanks
> S