Home Questions how can i call x, y position value from target table

how can i call x, y position value from target table

DWQA QuestionsCategory: KINARM End-Point Labhow can i call x, y position value from target table
Yihui Xu asked 4 years ago
I am looking to make the home position a variable that I can manipulate in the KINARM, but as of right now I am hard coding the home position. Is there any way to define the x and y coordinates of the home position as variables in Simulink (i.e., col_x, col_y), so that I can input the actual values later on in the KINARM?
1 Answers
Koloman Varady Staff answered 4 years ago
Hi Yihui, The way I would do this is to use the Target_Table and set the x-y values there in the first 2 columns. In the Trial_Protocol, you could create a column that would set the row you wanted to use to set your x-y coordinates. You can then use a Stateflow output to a selector to select the row of the Target Table and use the col_x and col_y constants (already defined in every Kinarm task) to pick out the x and y from the task protocol and modify your stimuli. I've attached a picture of what that might look like Cheers, Koloman
Yihui Xu replied 4 years ago

Thanks! but i still wonder so how can i get get target_Table first?

Koloman Varady Staff replied 4 years ago

Create a From tag (you can find the From block in the Library Browser). Then when you open it, click “UpdateTags” and then the Goto tag drop down will have a list of a whole bunch of available tags (these are the ones we provide for you use – you can see them described in the task programming guide in section 10.9 Available ‘Tags’ (From and Goto Blocks), Target_Table is one of the available tags and it contains a matrix that corresponds to the entire target table in your task protocol.

You can create your own Goto tags and corresponding From tags. Having a Goto and a From is the same thing as drawing a line between the two points. It’s just not as messy.

The kinematics are available from the From KINdata_bus, for example.

Yihui Xu replied 4 years ago

if i want to use selector to output an array called homeXY, homeXY[0] is the x value of home position, homeXY[1] is the y value of home position so that i can use the value in simulink, then what output size value should i put in the selector in your picture?

Koloman Varady Staff replied 4 years ago

It’s already set up that way. The way it’s set up in the picture is it outputs a two element vector, [col_x col_y]. If you look in the Parameter Table Defn block Target Table tab, col_x = 1 and col_y is a constant = 2.

The selector (as set up there), will go to the Target Table get the elements Target_Table(home_target_row, 1:2). If you plug the output from the selector into a MATLAB function (you could call the input variable homeXY and you’ll have access to that 2 element vector.

As well, in Simulink (outside of default C based Stateflow), arrays are indexed starting at 1.

Cheers,
Koloman

Yihui Xu replied 4 years ago

if i want to use selector to output an array called homeXY, homeXY[0] is the x value of home position, homeXY[1] is the y value of home position so that i can use the value in simulink, then what output size value should i put in the selector in your picture?

Yihui Xu replied 4 years ago

But when i try to call homeXY[2], the simulink shows coder error: Subscript [2] out of range for matrix Input Data ‘homeXY’ (#1621). Valid subscript range is 0…1 Please refer to object.

Yihui Xu replied 4 years ago

btw, do u know how can i upload images on this forum? so that i can describe my problem more clearly.

Koloman Varady Staff replied 4 years ago

If you edit a comment, there’s an icon for inserting images that are uploaded to the Internet.

You can always send images or models to our support email (support@bkintechnologies) as well if you want to be more detailed.