Jun 182011
 

To aid my never-ending quest to remember the things I learn about programming – I’ve decided to make this post as a place to leave little functions and crap that I always forget and are way too stupid to have to figure out more than once.

It’ll grow, I’m constantly learning things I forgot.

######################################
################ WARNING: ############
############## STUPID CODE ###########
######################################
#### PLEASE DO NOT LEARN ANYTHING ####
######################################

def sbh_within(x,y,d):
###---CHECK IF x-d <= y <= x+d
 if x-d <= y and x + d >= y:
 return True
 else: return False

def sbh_center2d(Ax, Ay, Bx, By):
###---GET CENTER BETWEEN TWO 2D POINTS
    Cx = Ax + (Bx - Ax)/2
    Cy = Ay + (By - Ay)/2
    return Cx, Cy

def sbh_dist2d(Ax, Ay, Bx, By):
###---GET DISTANCE BETWEEN TWO 2D POINTS
    Cx = Bx - Ax
    Cy = By - Ay
    return Cx, Cy

def sbh_hypot(a, b):
    c = sqrt(a*a+b*b)
    return c

def sbh_getAngle2d(A, B):
###---RETURNS HEADING FROM A TO B
    opp = B.y - A.y
    adj = B.x - A.x
    hyp = hypot(opp, adj)
    s = asin(opp/hyp)
    c = acos(adj/hyp)
    if B.x >= A.x and B.y >= A.y: r = s-pi/2
    if B.x <= A.x and B.y >= A.y: r = c-pi/2
    if B.x <= A.x and B.y <= A.y: r = (pi/2)-s
    if B.x >= A.x and B.y <= A.y: r = -(pi/2)-c
    return r

def sbh_si(num):
###---RETURNS SIGN OF A NUMBER
    if num>=0: return 1
    if num<0: return -1

def sbh_wrapAng(x):
###---WRAP EULER ANGLES (-pi <= a <= pi)
    p360 = pi*2
    f = x - (p360)*floor((x+pi)/p360)
    return f

—OTHER BLENDER PYTHON API NOTES—
Most of these are issues I’ve run into with and without solutions.

– Can not add game logic bricks via. python API. [SOLVED]
– Can not access poseLib data with bpy.data, only bpy.ops functions and none to read pose data.
– Voxel data files: .raw/.bvox – can’t use multi-frame data. Only 64x64x64 grid size works.

– active object – accessible with “bpy.context.scene.objects.active = ob”

 

May 272011
 

Trying to learn more about making controllers for actual robots, but the bge is cheaper than buying components. Thought I’d start simple so I made a little differential drive robot and some control stuff. Wanted to spice it up so I gave him a little scoop so he could pitch a ball up.

For now the drive control is completely retarded and the target (ball) sensor is arbitrary so it doesn’t mimic a real sensor like I meant it to. Working on the motor controls more right now.

.blend file (b2.57b)

The bot gets the ball, then goes to the ‘goal’, then pitches the ball up. No aiming yet, doesn’t even work real hard to point in the right direction. Sort of a spaz shot.

Actually this was an offshoot of some problems I was having while trying to make a 0G ‘satellite’ type bot. So I thought I’d limit myself to 2D for now.

May 272011
 

Today I commend one Giorgio A. Tsoukalos. The first sentence of his wikipedia page says it all.

“Giorgio A. Tsoukalos (born March 14, 1978) is a Swiss born Greek writer and television presenter specializing in ancient astronaut theory.”

Not that I don’t think ancient astronaut theory is fun and interesting, even Carl Sagan suggested it deserved a serious look.  I just think this guy is like the Tommy Chong of space advocacy.

Then again maybe I’m worse- he’s just telling a fun story. I’m saying if we don’t start building spaceships like Noah on steroids then we’re all going to die. Yeah, I’m worse.

So I hereby rescind the ‘Kook of the Month’ award. That was quick.

May 242011
 

GOAL:
To get a photo of Blender running in space. Or if one exists, to make lots more.

REASONS:
• Lots! Why not? It’d be really cool!
• To raise the profile of Blender as a tool for education.
• To cultivate awareness, interest, and support for space science and technology.
• To create more opportunities for those of us who are gravitationally challenged to participate and contribute to space science and technology.
• To effectively synergize backwards overflow.

HOW TO ACHIEVE THIS GOAL?
Recruit Suzanne’s Space Monkey Corps! A small army of artists, game designers, developers, coders, kooks, quacks, and nerds, ready and willing to work on small blender projects that an astro/cosmonaut might use in space. Then work on said projects for said ‘nauts. Then ask them to take a picture of themselves using it in space for us.

POSSIBLE PROJECTS:
• Artistic renderings/animations for space education and advocacy.
• Visualizations of data gathered from various research.
• Reaction time, concentration, coordination, or memory testing ‘games’ for cognitive experiments.
• Data logging ‘games’ to allow versatile input of data from inflight experiments. For example an experiment where a mission specialist must observe several insect behaviors in a short span of time. A ‘game’ might be setup with multiple timers and key inputs to report certain behavior ‘events’, results are logged for later analysis and/or visualization.
• Real time visualization of data from external devices connected by tcpip/usb/bluetooth.
• Earth training simulations for experiments to be performed in 0G.
• <insert cool idea I haven’t thought of here>

HOW TO PROCEED (EXTREMELY SIMPLIFIED)
• Make a post with lots of bullet points.
• Get comments from all the brilliant blender people out there to see if this is just crazy or not.
• Volunteers sign up and specify their areas of interest and abilities. (for now just reply to this post and say you’re in and what you’re awesome at)
• Maybe some kind of demo reel / 30 second spot to get the idea out. (beyond the Blenderverse)
• Contact every possible space agency, business, and advocacy group and see what kinds of projects might be useful for currently planned or possible future missions.
• When potential projects arise, open requests will be made to volunteers. Organize work on these projects.
• Stare at the cool pics of Blender running in space and bask in the awesomeness.

WHAT I WILL DO (AND WHO AM I ANYWAY?)
I’m just a Blender guy obsessed with space. Here is some of the stuff I’ve done with Blender. Nothing revolutionary, but I like to think I contribute.
I’m very passionate about open source in general. Somewhere between passion, vanity, and delusion I decided that this would be a good idea and that I am somehow qualified to crank up the mission.
For now my plan is to make this post, let it percolate, and meanwhile compile information we need to know to make this happen. Stuff like finding out about existing ISS crew data services. For instance, could a crew member easily download a .blend file aboard the ISS from the internet? Does the ISS use standard wifi/bluetooth protocols or something else. What hardware OS/specs are normally flown? Does the crew fly with personal laptops? What kind of security restrictions, if any, might we need to consider, what can we do to satisfy the security requirements?
Once ‘The Corps’ materializes a little I’ll start writing to the organizations that can help to get the ball rolling, offer our capabilities and announce the mission. Basically try to get the attention of people who fund, fly or live in space and see what they say.
Once projects arise, I’d be happy to organize any projects that are my league, but I’m not sure what league I’m in, so I’d be just as happy to hand off to any of the masters and gurus who are in leagues that make my league look silly.

THOUGHTS:
I realize this is a pretty lofty goal and might look a little naive. Maybe it is. Even so, space travel captures the imagination, and I think the world is in desperate need of imagination. Students from elementary through graduate school have designed experiments that have actually been flown in space. This could be an opportunity to open a whole other avenue for student/amateur participation in space programs, especially since there’s no delta-V required to put a .blend file in orbit. Though it could and probably will take a long time to get this going, there is actually a small chance it could take off very quickly. Technologically the first ‘Blender in Space’ pic could happen overnight. I’m not pinning any hopes on that, just deserves saying.

WHAT THIS IS NOT:
Just to clarify, I’m NOT suggesting that Blender be a part of any critical functions. Nothing remotely related to flight controls, power, navigation, life-support, or anything like that. We’re talking about little stuff here, experiments and tests and such that could involve a consumer grade laptop or netbook.
Also – this is NOT a request for doctored photos pasting a Blender screencap on an astronauts computer screen. If this works each image would be very precious and have a long story behind it including a lot of peoples hard work and dreams. I’d hate to dilute this with questions of authenticity. Hope that didn’t come across wrong, just had to say it.

QUESTIONS:
How would people feel about volunteering for commercial space companies (Virgin Galactic, Blue Origin, Armadillo, SpaceX, Bigelow, etc). As of yet none of these companies could actually take a photo of Blender in space, and since they are commercial they don’t fit into my perfect star-trek vision of enlightened exploration of the universe. However they do fit in a Heinlein universe, and Orson Scott Cards, sort of. Anyway- they are making spaceships, and I love spaceships.
Are there any intellectual property concerns?
Is this just way too far out a limb? Nah, it could work.

FIRST REQUEST:
Every mission needs a patch. I propose Suzanne with a helmet somewhere in it. Any artists want to take a swing at it?
Also- I request to be the CAPCOM for this mission. Any objection? No? Great! I accept!

So whaddya think?
-CAPCOM

May 222011
 

I used to get lots of spam comments until I put a captcha thing on. Most of it was crap but there was a gem…

“We are Dyslexia of Borg. Fusistance is retile. Your ass will be laminated.”

Now that’s good spam.