bugGNU Octave - Bugs: bug #50466, makehgtform function missing


bug #50466: makehgtform function missing

Submitted by:  None
Submitted on:  Mon Mar 6 05:49:33 2017  
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Bob StephensOriginator Email: -unavailable-
Open/Closed: OpenRelease: dev
Operating System: Any

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Mon Mar 13 07:42:17 2017, comment #12:

Thanks Rik. That aspect works. I'm still not managing to successfully use the robotics toolbox function trplot2 to draw a coordinate frame. The toolbox was developed against Matlab so I have some work to do yet.

I think my next step is to try and get the debugger working so I can step through the code. I'm suspecting I'll need to install a Linux partition or VM as my PC's are Windows 10 and I've not had any success with the debugger on them yet. Seems to lock up Octave (and I read the disclaimer when installing Octave re Windows 10).

Bob Stephens <rst26508>
Sun Mar 12 06:13:47 2017, comment #11:

Having different recipes for each object type is definitely beginning to complicate this function. I checked in a cset here (http://hg.savannah.gnu.org/hgweb/octave/rev/a470f7fee1cf) that does more input validation on the object type. It issues a warning if the type should be accepted, like text, but the code hasn't been implemented. The warning is issued only once. Thereafter the unsupported objects are ignored.

Rik <rik5>
Project Administrator
Sun Mar 12 03:47:10 2017, comment #10:

There is a list of allowed types in http://matlab.izmiran.ru/help/techdoc/ref/hgtransformproperties.html

"Children of the hgtransform object. An array containing the handles of all graphics objects parented to the hgtransform object (whether visible or not).

The graphics objects that can be children of an hgtransform are images, lights, lines, patches, rectangles, surfaces, and text. You can change the order of the handles and thereby change the stacking of the objects on the display.

Note that if a child object's HandleVisibility property is set to callback or off, its handle does not show up in the hgtransform Children property unless you set the Root ShowHiddenHandles property to on. "

I had a limited period license for Matlab for a short period but did not get to know it well enough. Looking at the plot example in a text it appears that the position of the text is rotated but not the orientation (Hope that makes sense). Eg X, Y and coordinate frame labels are upright but positioned to correspond to the relevant axis.

Would it be viable as an intermediate option to allow text to be added (or behave as though it had been added) but then ignore it. Something that would allow code built for Matlab to run but with a reduced functionality (not displaying text)?

Bob Stephens <rst26508>
Sun Mar 12 01:45:28 2017, comment #9:

The problem, as noted, is that some graphics objects don't have data properties. The text object is one of them. It has a position property and a rotation property. Instead of just doing matrix multiplication which is what hgtransform does now, one would need to merge the position and rotation information into x,y, and zdata, apply the transform, and then unmerge the data back to position and rotation. That sounds like a lot of work.

Do you know if Matlab allows any object to be parented to an hgtransform? The simplest thing would be a restriction on the allowed object types. If Matlab does accept any object, does it actually transform them all or does it simply ignore ones with no data property. Finally, if it is transforming even text fields then the transform becomes much more complicated as it will need to be a switch statement off of the graphics object type and properties.

Rik <rik5>
Project Administrator
Sat Mar 11 22:56:40 2017, comment #8:

Thanks Rik. I dropped part way into the debugger. I can see the "debug>" prompt but Octave keep getting stuck in a not responding mode.

I'm assuming that working towards getting hgtransform functionality to a point where it deals with all the functionality from matlab is of value and that lessons learned in the .m version will be important for an eventual build in c++ but if the priority is low enough on the big picture that I'm becoming a time waster please let me know.

I added the following to the test_hgtransform.m script just before the for loop. It appears to be failing in at least one of the same spots as the version using trplot2 although I've had to modify the statement from trplot2 as it was relying on structures and calls to other parts of the toolbox. Eg not entirely sure I have it right but somewhat hopeful.
% Modified extract from trplot2 to simulate errors raised from that
h = text(1, 2, 'X', 'Parent', t);
set(h, 'Parent', t);

It's stopping at line 161 of hgtransform.m
orig_data(end).xdata = get (hk, "xdata");

The initial error raised is
error: get: unknown text property data

I'm assuming that the areas where xyz data in the children is dealt with may need some kind of test on data type to handle types without xyz data differently but so far I've not yes succeeded in finding something that works.

From the Workspace panel in Octave (Values appear to be truncated)
orig_data struct 1x7 ...
hnew double 1x1 -13.732
hlist double 1x6 [-6.2230, -7...
hkids double 7x1 [-13.732, -1...
hk double 1x1 -13.732
hgt double 1x1 -12.619
hdel double 1x0 []
double 0x0 []

Bob Stephens <rst26508>
Sat Mar 11 05:40:54 2017, comment #7:

Maybe try

and then run your test code. If it works as expected, you should be dropped in to the debugger at the statement causing an error. At that point you can inspect variables, look at the backtrace, and maybe figure out what is going on.

Rik <rik5>
Project Administrator
Sat Mar 11 05:13:45 2017, comment #6:

The sample Code I posted earlier to test hgtransform appears to work well with the hgtransform.m file Rik so kindly created.

I have found that when trying to use the Robotics Toolbox and the trplot2 function it's failing. I've been trying to work my way through what and where (interesting learning).
I've not been able to find a neat way of providing a simple way to reproduce it without the Toolbox yet.

The errors appear to be around items returned in the "for hk = hlist.'" in xform_data failing when later statements try to extract the xdata. I am wondering if it's because trplot2 appends text data (but don't know enough yet to speak with confidence).

From line 157 of trplot2.m
% label the axes
if isempty(opt.frame)
fmt = '%c';
fmt = sprintf('%%c_{%s}', opt.frame);

% add the labels to each axis
h = text(x1(1), x1(2), sprintf(fmt, 'X'), 'Parent', hg);
if ~isempty(opt.text_opts)
set(h, opt.text_opts{:});
if opt.arrow
set(h, 'Parent', hg);

-- More for Y axis and the frame follow in the code.

As I stated earlier I've not yet worked out how to post a simple test for this without the toolbox. I'll post the output (I think I'm back to original code after lots of try blocks to see if I can isolate the issue)
% label the axes
if isempty(opt.frame)
fmt = '%c';
fmt = sprintf('%%c_{%s}', opt.frame);

% add the labels to each axis
h = text(x1(1), x1(2), sprintf(fmt, 'X'), 'Parent', hg);
if ~isempty(opt.text_opts)
set(h, opt.text_opts{:});
if opt.arrow
set(h, 'Parent', hg);

Bob Stephens <rst26508>
Thu Mar 9 11:07:23 2017, comment #5:

Thanks Rik, I really appreciate that. Tested earlier and the shape generated by the test script rotated nicely. That should get me going on some of the plotting stuff in the robotics toolbox and give me an opportunity to see how that was done.

I have some other bits to chase in behaviours of the Toolbox on Octave but greatly appreciate having a version of the function available.


Bob Stephens <rst26508>
Wed Mar 8 23:22:33 2017, comment #4:

I created a quick m-file version of hgtransform.m on the development branch of Octave (http://hg.savannah.gnu.org/hgweb/octave/rev/aaf91b4f48e4). It seems to work pretty well. Since it is just an m-file you can download it and use it as is.

Rik <rik5>
Project Administrator
Tue Mar 7 10:25:38 2017, comment #3:

I've attached my working files. After doing so I remembered that the version of makehgtform.m that I have so far relies on the robotics toolbox I mentioned earlier so may not make much sense at this point. It creates a 4*4 transformation matrix based on the type passed in.

hgtransform is doing some of what I want but I think I have a notable logic failure in the actual application of the transformation matrix. The parts of the surfaces which make up the group change shape (and size when I include the scale transform) but not in the way I'm expecting.

There is a test structure to drive it based on code snippets for using hgtransform eg (http://matlab.izmiran.ru/help/techdoc/ref/hgtransform.html).

Posting in case this of interest to others either for their own use or for guiding a learner.

I'm using padarray in the listener because I've not yet worked out how to append rows to the bottom of the matrix.

Bob Stephens <rst26508>
Tue Mar 7 06:00:05 2017, comment #2:

Thanks Rik. At this stage I'll try for the hgtransform.m approach, the learning curve on the C++ graphics object primitive looks like it would be a little steep at this point. Is it appropriate to ask "how to" questions here if I get stuck or should that be elsewhere?

I appreciate the hints by the way.


Bob Stephens <rst26508>
Mon Mar 6 19:37:55 2017, comment #1:

The function is known to be missing which is why it is in the unimplemented list. If you try at the command line you get

This is a different, and more appropriate error message, than if the name in question doesn't refer to any known variable or function.

Implementation, ideally, would be in C++ as a new graphics object primitive (like line, or surface).

However, you might be able to work up a replacement in an m-file that uses hggroup. Child graphic primitives can have their parent properties set to an hggroup and you can add the necessary property (Matrix) using addproperty to make the hggroup resemble an hgtransform. After that, you would need to add a callback function that listens for changes on the hgtransform Matrix property (addlistener()). The callback functions would then use the transform Matrix to alter the Data properties of the child objects.

Rik <rik5>
Project Administrator
Mon Mar 6 05:49:33 2017, original submission:

Firstly - I'm a newby to this space so I may have missed something, my apologies if I have.

The Matlab function hgtransform does not appear to exist in Octave or in the function/missing function references I can find. One hit in Octave-4.2.1\share\octave\4.2.1\m\help\__unimplemented__.m on line 690


It's used by some of the plotting functions in Peter Corke's Robotics toolkit (trplot2.m, trplot.m, plot3d.m, Vehicle.m and Shape.m) which are used in the Matlab examples in his text. Eg line 210 in trplot.m https://github.com/petercorke/robotics-toolbox-matlab/blob/master/trplot.m

I'm interested in how to go about adding a feature such as this to Octave (or the toolkit if that makes sense) but at this point don't know enough to make a credible start.

Should hgtransform be added to the list of missing functions?



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #39923:  makehgtform.m added by rst26508 (502B - application/octet-stream - First pass at some of the functionaility for a .m version of hgtransform)
file #39924:  hgtransform.m added by rst26508 (976B - application/octet-stream - First pass at some of the functionaility for a .m version of hgtransform)
file #39925:  test_hgtransform.m added by rst26508 (792B - application/octet-stream - First pass at some of the functionaility for a .m version of hgtransform)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by rst26508 (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Mar 8 23:22:33 2017rik5Release4.2.1=>dev
      Summaryhgtransform function missing=>makehgtform function missing
    Tue Mar 7 10:10:29 2017rst26508Attached File-=>Added makehgtform.m, #39923
      Attached File-=>Added hgtransform.m, #39924
      Attached File-=>Added test_hgtransform.m, #39925
    Mon Mar 6 19:37:55 2017rik5StatusNone=>Confirmed
      Operating SystemMicrosoft Windows=>Any

    Back to the top

    Powered by Savane 3.1-cleanup1