SketchUcation Premium Membership

 

 

SketchyPhysics Keyboard Controls

Moderator: CPhillips

SketchyPhysics Keyboard Controls

Postby ashscott » Wed Apr 04, 2012 12:02 pm

Hi all,

discussion on sketchyphysics sure seems to have cooled off since I was last in this part of the forum 2 years ago - thats a shame, over the last few days I have been using SP to model a proposed walking machine and it really is an extraordinary plugin.

I have a couple of questions for you folks that are more familiar with SP and Ruby:

1) Using (rightx) how do I get servo to sit in a position and stay there without spring loading back to its midway point? I am lifting a leg with the servo, pressing one arrow raises the leg and pushing the opposing arrow lowers the leg but if I release the arrow at any time the leg springs back to the middle position. How can I set things up so the leg maintains it's position when I release the arrow key? Currently the controller says this:
Code: Select all
slider('A2_Tilt',0)+(rightx)


2) Is there a way to apply the same set of keys for certain objects and toggle between them, for example my walking machine has four legs. I can use (rightx) and (righty) to lift and place one leg - is there a way that I can set up a toggle function to apply those keys to each leg in real time so I can move each one individually? IE press spacebar so that the (rightx) and (righty) functions apply to the next leg on the machine?

Any help is much appreciated - I love the plugin and would pay for it if it would encourage Cphillips and co in their endeavours (you can't work for free) ;)

Thanks

Ash
Google Certified Geo-Developer
User avatar
ashscott
Premium Member
Premium Member
 
Posts: 165
Joined: Sun Apr 26, 2009 11:20 pm
Location: New Zealand
Name: Ash Scott
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate

Re: SketchyPhysics Keyboard Controls

Postby ashscott » Sat Apr 14, 2012 6:03 am

Answers to these questions:
1) Use a motor not a servo
2) Toggling between keys looks something like this:
Code: Select all
if key("m")==1
@B1_Tilt=(righty) and @B1_Twist=(0.5-rightx) and @B1_Ext=key("b")
elsif key("m")==0 and key("n")==0
@stick=0.5-(righty)

If I hold down ("m") the joystick controls a different set of functions than if I hold down ("n"). I also have another set of functions for the joystick if no key is pressed so I have three joysticks in one.

"m" and "n" have been assigned to my second joystick using the software 'joytokey' which I highly recommend. It allows you to set functions to the keyboard but then run them through a second joystick to your primary joystick.

Thus, I am running my sketchyphysicks sim with a logitech attack3 joystick in each hand.

It is an industrial simulation and I haven't seen anything else like it done online. I can't share more because its under NDA but if anyone wants help with something like this then let me know.

Ash
Google Certified Geo-Developer
User avatar
ashscott
Premium Member
Premium Member
 
Posts: 165
Joined: Sun Apr 26, 2009 11:20 pm
Location: New Zealand
Name: Ash Scott
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate

Re: SketchyPhysics Keyboard Controls

Postby ashscott » Tue Apr 24, 2012 8:51 am

There is a much better answer than using a motor to place a joint where you want it - you need to use a servo and a little ruby script

Step1: place your servo within the group you want to move and attach it to a base group
Step2: select the servo and open the sketchyphysics UI
Step3: within the UI apply the following settings
[list=]min:0
max:1
accel:4000
damp:1000
controller:@servo1 (you can actually call it anything starting with @
[/list]
Step4: Select the base of your model and open the sketchyphysics UI
Step5: place the following rubyscript in there:
Code: Select all
if frame<1.00
@servo1=0.00
end
# this allows servo to incrementally increase based on joystick input (righty) you can change it to any of the joystick axes
@servo1+=(0.5-righty)
# this sets range of movement for the servo as it is not set in the servo's UI
if @servo1>45;@servo1=45;end
if @servo1<-45;@servo1=-45;end

It took me a long time to work this out (reverse engineering another model) so I am more than happy to help anyone out with it if these instructions are too hard to follow.

I believe this is a very powerful function in sketchyphysics and I have only seen it in one model in the 3DWH
Google Certified Geo-Developer
User avatar
ashscott
Premium Member
Premium Member
 
Posts: 165
Joined: Sun Apr 26, 2009 11:20 pm
Location: New Zealand
Name: Ash Scott
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate

Re: SketchyPhysics Keyboard Controls

Postby DL xyz » Sun Apr 14, 2013 3:52 pm

You should just put hinge to limit movement, and motor to move. Put high damp and high speed on motor to make it stand still in position. That is how I make my models, which you can see on my site: http://forsa07.wix.com/dl-design#!design/cc9
DL xyz
 
Posts: 2
Joined: Tue Mar 12, 2013 7:23 pm
Name: Dragan
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Artisan Organic Toolset - a set of powerful organic modeling tools.

Premium Members get 20% discount!

Ad Machine
Robot
 
Posts: 2012


Return to SketchyPhysics

Who is online

Users browsing this forum: No registered users and 1 guest