Joe Kelly Posted May 2, 2015 Report Share Posted May 2, 2015 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! Quote Link to comment
ensegre Posted May 3, 2015 Report Share Posted May 3, 2015 (edited) 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 May 3, 2015 by ensegre Quote Link to comment
ned Posted May 4, 2015 Report Share Posted May 4, 2015 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.