rwaldron / javascript-robotics

70 stars 43 forks source link

What do the parameters "h, t, s" mean? #24

Open litwa995 opened 6 years ago

litwa995 commented 6 years ago

Hello I build a phoenix spider using the rwaldron code. My servo is : Coxa is HS-485B, Femur and Tibia for Kingmax serva, they have much smaller maximum working range. Now I would like to adjust the values of servos "h, t, s", but I do not know what they mean and how to calculate them.

h = {// What does "h" mean?      f: {        c: [56, 70, 91], // coxa, How to calculate the servo angle?        f: [116, 120, 119], // femur        t: [97, 110, 116] // tibia      }      m: {        c: [70, 88, 109],        f: [116, 117, 116],        t: [102, 106, 104]      }      r: {        c: [56, 70, 91],        f: [116, 120, 119],        t: [97, 110, 116]      }    }

I would like to understand the code and not to use it intentionally. I apologize in advance for my English, but I am Polish and I am not speaking perfectly. I hope this is a good place to report a problem. Please help me spider.

dtex commented 6 years ago

Hi @litwa995

The h object contains the positions of each servo used when the robot is standing still, moving with the run gate or moving with the row gate. t contains the same for turning. s is used in the walk and crawl gates. f, m, and r are front, mid and rear legs.

Honestly, all these servo angles were derived through trial and error. I had created a test rig for the robot that allowed me to tune the position of each joint. There is a more modern approach that uses Inverse Kinematics and the Tharp package to solve the servo angles on the fly

litwa995 commented 6 years ago

So if we have h = {       f: {         c: [56, 70, 91],         f: [116, 120, 119],         t: [97, 110, 116

coxa servo moves 56 degrees later on 70 and 91 and so any servo? And these values are a method of trials and errors tuned?

So if I have a serva with a smaller range of motion, I will have to reduce the number of steps or increase

dtex commented 6 years ago

That's exactly right.

You say your servo has a smaller range of motion. I'm wondering if that is by design, or if we are just using the wrong PWM range. I have this little app that will help you find the ideal PWM range for your servo:

https://github.com/dtex/servo-tuner

litwa995 commented 6 years ago

Hi Thanks for help with parametr(h,t,s). I have another question. How much does the battery keep when the spider is running? I am asking because my rechargeable batteries, i.e. 5x1.2v, are running out very quickly, I also ask my question.

dtex commented 6 years ago

That is hard to say. I've always run 6 x 1.2 2100mah rechargeable NiCd batteries in mine. The servos are always under load (especially the femurs) so let's just wild guess 500ma per servo. I'm gonna say less than 15 minutes would be a reasonable expectation.

litwa995 commented 5 years ago

Thanks for the help dtex. I'am sending link to video on youtube, what happens when you use not enough batteries to move 18 servos. I use now NI-MH battery pack. https://youtu.be/TvDK1r-Nf0o

dtex commented 5 years ago

Thanks for sharing. What kind of battery were you using in this video?

litwa995 commented 5 years ago

Could you explain to me what [5] and [4] mean? {degrees: s.f.f[5], easing: easeIn} {degrees: s.m.f[4], easing: easeIn} I know that these are key frames and I know what 1,2,3 keyFrames mean.

dtex commented 5 years ago

They're the same thing. Some of the movement sequences just use more than 4 keyframes.

litwa995 commented 5 years ago

Ok. It is somewhere written keyFrames? I still have a problem with the code from the Hexapod Phoenix repository. The ph.att () function does not work and the ph.stop () function displays an error, I can not find out what's going on. Too small experience yet with javascript and robtics. Create a separate topic?

dtex commented 5 years ago

I think this thread is fine. There is not that much going on in this repo. What error is being thrown?

litwa995 commented 5 years ago

ph att

litwa995 commented 5 years ago

I can paste the code here like something, but it's the same as it is in the repository.

dtex commented 5 years ago

The error is on line 545 and there are only 542 lines in the file in the repository, so it must be a little different. Maybe paste it in a gist?

litwa995 commented 5 years ago

`// Return phoenix to home position // Powrót phoenixa do pozicji wyjściowej phoenix.att = function() { var most = 0, grouped, mostIndex, ani, work = [ { name: "r1", offset: 0, home: h.f.f[1], thome: h.f.t[1], chome: h.f.c[1]}, { name: "r2", offset: 0, home: h.m.f[1], thome: h.m.t[1], chome: h.m.c[1] }, { name: "r3", offset: 0, home: h.r.f[1], thome: h.r.t[1], chome: h.r.c[1] }, { name: "l1", offset: 0, home: h.f.f[1], thome: h.f.t[1], chome: h.f.c[1] }, { name: "l2", offset: 0, home: h.m.f[1], thome: h.m.t[1], chome: h.m.c[1] }, { name: "l3", offset: 0, home: h.r.f[1], thome: h.r.t[1], chome: h.r.c[1] } ];

// Loop through legs and find how far each is from "home"
// Przeprowadź pętlę nóg i znajdź jak daleko jest, od "domu"

work.forEach(function(leg, i) { work[i].offset = Math.abs(ph[leg.name + "f"].last.reqDegrees - leg.home); });

var moving = _.max(work, function(leg){ return leg.offset; });

if (moving.name === "r2" || moving.name === "l1" || moving.name === "l3") {
  grouped = [ [1, 3, 5], [0, 2, 4] ];
} else {
  grouped = [ [0, 2, 4], [1, 3, 5] ];
}

grouped.forEach(function(group, i) {
  group.forEach(function(leg, j) {
    temporal.queue([
      {
        delay: 500 * i,
        task: function() {
          phoenix[work[leg].name + "f"].to(work[leg].home + lift.femur);
          phoenix[work[leg].name + "t"].to(work[leg].thome + lift.tibia);
        }
      },
      {
        delay: 100,
        task: function() {
          phoenix[work[leg].name + "c"].to(work[leg].chome);
        }
      },
      {
        delay: 100,
        task: function() {
          phoenix[work[leg].name + "f"].to(work[leg].home);
          phoenix[work[leg].name + "t"].to(work[leg].thome);
        }
      }
    ]);
  });
});
phoenix.state = "stand";

};`

litwa995 commented 5 years ago

Is about: work[i].offset = Math.abs(ph[leg.name + "f"].last.reqDegrees - leg.home);

dtex commented 5 years ago

In the repo that line is:

work[i].offset = Math.abs(phoenix[leg.name+"f"].last.reqDegrees - leg.home);
litwa995 commented 5 years ago

var moving = _.max(work, function(leg){ return leg.offset; }); ph att 2

litwa995 commented 5 years ago

The replaced code line now writes me this error

litwa995 commented 5 years ago

I succeeded to fix it. ph att -naprawione At the beginning it was necessary to add const _ = require("underscore");

litwa995 commented 5 years ago

Hey, dtex, I have a few questions about hexapod and code. Here is my spider, this is the stand position. Why are the parameters h, t, s defined so that these legs are so low and the body high? When you walk, the spider does not lift the Femur legs up, but only bends them down. Which results in a shuffle down the ground. What is the reason for this? I changed these parameters for copy and tried others, but without any difference. Am I doing something wrong? p_20190225_173908 Walk p_20190225_173925

dtex commented 5 years ago

So the first thing I'd check is are the PWM ranges set properly for those specific servos. In other words, when I sweep from 0 to 180 am I actually getting 180° of range.

Next, I'd examine the physical installation of the servo. Standard servos are limited to a 180° range and you want to make sure that they were oriented correctly when they were installed. In other words, when the servo is set to 90° is the limb positioned in the middle of the range you will want it to cover?

Once that's good I'd make sure that the servo offset is correct. When you install it with 90° pointed at the center of the range of motion, the servo will probably not be oriented to 90° in the robot's coordinate space. Use the servo's offset property to adjust this.

I have a library that can help with all this: https://github.com/dtex/servo-tuner

litwa995 commented 5 years ago

Thank you for the software you have received. Super software can be easily adjusted servos and pwm. I adjusted the servu Femur and Tibia, Coxa did not move because I would have to unscrew everything to set the maximum inclination. But coxa is Hitec HS-485HB, also cool. Standing position is still the same, but he started to walk and move normally.

Is it in your hexapod, because you built it too? This standing position is the same, does it look different?

Sory, she asks so many questions, but I have no one to ask for, after all this is robotics and hardly anyone knows about it. I hope it does not bother you.

Other questions: I write moves to the hexapod and I do not know how to refer to the selected robot's leg when moving all in the animation, i.e.: I would like to move right.front and next middle legs next rear right legs.

dtex commented 5 years ago

@litwa995 This is my standing position

hexapod

You may just need to adjust the values for the different leg positions in each sequence. It's very tedious to do, but may be necessary to get it just right. You've probably figured most of this out already, but hopefully this helps:

Screen Shot 2019-03-10 at 11 08 02 AM

The values in green boxes are the ones that control the standing position.

dtex commented 5 years ago

I'm sorry there is so much that has to be deduced. When I first wrote my chapter it was 50 pages and I had to trim for publishing. Even at 50 pages I felt like I was leaving things out :-(

litwa995 commented 5 years ago

Cool thinking has not killed anyone yet, and besides, to achieve something you have to work hard. After a week of work on adjusting the stand position I managed, it was enough to replace "lift, femur: -10, tibia: 20" and parameters h, t, s. That's all. P_20190313_111714_HDR

litwa995 commented 5 years ago

Hey, I need help. Help with serialport. I am using Node 8.11.2, above 5.6.0 because I have already looked at many Node.js and not all versions have what I am working on, ie simplebot, phoenix and many more. This one version at least works for me, and I have no problems with it. Now I have a problem with sierialport for a month, i.e. D: \ Node.js \ nodebot \ Robots in this directory have many programs and here I have no problem with serialport, do not crash me, etc., in this path D: \ Node.js \ nodebot \ Buck.Animation here I have a program with phoniex that breaks it all the time. In one day there is a second in the second and, of course, a message error.   missing serialport

I would like to solve this issue all the more because I'm working on a gamepad and xbee on my spider.

dtex commented 5 years ago

Each project directory has its own node_modules so each has its own instance of serialport. One thing you might try is simply deleting the Buck.Animation\node_modules\seriaport directory and then reinstalling serialport with npm install serialport (make sure you are in the Buck.Animation directory when you do that.