Jump to content

Making sub-programs with picture objects


Recommended Posts

Hello all,

 

I'm a mentor for a FRC Robotics Team.  For the summer, I want to try to make a VI that is able to create sub-programs for the autonomous period.  Basically, there would be this canvas that the user could move the "robot" (aka rectangle) around, and it would record its movements and "translate" them into "motor code".

 

For instance: I want my robot to go straight for about 3 feet, rotate 90 degrees clockwise, and go another 3 feet.  I would take the rectangle, drag it up an equivalent 3 feet (maybe using a grid pattern to show 0.5 feet increments), rotate the rectangle 90 degrees clockwise, then drag it another 3 feet.

 

This is the big picture.  Right now, I want to know if it's possible to have a user drag a picture (such as a rectangle) and have the program where it is on a coordinate plane.

 

Thanks!

Link to comment

This reminds me something I did years ago, perhaps in a very suboptimal way. I created a set of custom controls with funny decorations, and the user was able to drag them around on the FP and place them. The idea was to give the impression of "probes" which the user could place over a scheme of a plant. All it take was to handle mouse down events on those controls, and read coordinates as long as the mouse button was pressed, which was polled. There was even the notion of a "home" (bring back all probes in the toolbox, activate only probes which have been taken out, etc.), based on coordinate parsing.

This may be a solution for translations, but it won't cover sprite rotations.

If not I can think only at the hard way -- use a picture control and draw objects inside it, handle every possible mouse action with proper object redraws -- looks tedious.

Edited by ensegre
Link to comment

I think a picture control is the way to go. I would start with a simpler interface than dragging the item around on the screen. Instead you might have buttons for forward/back along with a control for the distance to move, and also a rotation button with number of degrees. Another option would be to use the joystick. For one FIRST team I mentored, we made a simple demo where they could move a shape around within a picture control using the joystick. If your image is simple (for example a rectangle), rotation is not too complicated, you might start with the "2D Cartesian Coordinate Rotation" function.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.