file_path
stringlengths 21
224
| content
stringlengths 0
80.8M
|
---|---|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/openDogV2/openDogV2-original/Release01/Code/openDogV2_R1/kinematics.ino | void kinematics (int leg, float x, float y, float z, float roll, float pitch, float yaw) {
// leg 1 : front left
// leg 2 : front right
// leg 3 : back left
// leg 4 : back right
// moving the foot sideways on the end plane
float lengthY;
float hipAngle1a;
float hipAngle1b;
float hipAngle1;
float hipAngle1Degrees;
float hipHyp;
// moving the foot forwards or backwardes in the side plane
float shoulderAngle2;
float shoulderAngle2Degrees;
float z2;
// side plane of individual leg only
#define shinLength 200
#define thighLength 200
float z3;
float shoulderAngle1;
float shoulderAngle1Degrees;
float shoulderAngle1a;
float shoulderAngle1b;
float shoulderAngle1c;
float shoulderAngle1d;
float kneeAngle;
float kneeAngleDegrees;
// *** ROTATION AXIS
// roll axis
#define bodyWidth 125 // half the distance from the middle of the body to the hip pivot
float legDiffRoll; // differnece in height for each leg
float bodyDiffRoll; // how much shorter the 'virtual body' gets
float footDisplacementRoll; // where the foot actually is
float footDisplacementAngleRoll; // smaller angle
float footWholeAngleRoll; // whole leg angle
float hipRollAngle; // angle for hip when roll axis is in use
float rollAngle; // angle in RADIANS that the body rolls
float zz1a; // hypotenuse of final triangle
float zz1; // new height for leg to pass onto the next bit of code
float yy1; // new position for leg to move sideways
// pitch axis
#define bodyLength 265 // distance from centre of body to shoulder pivot
float legDiffPitch; // differnece in height for each leg
float bodyDiffPitch; // how much shorter the 'virtual body' gets
float footDisplacementPitch; // where the foot actually is
float footDisplacementAnglePitch; // smaller angle
float footWholeAnglePitch; // whole leg angle
float shoulderPitchAngle; // angle for hip when roll axis is in use
float pitchAngle; // angle in RADIANS that the body rolls
float zz2a; // hypotenuse of final triangle
float zz2; // new height for the leg to pass onto the next bit of code
float xx1; // new position to move the leg fowwards/backwards
// yaw axis
float yawAngle; // angle in RADIANs for rotation in yaw
float existingAngle; // existing angle of leg from centre
float radius; // radius of leg from centre of robot based on x and y from sticks
float demandYaw; // demand yaw postion - existing yaw plus the stick yaw
float xx3; // new X coordinate based on demand angle
float yy3; // new Y coordinate based on demand angle
// ** ROLL AXIS **
// convert degrees to radians for the calcs
yawAngle = (PI/180) * yaw;
// put in offsets from robot's parameters so we can work out the radius of the foot from the robot's centre
if (leg == 1) { // front left leg
y = y - bodyWidth;
x = x - bodyLength;
}
else if (leg == 2) { // front right leg
y = y + bodyWidth;
x = x - bodyLength;
}
else if (leg == 3) { // back left leg
y = y - bodyWidth;
x = x + bodyLength;
}
else if (leg == 4) { // back left leg
y = y + bodyWidth;;
x = x + bodyLength;
}
//calc existing angle of leg from cetre
existingAngle = atan(y/x);
// calc radius from centre
radius = y/sin(existingAngle);
//calc demand yaw angle
demandYaw = existingAngle + yawAngle;
// calc new X and Y based on demand yaw angle
xx3 = radius * cos(demandYaw); // calc new X and Y based on new yaw angle
yy3 = radius * sin(demandYaw);
// remove the offsets so we pivot around 0/0 x/y
if (leg == 1) { // front left leg
yy3 = yy3 + bodyWidth;
xx3 = xx3 + bodyLength;
}
else if (leg == 2) { // front right leg
yy3 = yy3 - bodyWidth;
xx3 = xx3 + bodyLength;
}
else if (leg == 3) { // back left leg
yy3 = yy3 + bodyWidth;
xx3 = xx3 - bodyLength;
}
else if (leg == 4) { // back left leg
yy3 = yy3 - bodyWidth;
xx3 = xx3 - bodyLength;
}
// ** PITCH AXIS ***
if (leg == 1 || leg == 2) {
pitch = pitch *-1;
xx3 = xx3*-1;
}
// convert pitch to degrees
pitchAngle = (PI/180) * pitch;
//calc top triangle sides
legDiffPitch = sin(pitchAngle) * bodyLength;
bodyDiffPitch = cos(pitchAngle) * bodyLength;
// calc actual height from the ground for each side
legDiffPitch = z - legDiffPitch;
// calc foot displacement
footDisplacementPitch = ((bodyDiffPitch - bodyLength)*-1)+xx3;
//calc smaller displacement angle
footDisplacementAnglePitch = atan(footDisplacementPitch/legDiffPitch);
//calc distance from the ground at the displacement angle (the hypotenuse of the final triangle)
zz2a = legDiffPitch/cos(footDisplacementAnglePitch);
// calc the whole angle for the leg
footWholeAnglePitch = footDisplacementAnglePitch + pitchAngle;
//calc actual leg length - the new Z to pass on
zz2 = cos(footWholeAnglePitch) * zz2a;
//calc new Z to pass on
xx1 = sin(footWholeAnglePitch) * zz2a;
if (leg == 1 || leg == 2) {
xx1 = xx1*-1;
}
// *** ROLL AXIS ***
// convert roll angle to radians
rollAngle = (PI/180) * roll; //covert degrees from the stick to radians
if (leg == 2 || leg == 3) { // reverse the calcs for each side of the robot
rollAngle = rollAngle *-1;
yy3 = yy3*-1;
}
// calc the top triangle sides
legDiffRoll = sin(rollAngle) * bodyWidth;
bodyDiffRoll = cos(rollAngle) * bodyWidth;
// calc actual height from the ground for each side
legDiffRoll = zz2 - legDiffRoll;
// calc foot displacement
footDisplacementRoll = ((bodyDiffRoll - bodyWidth)*-1)-yy3;
//calc smaller displacement angle
footDisplacementAngleRoll = atan(footDisplacementRoll/legDiffRoll);
//calc distance from the ground at the displacement angle (the hypotenuse of the final triangle)
zz1a = legDiffRoll/cos(footDisplacementAngleRoll);
// calc the whole angle for the leg
footWholeAngleRoll = footDisplacementAngleRoll + rollAngle;
//calc actual leg length - the new Z to pass on
zz1 = cos(footWholeAngleRoll) * zz1a;
//calc new Y to pass on
yy1 = sin(footWholeAngleRoll) * zz1a;
if (leg == 2 || leg == 3) { // reverse the calcs for each side of the robot
yy1 = yy1*-1;
}
// *** TRANSLATION AXIS ***
// calculate the hip joint and new leg length based on how far the robot moves sideways
hipAngle1 = atan(yy1/zz1);
hipAngle1Degrees = ((hipAngle1 * (180/PI))); // convert to degrees
z2 = zz1/cos(hipAngle1);
// ****************
// calculate the shoulder joint offset and new leg length based on now far the foot moves forward/backwards
shoulderAngle2 = atan(xx1/z2); // calc how much extra to add to the shoulder joint
shoulderAngle2Degrees = shoulderAngle2 * (180/PI);
z3 = z2/cos(shoulderAngle2); // calc new leg length to feed to the next bit of code below
// ****************
// calculate leg length based on shin/thigh length and knee and shoulder angle
shoulderAngle1a = sq(thighLength) + sq(z3) - sq(shinLength);
shoulderAngle1b = 2 * thighLength * z3;
shoulderAngle1c = shoulderAngle1a / shoulderAngle1b;
shoulderAngle1 = acos(shoulderAngle1c); // radians
kneeAngle = PI - (shoulderAngle1 *2); // radians
//calc degrees from angles
shoulderAngle1Degrees = shoulderAngle1 * (180/PI); // degrees
kneeAngleDegrees = kneeAngle * (180/PI); // degrees
// write to joints
if (leg == 1) { // front right
int shoulderAngle1Counts = (shoulderAngle1Degrees-45) * 55.555555; // convert to encoder counts
int shoulderAngle2Counts = shoulderAngle2Degrees * 55.555555; // convert to encoder counts
int shoulderAngleCounts = shoulderAngle1Counts + shoulderAngle2Counts;
int kneeAngleCounts = (kneeAngleDegrees-90) * 55.555555; // convert to encoder counts
int hipAngleCounts = hipAngle1Degrees * 55.555555; // convert to encoder counts
driveJoints (60, shoulderAngleCounts); // front right shoulder
driveJoints (61, kneeAngleCounts); // front right knee
driveJoints (41, hipAngleCounts); // front right hip
}
else if (leg == 2) { // front left
int shoulderAngle1Counts = (shoulderAngle1Degrees-45) * 55.555555; // convert to encoder counts
int shoulderAngle2Counts = shoulderAngle2Degrees * 55.555555; // convert to encoder counts
int shoulderAngleCounts = shoulderAngle1Counts + shoulderAngle2Counts;
int kneeAngleCounts = (kneeAngleDegrees-90) * 55.555555; // convert to encoder counts
int hipAngleCounts = hipAngle1Degrees * 55.555555; // convert to encoder counts
driveJoints (50, shoulderAngleCounts); // front left shoulder
driveJoints (51, kneeAngleCounts); // front left knee
driveJoints (40, hipAngleCounts); // front left hip
}
else if (leg == 3) { // back left
int shoulderAngle1Counts = (shoulderAngle1Degrees-45) * 55.555555; // convert to encoder counts
int shoulderAngle2Counts = shoulderAngle2Degrees * 55.555555; // convert to encoder counts
int shoulderAngleCounts = shoulderAngle1Counts - shoulderAngle2Counts;
int kneeAngleCounts = (kneeAngleDegrees-90) * 55.555555; // convert to encoder counts
int hipAngleCounts = hipAngle1Degrees * 55.555555; // convert to encoder counts
driveJoints (30, shoulderAngleCounts); // back left shoulder
driveJoints (31, kneeAngleCounts); // back left knee
driveJoints (10, hipAngleCounts); // back left hip
}
else if (leg == 4) { // back right
int shoulderAngle1Counts = (shoulderAngle1Degrees-45) * 55.555555; // convert to encoder counts
int shoulderAngle2Counts = shoulderAngle2Degrees * 55.555555; // convert to encoder counts
int shoulderAngleCounts = shoulderAngle1Counts - shoulderAngle2Counts;
int kneeAngleCounts = (kneeAngleDegrees-90) * 55.555555; // convert to encoder counts
int hipAngleCounts = hipAngle1Degrees * 55.555555; // convert to encoder counts
driveJoints (20, shoulderAngleCounts); // back right shoulder
driveJoints (21, kneeAngleCounts); // back right knee
driveJoints (11, hipAngleCounts); // back right hip
}
}
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/openDogV2/openDogV2-original/Release01/Code/openDogV2_R1/readangle.ino | // IMU interrupt service routine
void dmpDataReady() {
IMUdataReady = 1;
}
// function that actually read the angle when the flag is set by the ISR
void readAngles() {
mpuIntStatus = mpu.getIntStatus();
fifoCount = mpu.getFIFOCount();
if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
// reset so we can continue cleanly
mpu.resetFIFO();
Serial.println(F("FIFO overflow!"));
}
else if (mpuIntStatus & 0x02) {
// wait for correct available data length, should be a VERY short wait
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
// read a packet from FIFO
mpu.getFIFOBytes(fifoBuffer, packetSize);
// track FIFO count here in case there is > 1 packet available
// (this lets us immediately read more without waiting for an interrupt)
fifoCount -= packetSize;
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
IMUdataReady = 0;
}
}
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/openDogV2/openDogV2-original/Release01/Code/openDogV2_R1/MPU6050_6Axis_MotionApps20.h | // I2Cdev library collection - MPU6050 I2C device class, 6-axis MotionApps 2.0 implementation
// Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
// 5/20/2013 by Jeff Rowberg <[email protected]>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
// ... - ongoing debug release
/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2012 Jeff Rowberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/
#ifndef _MPU6050_6AXIS_MOTIONAPPS20_H_
#define _MPU6050_6AXIS_MOTIONAPPS20_H_
#include "I2Cdev.h"
#include "helper_3dmath.h"
// MotionApps 2.0 DMP implementation, built using the MPU-6050EVB evaluation board
#define MPU6050_INCLUDE_DMP_MOTIONAPPS20
#include "MPU6050.h"
// Tom Carpenter's conditional PROGMEM code
// http://forum.arduino.cc/index.php?topic=129407.0
#ifndef __arm__
#include <avr/pgmspace.h>
#else
// Teensy 3.0 library conditional PROGMEM code from Paul Stoffregen
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
#include <inttypes.h>
#define PROGMEM
#define PGM_P const char *
#define PSTR(str) (str)
#define F(x) x
typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;
#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcat_P(dest, src) strcat((dest), (src))
#define strcmp_P(a, b) strcmp((a), (b))
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)
#endif
#endif
/* Source is from the InvenSense MotionApps v2 demo code. Original source is
* unavailable, unless you happen to be amazing as decompiling binary by
* hand (in which case, please contact me, and I'm totally serious).
*
* Also, I'd like to offer many, many thanks to Noah Zerkin for all of the
* DMP reverse-engineering he did to help make this bit of wizardry
* possible.
*/
// NOTE! Enabling DEBUG adds about 3.3kB to the flash program size.
// Debug output is now working even on ATMega328P MCUs (e.g. Arduino Uno)
// after moving string constants to flash memory storage using the F()
// compiler macro (Arduino IDE 1.0+ required).
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTF(x, y) Serial.print(x, y)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINTLNF(x, y) Serial.println(x, y)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTF(x, y)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINTLNF(x, y)
#endif
#define MPU6050_DMP_CODE_SIZE 1929 // dmpMemory[]
#define MPU6050_DMP_CONFIG_SIZE 192 // dmpConfig[]
#define MPU6050_DMP_UPDATES_SIZE 47 // dmpUpdates[]
/* ================================================================================================ *
| Default MotionApps v2.0 42-byte FIFO packet structure: |
| |
| [QUAT W][ ][QUAT X][ ][QUAT Y][ ][QUAT Z][ ][GYRO X][ ][GYRO Y][ ] |
| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
| |
| [GYRO Z][ ][ACC X ][ ][ACC Y ][ ][ACC Z ][ ][ ] |
| 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
* ================================================================================================ */
// this block of memory gets written to the MPU on start-up, and it seems
// to be volatile memory, so it has to be done each time (it only takes ~1
// second though)
const unsigned char dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
// bank 0, 256 bytes
0xFB, 0x00, 0x00, 0x3E, 0x00, 0x0B, 0x00, 0x36, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0xFA, 0x80, 0x00, 0x0B, 0x12, 0x82, 0x00, 0x01,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x28, 0x00, 0x00, 0xFF, 0xFF, 0x45, 0x81, 0xFF, 0xFF, 0xFA, 0x72, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xE8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7F, 0xFF, 0xFF, 0xFE, 0x80, 0x01,
0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3E, 0x03, 0x30, 0x40, 0x00, 0x00, 0x00, 0x02, 0xCA, 0xE3, 0x09, 0x3E, 0x80, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
0x41, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x2A, 0x00, 0x00, 0x16, 0x55, 0x00, 0x00, 0x21, 0x82,
0xFD, 0x87, 0x26, 0x50, 0xFD, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x05, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x6F, 0x00, 0x02, 0x65, 0x32, 0x00, 0x00, 0x5E, 0xC0,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFB, 0x8C, 0x6F, 0x5D, 0xFD, 0x5D, 0x08, 0xD9, 0x00, 0x7C, 0x73, 0x3B, 0x00, 0x6C, 0x12, 0xCC,
0x32, 0x00, 0x13, 0x9D, 0x32, 0x00, 0xD0, 0xD6, 0x32, 0x00, 0x08, 0x00, 0x40, 0x00, 0x01, 0xF4,
0xFF, 0xE6, 0x80, 0x79, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xD6, 0x00, 0x00, 0x27, 0x10,
// bank 1, 256 bytes
0xFB, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFA, 0x36, 0xFF, 0xBC, 0x30, 0x8E, 0x00, 0x05, 0xFB, 0xF0, 0xFF, 0xD9, 0x5B, 0xC8,
0xFF, 0xD0, 0x9A, 0xBE, 0x00, 0x00, 0x10, 0xA9, 0xFF, 0xF4, 0x1E, 0xB2, 0x00, 0xCE, 0xBB, 0xF7,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x0C,
0xFF, 0xC2, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xCF, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x14,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x68, 0xB6, 0x79, 0x35, 0x28, 0xBC, 0xC6, 0x7E, 0xD1, 0x6C,
0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2, 0x6A, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x30,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x25, 0x4D, 0x00, 0x2F, 0x70, 0x6D, 0x00, 0x00, 0x05, 0xAE, 0x00, 0x0C, 0x02, 0xD0,
// bank 2, 256 bytes
0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0xFF, 0xEF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// bank 3, 256 bytes
0xD8, 0xDC, 0xBA, 0xA2, 0xF1, 0xDE, 0xB2, 0xB8, 0xB4, 0xA8, 0x81, 0x91, 0xF7, 0x4A, 0x90, 0x7F,
0x91, 0x6A, 0xF3, 0xF9, 0xDB, 0xA8, 0xF9, 0xB0, 0xBA, 0xA0, 0x80, 0xF2, 0xCE, 0x81, 0xF3, 0xC2,
0xF1, 0xC1, 0xF2, 0xC3, 0xF3, 0xCC, 0xA2, 0xB2, 0x80, 0xF1, 0xC6, 0xD8, 0x80, 0xBA, 0xA7, 0xDF,
0xDF, 0xDF, 0xF2, 0xA7, 0xC3, 0xCB, 0xC5, 0xB6, 0xF0, 0x87, 0xA2, 0x94, 0x24, 0x48, 0x70, 0x3C,
0x95, 0x40, 0x68, 0x34, 0x58, 0x9B, 0x78, 0xA2, 0xF1, 0x83, 0x92, 0x2D, 0x55, 0x7D, 0xD8, 0xB1,
0xB4, 0xB8, 0xA1, 0xD0, 0x91, 0x80, 0xF2, 0x70, 0xF3, 0x70, 0xF2, 0x7C, 0x80, 0xA8, 0xF1, 0x01,
0xB0, 0x98, 0x87, 0xD9, 0x43, 0xD8, 0x86, 0xC9, 0x88, 0xBA, 0xA1, 0xF2, 0x0E, 0xB8, 0x97, 0x80,
0xF1, 0xA9, 0xDF, 0xDF, 0xDF, 0xAA, 0xDF, 0xDF, 0xDF, 0xF2, 0xAA, 0xC5, 0xCD, 0xC7, 0xA9, 0x0C,
0xC9, 0x2C, 0x97, 0x97, 0x97, 0x97, 0xF1, 0xA9, 0x89, 0x26, 0x46, 0x66, 0xB0, 0xB4, 0xBA, 0x80,
0xAC, 0xDE, 0xF2, 0xCA, 0xF1, 0xB2, 0x8C, 0x02, 0xA9, 0xB6, 0x98, 0x00, 0x89, 0x0E, 0x16, 0x1E,
0xB8, 0xA9, 0xB4, 0x99, 0x2C, 0x54, 0x7C, 0xB0, 0x8A, 0xA8, 0x96, 0x36, 0x56, 0x76, 0xF1, 0xB9,
0xAF, 0xB4, 0xB0, 0x83, 0xC0, 0xB8, 0xA8, 0x97, 0x11, 0xB1, 0x8F, 0x98, 0xB9, 0xAF, 0xF0, 0x24,
0x08, 0x44, 0x10, 0x64, 0x18, 0xF1, 0xA3, 0x29, 0x55, 0x7D, 0xAF, 0x83, 0xB5, 0x93, 0xAF, 0xF0,
0x00, 0x28, 0x50, 0xF1, 0xA3, 0x86, 0x9F, 0x61, 0xA6, 0xDA, 0xDE, 0xDF, 0xD9, 0xFA, 0xA3, 0x86,
0x96, 0xDB, 0x31, 0xA6, 0xD9, 0xF8, 0xDF, 0xBA, 0xA6, 0x8F, 0xC2, 0xC5, 0xC7, 0xB2, 0x8C, 0xC1,
0xB8, 0xA2, 0xDF, 0xDF, 0xDF, 0xA3, 0xDF, 0xDF, 0xDF, 0xD8, 0xD8, 0xF1, 0xB8, 0xA8, 0xB2, 0x86,
// bank 4, 256 bytes
0xB4, 0x98, 0x0D, 0x35, 0x5D, 0xB8, 0xAA, 0x98, 0xB0, 0x87, 0x2D, 0x35, 0x3D, 0xB2, 0xB6, 0xBA,
0xAF, 0x8C, 0x96, 0x19, 0x8F, 0x9F, 0xA7, 0x0E, 0x16, 0x1E, 0xB4, 0x9A, 0xB8, 0xAA, 0x87, 0x2C,
0x54, 0x7C, 0xB9, 0xA3, 0xDE, 0xDF, 0xDF, 0xA3, 0xB1, 0x80, 0xF2, 0xC4, 0xCD, 0xC9, 0xF1, 0xB8,
0xA9, 0xB4, 0x99, 0x83, 0x0D, 0x35, 0x5D, 0x89, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0xB5, 0x93, 0xA3,
0x0E, 0x16, 0x1E, 0xA9, 0x2C, 0x54, 0x7C, 0xB8, 0xB4, 0xB0, 0xF1, 0x97, 0x83, 0xA8, 0x11, 0x84,
0xA5, 0x09, 0x98, 0xA3, 0x83, 0xF0, 0xDA, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xD8, 0xF1, 0xA5,
0x29, 0x55, 0x7D, 0xA5, 0x85, 0x95, 0x02, 0x1A, 0x2E, 0x3A, 0x56, 0x5A, 0x40, 0x48, 0xF9, 0xF3,
0xA3, 0xD9, 0xF8, 0xF0, 0x98, 0x83, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0x97, 0x82, 0xA8, 0xF1,
0x11, 0xF0, 0x98, 0xA2, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xDA, 0xF3, 0xDE, 0xD8, 0x83, 0xA5,
0x94, 0x01, 0xD9, 0xA3, 0x02, 0xF1, 0xA2, 0xC3, 0xC5, 0xC7, 0xD8, 0xF1, 0x84, 0x92, 0xA2, 0x4D,
0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9,
0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0x93, 0xA3, 0x4D,
0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9,
0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0xA8, 0x8A, 0x9A,
0xF0, 0x28, 0x50, 0x78, 0x9E, 0xF3, 0x88, 0x18, 0xF1, 0x9F, 0x1D, 0x98, 0xA8, 0xD9, 0x08, 0xD8,
0xC8, 0x9F, 0x12, 0x9E, 0xF3, 0x15, 0xA8, 0xDA, 0x12, 0x10, 0xD8, 0xF1, 0xAF, 0xC8, 0x97, 0x87,
// bank 5, 256 bytes
0x34, 0xB5, 0xB9, 0x94, 0xA4, 0x21, 0xF3, 0xD9, 0x22, 0xD8, 0xF2, 0x2D, 0xF3, 0xD9, 0x2A, 0xD8,
0xF2, 0x35, 0xF3, 0xD9, 0x32, 0xD8, 0x81, 0xA4, 0x60, 0x60, 0x61, 0xD9, 0x61, 0xD8, 0x6C, 0x68,
0x69, 0xD9, 0x69, 0xD8, 0x74, 0x70, 0x71, 0xD9, 0x71, 0xD8, 0xB1, 0xA3, 0x84, 0x19, 0x3D, 0x5D,
0xA3, 0x83, 0x1A, 0x3E, 0x5E, 0x93, 0x10, 0x30, 0x81, 0x10, 0x11, 0xB8, 0xB0, 0xAF, 0x8F, 0x94,
0xF2, 0xDA, 0x3E, 0xD8, 0xB4, 0x9A, 0xA8, 0x87, 0x29, 0xDA, 0xF8, 0xD8, 0x87, 0x9A, 0x35, 0xDA,
0xF8, 0xD8, 0x87, 0x9A, 0x3D, 0xDA, 0xF8, 0xD8, 0xB1, 0xB9, 0xA4, 0x98, 0x85, 0x02, 0x2E, 0x56,
0xA5, 0x81, 0x00, 0x0C, 0x14, 0xA3, 0x97, 0xB0, 0x8A, 0xF1, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9,
0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x84, 0x0D, 0xDA, 0x0E, 0xD8, 0xA3, 0x29, 0x83, 0xDA,
0x2C, 0x0E, 0xD8, 0xA3, 0x84, 0x49, 0x83, 0xDA, 0x2C, 0x4C, 0x0E, 0xD8, 0xB8, 0xB0, 0xA8, 0x8A,
0x9A, 0xF5, 0x20, 0xAA, 0xDA, 0xDF, 0xD8, 0xA8, 0x40, 0xAA, 0xD0, 0xDA, 0xDE, 0xD8, 0xA8, 0x60,
0xAA, 0xDA, 0xD0, 0xDF, 0xD8, 0xF1, 0x97, 0x86, 0xA8, 0x31, 0x9B, 0x06, 0x99, 0x07, 0xAB, 0x97,
0x28, 0x88, 0x9B, 0xF0, 0x0C, 0x20, 0x14, 0x40, 0xB8, 0xB0, 0xB4, 0xA8, 0x8C, 0x9C, 0xF0, 0x04,
0x28, 0x51, 0x79, 0x1D, 0x30, 0x14, 0x38, 0xB2, 0x82, 0xAB, 0xD0, 0x98, 0x2C, 0x50, 0x50, 0x78,
0x78, 0x9B, 0xF1, 0x1A, 0xB0, 0xF0, 0x8A, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x8B, 0x29, 0x51, 0x79,
0x8A, 0x24, 0x70, 0x59, 0x8B, 0x20, 0x58, 0x71, 0x8A, 0x44, 0x69, 0x38, 0x8B, 0x39, 0x40, 0x68,
0x8A, 0x64, 0x48, 0x31, 0x8B, 0x30, 0x49, 0x60, 0xA5, 0x88, 0x20, 0x09, 0x71, 0x58, 0x44, 0x68,
// bank 6, 256 bytes
0x11, 0x39, 0x64, 0x49, 0x30, 0x19, 0xF1, 0xAC, 0x00, 0x2C, 0x54, 0x7C, 0xF0, 0x8C, 0xA8, 0x04,
0x28, 0x50, 0x78, 0xF1, 0x88, 0x97, 0x26, 0xA8, 0x59, 0x98, 0xAC, 0x8C, 0x02, 0x26, 0x46, 0x66,
0xF0, 0x89, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31,
0xA9, 0x88, 0x09, 0x20, 0x59, 0x70, 0xAB, 0x11, 0x38, 0x40, 0x69, 0xA8, 0x19, 0x31, 0x48, 0x60,
0x8C, 0xA8, 0x3C, 0x41, 0x5C, 0x20, 0x7C, 0x00, 0xF1, 0x87, 0x98, 0x19, 0x86, 0xA8, 0x6E, 0x76,
0x7E, 0xA9, 0x99, 0x88, 0x2D, 0x55, 0x7D, 0x9E, 0xB9, 0xA3, 0x8A, 0x22, 0x8A, 0x6E, 0x8A, 0x56,
0x8A, 0x5E, 0x9F, 0xB1, 0x83, 0x06, 0x26, 0x46, 0x66, 0x0E, 0x2E, 0x4E, 0x6E, 0x9D, 0xB8, 0xAD,
0x00, 0x2C, 0x54, 0x7C, 0xF2, 0xB1, 0x8C, 0xB4, 0x99, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0x81, 0x91,
0xAC, 0x38, 0xAD, 0x3A, 0xB5, 0x83, 0x91, 0xAC, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9, 0x48, 0xD8,
0x6D, 0xD9, 0x68, 0xD8, 0x8C, 0x9D, 0xAE, 0x29, 0xD9, 0x04, 0xAE, 0xD8, 0x51, 0xD9, 0x04, 0xAE,
0xD8, 0x79, 0xD9, 0x04, 0xD8, 0x81, 0xF3, 0x9D, 0xAD, 0x00, 0x8D, 0xAE, 0x19, 0x81, 0xAD, 0xD9,
0x01, 0xD8, 0xF2, 0xAE, 0xDA, 0x26, 0xD8, 0x8E, 0x91, 0x29, 0x83, 0xA7, 0xD9, 0xAD, 0xAD, 0xAD,
0xAD, 0xF3, 0x2A, 0xD8, 0xD8, 0xF1, 0xB0, 0xAC, 0x89, 0x91, 0x3E, 0x5E, 0x76, 0xF3, 0xAC, 0x2E,
0x2E, 0xF1, 0xB1, 0x8C, 0x5A, 0x9C, 0xAC, 0x2C, 0x28, 0x28, 0x28, 0x9C, 0xAC, 0x30, 0x18, 0xA8,
0x98, 0x81, 0x28, 0x34, 0x3C, 0x97, 0x24, 0xA7, 0x28, 0x34, 0x3C, 0x9C, 0x24, 0xF2, 0xB0, 0x89,
0xAC, 0x91, 0x2C, 0x4C, 0x6C, 0x8A, 0x9B, 0x2D, 0xD9, 0xD8, 0xD8, 0x51, 0xD9, 0xD8, 0xD8, 0x79,
// bank 7, 138 bytes (remainder)
0xD9, 0xD8, 0xD8, 0xF1, 0x9E, 0x88, 0xA3, 0x31, 0xDA, 0xD8, 0xD8, 0x91, 0x2D, 0xD9, 0x28, 0xD8,
0x4D, 0xD9, 0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x83, 0x93, 0x35, 0x3D, 0x80, 0x25, 0xDA,
0xD8, 0xD8, 0x85, 0x69, 0xDA, 0xD8, 0xD8, 0xB4, 0x93, 0x81, 0xA3, 0x28, 0x34, 0x3C, 0xF3, 0xAB,
0x8B, 0xF8, 0xA3, 0x91, 0xB6, 0x09, 0xB4, 0xD9, 0xAB, 0xDE, 0xFA, 0xB0, 0x87, 0x9C, 0xB9, 0xA3,
0xDD, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x95, 0xF1, 0xA3, 0xA3, 0xA3, 0x9D, 0xF1, 0xA3, 0xA3, 0xA3,
0xA3, 0xF2, 0xA3, 0xB4, 0x90, 0x80, 0xF2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
0xA3, 0xB2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xB0, 0x87, 0xB5, 0x99, 0xF1, 0xA3, 0xA3, 0xA3,
0x98, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x97, 0xA3, 0xA3, 0xA3, 0xA3, 0xF3, 0x9B, 0xA3, 0xA3, 0xDC,
0xB9, 0xA7, 0xF1, 0x26, 0x26, 0x26, 0xD8, 0xD8, 0xFF
};
// thanks to Noah Zerkin for piecing this stuff together!
const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
// BANK OFFSET LENGTH [DATA]
0x03, 0x7B, 0x03, 0x4C, 0xCD, 0x6C, // FCFG_1 inv_set_gyro_calibration
0x03, 0xAB, 0x03, 0x36, 0x56, 0x76, // FCFG_3 inv_set_gyro_calibration
0x00, 0x68, 0x04, 0x02, 0xCB, 0x47, 0xA2, // D_0_104 inv_set_gyro_calibration
0x02, 0x18, 0x04, 0x00, 0x05, 0x8B, 0xC1, // D_0_24 inv_set_gyro_calibration
0x01, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, // D_1_152 inv_set_accel_calibration
0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_accel_calibration
0x03, 0x89, 0x03, 0x26, 0x46, 0x66, // FCFG_7 inv_set_accel_calibration
0x00, 0x6C, 0x02, 0x20, 0x00, // D_0_108 inv_set_accel_calibration
0x02, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_00 inv_set_compass_calibration
0x02, 0x44, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_01
0x02, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_02
0x02, 0x4C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_10
0x02, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_11
0x02, 0x54, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_12
0x02, 0x58, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_20
0x02, 0x5C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_21
0x02, 0xBC, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_22
0x01, 0xEC, 0x04, 0x00, 0x00, 0x40, 0x00, // D_1_236 inv_apply_endian_accel
0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_mpu_sensors
0x04, 0x02, 0x03, 0x0D, 0x35, 0x5D, // CFG_MOTION_BIAS inv_turn_on_bias_from_no_motion
0x04, 0x09, 0x04, 0x87, 0x2D, 0x35, 0x3D, // FCFG_5 inv_set_bias_update
0x00, 0xA3, 0x01, 0x00, // D_0_163 inv_set_dead_zone
// SPECIAL 0x01 = enable interrupts
0x00, 0x00, 0x00, 0x01, // SET INT_ENABLE at i=22, SPECIAL INSTRUCTION
0x07, 0x86, 0x01, 0xFE, // CFG_6 inv_set_fifo_interupt
0x07, 0x41, 0x05, 0xF1, 0x20, 0x28, 0x30, 0x38, // CFG_8 inv_send_quaternion
0x07, 0x7E, 0x01, 0x30, // CFG_16 inv_set_footer
0x07, 0x46, 0x01, 0x9A, // CFG_GYRO_SOURCE inv_send_gyro
0x07, 0x47, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_9 inv_send_gyro -> inv_construct3_fifo
0x07, 0x6C, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo
0x02, 0x16, 0x02, 0x00, 0x09 // D_0_22 inv_set_fifo_rate
// This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
// 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data.
// DMP output frequency is calculated easily using this equation: (200Hz / (1 + value))
// It is important to make sure the host processor can keep up with reading and processing
// the FIFO output at the desired rate. Handling FIFO overflow cleanly is also a good idea.
};
const unsigned char dmpUpdates[MPU6050_DMP_UPDATES_SIZE] PROGMEM = {
0x01, 0xB2, 0x02, 0xFF, 0xFF,
0x01, 0x90, 0x04, 0x09, 0x23, 0xA1, 0x35,
0x01, 0x6A, 0x02, 0x06, 0x00,
0x01, 0x60, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x04, 0x40, 0x00, 0x00, 0x00,
0x01, 0x62, 0x02, 0x00, 0x00,
0x00, 0x60, 0x04, 0x00, 0x40, 0x00, 0x00
};
uint8_t MPU6050::dmpInitialize() {
// reset device
DEBUG_PRINTLN(F("\n\nResetting MPU6050..."));
reset();
delay(30); // wait after reset
// enable sleep mode and wake cycle
/*Serial.println(F("Enabling sleep mode..."));
setSleepEnabled(true);
Serial.println(F("Enabling wake cycle..."));
setWakeCycleEnabled(true);*/
// disable sleep mode
DEBUG_PRINTLN(F("Disabling sleep mode..."));
setSleepEnabled(false);
// get MPU hardware revision
DEBUG_PRINTLN(F("Selecting user bank 16..."));
setMemoryBank(0x10, true, true);
DEBUG_PRINTLN(F("Selecting memory byte 6..."));
setMemoryStartAddress(0x06);
DEBUG_PRINTLN(F("Checking hardware revision..."));
uint8_t hwRevision = readMemoryByte();
DEBUG_PRINT(F("Revision @ user[16][6] = "));
DEBUG_PRINTLNF(hwRevision, HEX);
DEBUG_PRINTLN(F("Resetting memory bank selection to 0..."));
setMemoryBank(0, false, false);
// check OTP bank valid
DEBUG_PRINTLN(F("Reading OTP bank valid flag..."));
uint8_t otpValid = getOTPBankValid();
DEBUG_PRINT(F("OTP bank is "));
DEBUG_PRINTLN(otpValid ? F("valid!") : F("invalid!"));
// get X/Y/Z gyro offsets
DEBUG_PRINTLN(F("Reading gyro offset TC values..."));
int8_t xgOffsetTC = getXGyroOffsetTC();
int8_t ygOffsetTC = getYGyroOffsetTC();
int8_t zgOffsetTC = getZGyroOffsetTC();
DEBUG_PRINT(F("X gyro offset = "));
DEBUG_PRINTLN(xgOffset);
DEBUG_PRINT(F("Y gyro offset = "));
DEBUG_PRINTLN(ygOffset);
DEBUG_PRINT(F("Z gyro offset = "));
DEBUG_PRINTLN(zgOffset);
// setup weird slave stuff (?)
DEBUG_PRINTLN(F("Setting slave 0 address to 0x7F..."));
setSlaveAddress(0, 0x7F);
DEBUG_PRINTLN(F("Disabling I2C Master mode..."));
setI2CMasterModeEnabled(false);
DEBUG_PRINTLN(F("Setting slave 0 address to 0x68 (self)..."));
setSlaveAddress(0, 0x68);
DEBUG_PRINTLN(F("Resetting I2C Master control..."));
resetI2CMaster();
delay(20);
// load DMP code into memory banks
DEBUG_PRINT(F("Writing DMP code to MPU memory banks ("));
DEBUG_PRINT(MPU6050_DMP_CODE_SIZE);
DEBUG_PRINTLN(F(" bytes)"));
if (writeProgMemoryBlock(dmpMemory, MPU6050_DMP_CODE_SIZE)) {
DEBUG_PRINTLN(F("Success! DMP code written and verified."));
// write DMP configuration
DEBUG_PRINT(F("Writing DMP configuration to MPU memory banks ("));
DEBUG_PRINT(MPU6050_DMP_CONFIG_SIZE);
DEBUG_PRINTLN(F(" bytes in config def)"));
if (writeProgDMPConfigurationSet(dmpConfig, MPU6050_DMP_CONFIG_SIZE)) {
DEBUG_PRINTLN(F("Success! DMP configuration written and verified."));
DEBUG_PRINTLN(F("Setting clock source to Z Gyro..."));
setClockSource(MPU6050_CLOCK_PLL_ZGYRO);
DEBUG_PRINTLN(F("Setting DMP and FIFO_OFLOW interrupts enabled..."));
setIntEnabled(0x12);
DEBUG_PRINTLN(F("Setting sample rate to 200Hz..."));
setRate(4); // 1khz / (1 + 4) = 200 Hz
DEBUG_PRINTLN(F("Setting external frame sync to TEMP_OUT_L[0]..."));
setExternalFrameSync(MPU6050_EXT_SYNC_TEMP_OUT_L);
DEBUG_PRINTLN(F("Setting DLPF bandwidth to 42Hz..."));
setDLPFMode(MPU6050_DLPF_BW_42);
DEBUG_PRINTLN(F("Setting gyro sensitivity to +/- 2000 deg/sec..."));
setFullScaleGyroRange(MPU6050_GYRO_FS_2000);
DEBUG_PRINTLN(F("Setting DMP configuration bytes (function unknown)..."));
setDMPConfig1(0x03);
setDMPConfig2(0x00);
DEBUG_PRINTLN(F("Clearing OTP Bank flag..."));
setOTPBankValid(false);
DEBUG_PRINTLN(F("Setting X/Y/Z gyro offset TCs to previous values..."));
setXGyroOffsetTC(xgOffsetTC);
setYGyroOffsetTC(ygOffsetTC);
setZGyroOffsetTC(zgOffsetTC);
//DEBUG_PRINTLN(F("Setting X/Y/Z gyro user offsets to zero..."));
//setXGyroOffset(0);
//setYGyroOffset(0);
//setZGyroOffset(0);
DEBUG_PRINTLN(F("Writing final memory update 1/7 (function unknown)..."));
uint8_t dmpUpdate[16], j;
uint16_t pos = 0;
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Writing final memory update 2/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Resetting FIFO..."));
resetFIFO();
DEBUG_PRINTLN(F("Reading FIFO count..."));
uint16_t fifoCount = getFIFOCount();
uint8_t fifoBuffer[128];
DEBUG_PRINT(F("Current FIFO count="));
DEBUG_PRINTLN(fifoCount);
getFIFOBytes(fifoBuffer, fifoCount);
DEBUG_PRINTLN(F("Setting motion detection threshold to 2..."));
setMotionDetectionThreshold(2);
DEBUG_PRINTLN(F("Setting zero-motion detection threshold to 156..."));
setZeroMotionDetectionThreshold(156);
DEBUG_PRINTLN(F("Setting motion detection duration to 80..."));
setMotionDetectionDuration(80);
DEBUG_PRINTLN(F("Setting zero-motion detection duration to 0..."));
setZeroMotionDetectionDuration(0);
DEBUG_PRINTLN(F("Resetting FIFO..."));
resetFIFO();
DEBUG_PRINTLN(F("Enabling FIFO..."));
setFIFOEnabled(true);
DEBUG_PRINTLN(F("Enabling DMP..."));
setDMPEnabled(true);
DEBUG_PRINTLN(F("Resetting DMP..."));
resetDMP();
DEBUG_PRINTLN(F("Writing final memory update 3/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Writing final memory update 4/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Writing final memory update 5/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Waiting for FIFO count > 2..."));
while ((fifoCount = getFIFOCount()) < 3);
DEBUG_PRINT(F("Current FIFO count="));
DEBUG_PRINTLN(fifoCount);
DEBUG_PRINTLN(F("Reading FIFO data..."));
getFIFOBytes(fifoBuffer, fifoCount);
DEBUG_PRINTLN(F("Reading interrupt status..."));
uint8_t mpuIntStatus = getIntStatus();
DEBUG_PRINT(F("Current interrupt status="));
DEBUG_PRINTLNF(mpuIntStatus, HEX);
DEBUG_PRINTLN(F("Reading final memory update 6/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
readMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("Waiting for FIFO count > 2..."));
while ((fifoCount = getFIFOCount()) < 3);
DEBUG_PRINT(F("Current FIFO count="));
DEBUG_PRINTLN(fifoCount);
DEBUG_PRINTLN(F("Reading FIFO data..."));
getFIFOBytes(fifoBuffer, fifoCount);
DEBUG_PRINTLN(F("Reading interrupt status..."));
mpuIntStatus = getIntStatus();
DEBUG_PRINT(F("Current interrupt status="));
DEBUG_PRINTLNF(mpuIntStatus, HEX);
DEBUG_PRINTLN(F("Writing final memory update 7/7 (function unknown)..."));
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
DEBUG_PRINTLN(F("DMP is good to go! Finally."));
DEBUG_PRINTLN(F("Disabling DMP (you turn it on later)..."));
setDMPEnabled(false);
DEBUG_PRINTLN(F("Setting up internal 42-byte (default) DMP packet buffer..."));
dmpPacketSize = 42;
/*if ((dmpPacketBuffer = (uint8_t *)malloc(42)) == 0) {
return 3; // TODO: proper error code for no memory
}*/
DEBUG_PRINTLN(F("Resetting FIFO and clearing INT status one last time..."));
resetFIFO();
getIntStatus();
} else {
DEBUG_PRINTLN(F("ERROR! DMP configuration verification failed."));
return 2; // configuration block loading failed
}
} else {
DEBUG_PRINTLN(F("ERROR! DMP code verification failed."));
return 1; // main binary block loading failed
}
return 0; // success
}
bool MPU6050::dmpPacketAvailable() {
return getFIFOCount() >= dmpGetFIFOPacketSize();
}
// uint8_t MPU6050::dmpSetFIFORate(uint8_t fifoRate);
// uint8_t MPU6050::dmpGetFIFORate();
// uint8_t MPU6050::dmpGetSampleStepSizeMS();
// uint8_t MPU6050::dmpGetSampleFrequency();
// int32_t MPU6050::dmpDecodeTemperature(int8_t tempReg);
//uint8_t MPU6050::dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority);
//uint8_t MPU6050::dmpUnregisterFIFORateProcess(inv_obj_func func);
//uint8_t MPU6050::dmpRunFIFORateProcesses();
// uint8_t MPU6050::dmpSendQuaternion(uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendPacketNumber(uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy);
// uint8_t MPU6050::dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy);
uint8_t MPU6050::dmpGetAccel(int32_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = ((packet[28] << 24) + (packet[29] << 16) + (packet[30] << 8) + packet[31]);
data[1] = ((packet[32] << 24) + (packet[33] << 16) + (packet[34] << 8) + packet[35]);
data[2] = ((packet[36] << 24) + (packet[37] << 16) + (packet[38] << 8) + packet[39]);
return 0;
}
uint8_t MPU6050::dmpGetAccel(int16_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = (packet[28] << 8) + packet[29];
data[1] = (packet[32] << 8) + packet[33];
data[2] = (packet[36] << 8) + packet[37];
return 0;
}
uint8_t MPU6050::dmpGetAccel(VectorInt16 *v, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
v -> x = (packet[28] << 8) + packet[29];
v -> y = (packet[32] << 8) + packet[33];
v -> z = (packet[36] << 8) + packet[37];
return 0;
}
uint8_t MPU6050::dmpGetQuaternion(int32_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = ((packet[0] << 24) + (packet[1] << 16) + (packet[2] << 8) + packet[3]);
data[1] = ((packet[4] << 24) + (packet[5] << 16) + (packet[6] << 8) + packet[7]);
data[2] = ((packet[8] << 24) + (packet[9] << 16) + (packet[10] << 8) + packet[11]);
data[3] = ((packet[12] << 24) + (packet[13] << 16) + (packet[14] << 8) + packet[15]);
return 0;
}
uint8_t MPU6050::dmpGetQuaternion(int16_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = ((packet[0] << 8) + packet[1]);
data[1] = ((packet[4] << 8) + packet[5]);
data[2] = ((packet[8] << 8) + packet[9]);
data[3] = ((packet[12] << 8) + packet[13]);
return 0;
}
uint8_t MPU6050::dmpGetQuaternion(Quaternion *q, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
int16_t qI[4];
uint8_t status = dmpGetQuaternion(qI, packet);
if (status == 0) {
q -> w = (float)qI[0] / 16384.0f;
q -> x = (float)qI[1] / 16384.0f;
q -> y = (float)qI[2] / 16384.0f;
q -> z = (float)qI[3] / 16384.0f;
return 0;
}
return status; // int16 return value, indicates error if this line is reached
}
// uint8_t MPU6050::dmpGet6AxisQuaternion(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetRelativeQuaternion(long *data, const uint8_t* packet);
uint8_t MPU6050::dmpGetGyro(int32_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = ((packet[16] << 24) + (packet[17] << 16) + (packet[18] << 8) + packet[19]);
data[1] = ((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23]);
data[2] = ((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27]);
return 0;
}
uint8_t MPU6050::dmpGetGyro(int16_t *data, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
data[0] = (packet[16] << 8) + packet[17];
data[1] = (packet[20] << 8) + packet[21];
data[2] = (packet[24] << 8) + packet[25];
return 0;
}
uint8_t MPU6050::dmpGetGyro(VectorInt16 *v, const uint8_t* packet) {
// TODO: accommodate different arrangements of sent data (ONLY default supported now)
if (packet == 0) packet = dmpPacketBuffer;
v -> x = (packet[16] << 8) + packet[17];
v -> y = (packet[20] << 8) + packet[21];
v -> z = (packet[24] << 8) + packet[25];
return 0;
}
// uint8_t MPU6050::dmpSetLinearAccelFilterCoefficient(float coef);
// uint8_t MPU6050::dmpGetLinearAccel(long *data, const uint8_t* packet);
uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) {
// get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g)
v -> x = vRaw -> x - gravity -> x*8192;
v -> y = vRaw -> y - gravity -> y*8192;
v -> z = vRaw -> z - gravity -> z*8192;
return 0;
}
// uint8_t MPU6050::dmpGetLinearAccelInWorld(long *data, const uint8_t* packet);
uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q) {
// rotate measured 3D acceleration vector into original state
// frame of reference based on orientation quaternion
memcpy(v, vReal, sizeof(VectorInt16));
v -> rotate(q);
return 0;
}
// uint8_t MPU6050::dmpGetGyroAndAccelSensor(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetGyroSensor(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetControlData(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetTemperature(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetGravity(long *data, const uint8_t* packet);
uint8_t MPU6050::dmpGetGravity(VectorFloat *v, Quaternion *q) {
v -> x = 2 * (q -> x*q -> z - q -> w*q -> y);
v -> y = 2 * (q -> w*q -> x + q -> y*q -> z);
v -> z = q -> w*q -> w - q -> x*q -> x - q -> y*q -> y + q -> z*q -> z;
return 0;
}
// uint8_t MPU6050::dmpGetUnquantizedAccel(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetQuantizedAccel(long *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetExternalSensorData(long *data, int size, const uint8_t* packet);
// uint8_t MPU6050::dmpGetEIS(long *data, const uint8_t* packet);
uint8_t MPU6050::dmpGetEuler(float *data, Quaternion *q) {
data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1); // psi
data[1] = -asin(2*q -> x*q -> z + 2*q -> w*q -> y); // theta
data[2] = atan2(2*q -> y*q -> z - 2*q -> w*q -> x, 2*q -> w*q -> w + 2*q -> z*q -> z - 1); // phi
return 0;
}
uint8_t MPU6050::dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) {
// yaw: (about Z axis)
data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1);
// pitch: (nose up/down, about Y axis)
data[1] = atan(gravity -> x / sqrt(gravity -> y*gravity -> y + gravity -> z*gravity -> z));
// roll: (tilt left/right, about X axis)
data[2] = atan(gravity -> y / sqrt(gravity -> x*gravity -> x + gravity -> z*gravity -> z));
return 0;
}
// uint8_t MPU6050::dmpGetAccelFloat(float *data, const uint8_t* packet);
// uint8_t MPU6050::dmpGetQuaternionFloat(float *data, const uint8_t* packet);
uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char *dmpData) {
/*for (uint8_t k = 0; k < dmpPacketSize; k++) {
if (dmpData[k] < 0x10) Serial.print("0");
Serial.print(dmpData[k], HEX);
Serial.print(" ");
}
Serial.print("\n");*/
//Serial.println((uint16_t)dmpPacketBuffer);
return 0;
}
uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed) {
uint8_t status;
uint8_t buf[dmpPacketSize];
for (uint8_t i = 0; i < numPackets; i++) {
// read packet from FIFO
getFIFOBytes(buf, dmpPacketSize);
// process packet
if ((status = dmpProcessFIFOPacket(buf)) > 0) return status;
// increment external process count variable, if supplied
if (processed != 0) *processed++;
}
return 0;
}
// uint8_t MPU6050::dmpSetFIFOProcessedCallback(void (*func) (void));
// uint8_t MPU6050::dmpInitFIFOParam();
// uint8_t MPU6050::dmpCloseFIFO();
// uint8_t MPU6050::dmpSetGyroDataSource(uint_fast8_t source);
// uint8_t MPU6050::dmpDecodeQuantizedAccel();
// uint32_t MPU6050::dmpGetGyroSumOfSquare();
// uint32_t MPU6050::dmpGetAccelSumOfSquare();
// void MPU6050::dmpOverrideQuaternion(long *q);
uint16_t MPU6050::dmpGetFIFOPacketSize() {
return dmpPacketSize;
}
#endif /* _MPU6050_6AXIS_MOTIONAPPS20_H_ */
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/openDogV2/openDogV2-original/Release01/Code/Remote_R1/Remote_R1.ino | #include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
// Set the pins on the I2C chip used for LCD connections (Some LCD use Address 0x27 and others use 0x3F):
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
unsigned long previousMillis = 0;
const long interval = 20;
int but1;
int but2;
int but3;
int but4;
int but5;
int sw1;
int sw2;
int sw3;
int axis1;
int axis2;
int axis3;
int axis4;
int axis5;
int axis6;
String count;
struct SEND_DATA_STRUCTURE{
//struct __attribute__((__packed__)) SEND_DATA_STRUCTURE{
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int16_t menuDown;
int16_t Select;
int16_t menuUp;
int16_t toggleBottom;
int16_t toggleTop;
int16_t toggle1;
int16_t toggle2;
int16_t mode;
int16_t RLR;
int16_t RFB;
int16_t RT;
int16_t LLR;
int16_t LFB;
int16_t LT;
};
struct RECEIVE_DATA_STRUCTURE_REMOTE{
//put your variable definitions here for the data you want to receive
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int16_t mode;
int16_t count;
};
int remoteFlag = 0;
SEND_DATA_STRUCTURE mydata_send;
RECEIVE_DATA_STRUCTURE_REMOTE mydata_remote;
RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
pinMode(38, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(42, INPUT_PULLUP);
pinMode(44, INPUT_PULLUP);
pinMode(46, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
pinMode(30, INPUT_PULLUP);
pinMode(32, INPUT_PULLUP);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
radio.begin();
radio.openWritingPipe(addresses[1]); // 00001
radio.openReadingPipe(1, addresses[0]); // 00002
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
lcd.begin(20,4); // Initialize the lcd for 20 chars 4 lines, turn on backlight
lcd.setCursor(0,0);
lcd.print("Everything Remote ");
lcd.setCursor(0,1);
lcd.print("XRobots.co.uk ");
Serial.begin(115200);
}
void loop() {
unsigned long currentMillis = millis();
if (remoteFlag == 0 && currentMillis - previousMillis >= 10) {
previousMillis = currentMillis;
but1 = digitalRead(38);
but2 = digitalRead(40);
but3 = digitalRead(42);
but4 = digitalRead(44);
but5 = digitalRead(46);
sw1 = digitalRead(28);
sw2 = digitalRead(30);
sw3 = digitalRead(32);
if (but1 == 0) {
mydata_send.menuDown = 1;
}
else {
mydata_send.menuDown = 0;
}
if (but2 == 0) {
mydata_send.Select = 1;
}
else {
mydata_send.Select = 0;
}
if (but3 == 0) {
mydata_send.menuUp = 1;
}
else {
mydata_send.menuUp = 0;
}
if (but4 == 0) {
mydata_send.toggleBottom = 1;
}
else {
mydata_send.toggleBottom = 0;
}
if (but5 == 0) {
mydata_send.toggleTop = 1;
}
else {
mydata_send.toggleTop = 0;
}
//******************
if (sw1 == 0) {
mydata_send.toggle1 = 1;
}
else {
mydata_send.toggle1 = 0;
}
if (sw2 == 0) {
mydata_send.toggle2 = 1;
}
else {
mydata_send.toggle2 = 0;
}
axis1 = analogRead(A0);
axis2 = analogRead(A1);
axis3 = analogRead(A2);
axis4 = analogRead(A3);
axis5 = analogRead(A4);
axis6 = analogRead(A5);
mydata_send.RLR = axis1;
mydata_send.RFB = axis2;
mydata_send.RT = axis3;
mydata_send.LLR = axis4;
mydata_send.LFB = axis5;
mydata_send.LT = axis6;
radio.write(&mydata_send, sizeof(SEND_DATA_STRUCTURE));
}
} // end of main loop
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(cassie_description)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a run_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES cassie_description
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
## Declare a C++ library
# add_library(cassie_description
# src/${PROJECT_NAME}/cassie_description.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(cassie_description ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
# add_executable(cassie_description_node src/cassie_description_node.cpp)
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(cassie_description_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(cassie_description_node
# ${catkin_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables and/or libraries for installation
# install(TARGETS cassie_description cassie_description_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_cassie_description.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/package.xml | <?xml version="1.0"?>
<package>
<name>cassie_description</name>
<version>0.0.0</version>
<description>The cassie_description package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<maintainer email="[email protected]">ross</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/cassie_description</url> -->
<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">Jane Doe</author> -->
<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<!-- <run_depend>message_runtime</run_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package> |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/README.md | # cassie_description
This repository contains the .urdf model of the CASSIE robot from Agility Robotics.
It also includes a a way to visualize the robot using ROS and rviz.
Installation to view .urdf using rviz
=====================================
- Download and install ROS by following the instructions at http://wiki.ros.org/indigo/Installation/Ubuntu.
- Create a folder for the catkin workspace
```
mkdir ~/catkin_ws
cd ~/catkin_ws
mkdir src
cd src
catkin_init_workspace
```
- Clone the repository to get the cassie_description package
```
git clone https://github.com/UMich-BipedLab/cassie_description.git
```
- Build the package
```
cd ../
catkin_make
source devel/setup.bash
```
- Launch rviz to visualize the .urdf file
```
roslaunch cassie_description display.launch
```
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/launch/display.launch | <!-- Author: Ross Hartley
Email: [email protected]
Date: 3/22/2016 -->
<launch>
<!-- Input Arguments -->
<arg name="cassie_namespace" default="cassie" />
<arg name="publish_joint_states" default="true" />
<!-- Load URDFs -->
<param name="cassie_description" textfile="$(find cassie_description)/urdf/cassie.urdf"/>
<!-- Cassie joint state publisher -->
<group if = "$(arg publish_joint_states)">
<!--<rosparam command="load" file="$(find cassie_description)/config/dependent_joints.yaml" />-->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="true" />
<remap from="robot_description" to="cassie_description" />
<remap from="joint_states" to="/$(arg cassie_namespace)/joint_states" />
</node>
</group>
<!-- Cassie state publisher -->
<node pkg="robot_state_publisher" type="state_publisher" name="$(arg cassie_namespace)_state_publisher">
<param name="tf_prefix" value="/$(arg cassie_namespace)" />
<param name="use_tf_static" type="bool" value="false" />
<param name="publish_frequency" type="double" value="100.0" />
<remap from="robot_description" to="cassie_description" />
<remap from="joint_states" to="/$(arg cassie_namespace)/joint_states" />
</node>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find cassie_description)/rviz/cassie.rviz" required="false" />
</launch>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/launch/display_torso.launch | <!-- Author: Ross Hartley
Email: [email protected]
Date: 3/22/2016 -->
<launch>
<!-- Input Arguments -->
<arg name="cassie_namespace" default="cassie" />
<arg name="publish_joint_states" default="true" />
<!-- Load URDFs -->
<param name="cassie_description" textfile="$(find cassie_description)/urdf/cassie_with_torso.urdf"/>
<!-- Cassie joint state publisher -->
<group if = "$(arg publish_joint_states)">
<!--<rosparam command="load" file="$(find cassie_description)/config/dependent_joints.yaml" />-->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="true" />
<remap from="robot_description" to="cassie_description" />
<remap from="joint_states" to="/$(arg cassie_namespace)/joint_states" />
</node>
</group>
<!-- Cassie state publisher -->
<node pkg="robot_state_publisher" type="state_publisher" name="$(arg cassie_namespace)_state_publisher">
<param name="tf_prefix" value="/$(arg cassie_namespace)" />
<param name="use_tf_static" type="bool" value="false" />
<param name="publish_frequency" type="double" value="100.0" />
<remap from="robot_description" to="cassie_description" />
<remap from="joint_states" to="/$(arg cassie_namespace)/joint_states" />
</node>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find cassie_description)/rviz/cassie.rviz" required="false" />
</launch>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/rviz/cassie.rviz | Panels:
- Class: rviz/Displays
Help Height: 89
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /RobotModel1/Links1
- /RobotModel1/Links1/vectorNav1
- /RobotModel2
Splitter Ratio: 0.5
Tree Height: 1096
- Class: rviz/Selection
Name: Selection
- Class: rviz/Tool Properties
Expanded:
- /2D Pose Estimate1
- /2D Nav Goal1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.588679016
- Class: rviz/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.0299999993
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Class: rviz/TF
Enabled: false
Frame Timeout: 15
Frames:
All Enabled: true
Marker Scale: 0.5
Name: TF
Show Arrows: true
Show Axes: true
Show Names: false
Tree:
{}
Update Interval: 0
Value: false
- Alpha: 1
Class: rviz/RobotModel
Collision Enabled: false
Enabled: true
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
left_hip:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_knee:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_pelvis_abduction:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_pelvis_rotation:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_shin:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_tarsus:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_thigh:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
left_toe:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
pelvis:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_hip:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_knee:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_pelvis_abduction:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_pelvis_rotation:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_shin:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_tarsus:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_thigh:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
right_toe:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
vectorNav:
Alpha: 1
Show Axes: true
Show Trail: false
Name: RobotModel
Robot Description: cassie_description
TF Prefix: cassie
Update Interval: 0
Value: true
Visual Enabled: true
- Alpha: 1
Class: rviz/RobotModel
Collision Enabled: false
Enabled: true
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
multisense/accel:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/gyro:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/head:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
multisense/left_camera_frame:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/left_camera_optical_frame:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/mag:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/right_camera_frame:
Alpha: 1
Show Axes: false
Show Trail: false
multisense/right_camera_optical_frame:
Alpha: 1
Show Axes: false
Show Trail: false
Name: RobotModel
Robot Description: multisense_description
TF Prefix: ""
Update Interval: 0
Value: true
Visual Enabled: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Default Light: true
Fixed Frame: odom
Frame Rate: 30
Name: root
Tools:
- Class: rviz/Interact
Hide Inactive Objects: true
- Class: rviz/MoveCamera
- Class: rviz/Select
- Class: rviz/FocusCamera
- Class: rviz/Measure
- Class: rviz/SetInitialPose
Topic: /initialpose
- Class: rviz/SetGoal
Topic: /move_base_simple/goal
- Class: rviz/PublishPoint
Single click: true
Topic: /clicked_point
Value: true
Views:
Current:
Class: rviz/Orbit
Distance: 5.9645524
Enable Stereo Rendering:
Stereo Eye Separation: 0.0599999987
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0.218418032
Y: -0.596482456
Z: -0.261499405
Focal Shape Fixed Size: true
Focal Shape Size: 0.0500000007
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.00999999978
Pitch: 0.320397973
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 4.49358606
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 1388
Hide Left Dock: false
Hide Right Dock: true
QMainWindow State: 000000ff00000000fd00000004000000000000016a000004e2fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006400fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c0061007900730100000028000004e2000000dd00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000004c8fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730000000041000004c8000000b000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000006980000003efc0100000002fb0000000800540069006d00650100000000000006980000030000fffffffb0000000800540069006d0065010000000000000450000000000000000000000528000004e200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: true
Width: 1688
X: 1752
Y: 24
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/config/dependent_joints.yaml | dependent_joints:
knee_to_shin_left: {parent: knee_joint_left, factor: -1 }
ankle_joint_left: {parent: knee_joint_left, factor: 0 }
knee_to_shin_right: {parent: knee_joint_right, factor: 0 }
ankle_joint_right: {parent: knee_joint_right, factor: -1 }
zeros:
knee_to_shin_left: 0
ankle_joint_left: 0.226893
knee_to_shin_right: 0
ankle_joint_right: 0.226893
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie_with_torso.xacro | <?xml version="1.0"?>
<!-- Author: Bruce JK Huang
Email: [email protected]
Date: 10/10/2018 -->
<robot name="cassie"
xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Properties -->
<xacro:property name="cyan_RGB" value="0.267 0.89 1 1" />
<xacro:property name="black_RGB" value="0.1 0.1 0.1 1" />
<xacro:property name="grey_RGB" value="0.35 0.35 0.35 1" />
<xacro:property name="orange_RGB" value=".9569 .5372 .2588 1" />
<xacro:property name="blue_RGB" value=".0157 .1176 .2588 1" />
<xacro:property name="maize_RGB" value=".9451 .7686 0 1" />
<xacro:property name="light_grey_RGB" value="0.75 0.75 0.75 1" />
<!-- Link Definitions-->
<xacro:macro name="torso" params="cname color">
<link name="torso">
<inertial>
<origin rpy="0 0 0" xyz="0.00637 -0.00235 0.0803"/>
<mass value="8.5"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/torso.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="top_lidar" params="cname color">
<link name="top_lidar">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0 " rpy="0 0 0" />
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="tilted_lidar" params="cname color">
<link name="tilted_lidar">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0 " rpy="0 0 0" />
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="front_camera" params="cname color">
<link name="front_camera">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0 " rpy="0 0 0" />
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="back_camera" params="cname color">
<link name="back_camera">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0 " rpy="0 0 0" />
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="vectorNav">
<link name="vectorNav">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="pelvis" params="cname color">
<link name="pelvis">
<inertial>
<origin xyz=".0507 0 .0284" rpy="0 0 0"/>
<mass value="10.33" />
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_abduction" params="side cname color stl_ext">
<link name="${side}_pelvis_abduction">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/abduction${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_rotation" params="side cname color stl_ext reflect">
<link name="${side}_pelvis_rotation">
<inertial>
<origin xyz=".0257 ${reflect*.0001} .0179" rpy="0 0 0"/>
<mass value="1.82" />
<inertia ixx=".00272" ixy="${reflect*.000000703}" ixz=".00000153" iyy=".00559" iyz="${reflect*.00000261}" izz=".004640" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/yaw${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="hip" params="side cname color stl_ext">
<link name="${side}_hip">
<inertial>
<origin xyz="-.0557 0 0" rpy="0 0 0"/>
<mass value="1.17" />
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/hip${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="thigh" params="side cname color stl_ext reflect">
<link name="${side}_thigh">
<inertial>
<origin xyz=".0598 .0001 ${reflect*-.0358}" rpy="0 0 0"/>
<mass value="5.52" />
<inertia ixx=".018" ixy=".000284" ixz="${reflect*-.0117}" iyy=".0563" iyz="${reflect*-.0000193}" izz=".0498" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/thigh${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="knee" params="side cname color stl_ext reflect">
<link name="${side}_knee">
<inertial>
<origin xyz=".023 .0321 ${reflect*-.0022}" rpy="0 0 0"/>
<mass value=".758" />
<inertia ixx=".002160" ixy=".000956" ixz="${reflect*.00000284}" iyy=".00144" iyz="${reflect*.000000739}" izz=".00334" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="shin" params="side cname color stl_ext reflect">
<link name="${side}_shin">
<inertial>
<origin xyz=".1834 .0012 ${reflect*.0002}" rpy="0 0 0"/>
<mass value=".577" />
<inertia ixx=".000360" ixy=".000334" ixz="${reflect*-.000000194}" iyy=".0341" iyz="${reflect*.000000265}" izz=".0341" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="tarsus" params="side cname color stl_ext reflect">
<link name="${side}_tarsus">
<inertial>
<origin xyz=".1105 -.0306 ${reflect*-.0013}" rpy="0 0 0"/>
<mass value=".782" />
<inertia ixx=".00113" ixy="-.00288" ixz="${reflect*-.0000633}" iyy=".0231" iyz="${reflect*.0000362}" izz=".0239" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="toe" params="side cname color stl_ext reflect">
<link name="${side}_toe">
<inertial>
<origin xyz=".0047 .0275 ${reflect*-.0001}" rpy="0 0 0"/>
<mass value=".15" />
<inertia ixx=".000287" ixy="-.0000986" ixz="${reflect*-.00000146}" iyy=".000171" iyz="${reflect*.000000172}" izz=".000449" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/toe${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<!-- Joint Definitions -->
<xacro:macro name="fixed_pelvis_to_torso">
<joint name="fixed_pelvis_to_torso" type="fixed">
<origin xyz="0.0218 0 0.2606" rpy="0 0 0"/>
<parent link="pelvis" />
<child link="torso" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_torso_to_top_lidar">
<joint name="fixed_torso_to_top_lidar" type="fixed">
<origin xyz="0.0432 0 0.27" rpy="0 0 0"/>
<parent link="torso" />
<child link="top_lidar" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_torso_to_tilted_lidar">
<joint name="fixed_torso_to_tilted_lidar" type="fixed">
<origin xyz="0.1182 0 0.13" rpy="0 0.65 0"/>
<parent link="torso" />
<child link="tilted_lidar" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_torso_to_front_camera">
<joint name="fixed_torso_to_front_camera" type="fixed">
<origin xyz="0.1382 0 0.07" rpy="0 0 0"/>
<parent link="torso" />
<child link="front_camera" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_torso_to_back_camera">
<joint name="fixed_torso_to_back_camera" type="fixed">
<origin xyz="-0.1418 0 0.07" rpy="0 0 3.14"/>
<parent link="torso" />
<child link="back_camera" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_pelvis_to_vectorNav">
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin xyz="0.03155 0 -0.07996" rpy="0 0 0"/>
<parent link="pelvis" />
<child link="vectorNav" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_pelvis_to_abduction" params="side reflect">
<joint name="fixed_${side}" type="fixed">
<origin xyz="0.021 ${reflect*0.135} 0" rpy="0 ${pi/2} 0"/>
<parent link="pelvis" />
<child link="${side}_pelvis_abduction" />
</joint>
</xacro:macro>
<xacro:macro name="hip_abduction" params="side">
<joint name="hip_abduction_${side}" type="continuous">
<origin xyz="0 0 -0.07" rpy="0 ${-pi/2} 0"/>
<axis xyz="1 0 0"/>
<parent link="${side}_pelvis_abduction" />
<child link="${side}_pelvis_rotation" />
<xacro:if value="${side == 'left'}">
<limit lower="-0.2618" upper="0.3927" effort="4.5" velocity="12.1475" />
</xacro:if>
<xacro:if value="${side == 'right'}">
<limit lower="-0.3927" upper="0.2618" effort="4.5" velocity="12.1475" />
</xacro:if>
</joint>
</xacro:macro>
<xacro:macro name="hip_rotation" params="side">
<joint name="hip_rotation_${side}" type="continuous">
<origin xyz="0 0 -0.09" rpy="0 ${pi/2} ${-pi/2}"/>
<axis xyz="-1 0 0"/>
<parent link="${side}_pelvis_rotation" />
<child link="${side}_hip" />
<limit lower="-0.3927" upper="0.3927" effort="4.5" velocity="12.1475" />
</joint>
</xacro:macro>
<xacro:macro name="hip_flexion" params="side">
<joint name="hip_flexion_${side}" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_hip" />
<child link="${side}_thigh" />
<limit lower="-0.8727" upper="1.3963" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_joint" params="side reflect">
<joint name="knee_joint_${side}" type="continuous">
<origin xyz="0.12 0 ${reflect*0.0045}" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_thigh" />
<child link="${side}_knee" />
<limit lower="-2.8623" upper="-0.6458" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_to_shin" params="side">
<joint name="knee_to_shin_${side}" type="continuous">
<origin xyz="0.0607 0.0474 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_knee" />
<child link="${side}_shin" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="ankle_joint" params="side">
<joint name="ankle_joint_${side}" type="continuous">
<origin xyz="0.4348 0.02 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_shin" />
<child link="${side}_tarsus" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="toe_joint" params="side">
<joint name="toe_joint_${side}" type="continuous">
<origin xyz="0.408 -0.04 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_tarsus" />
<child link="${side}_toe" />
<limit lower="-2.4435" upper="-0.5236" effort="0.9" velocity="11.5192" />
</joint>
</xacro:macro>
<!-- Transmission Definitions -->
<xacro:macro name="hip_abduction_trans" params="side">
<transmission name="hip_abduction_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_${side}"/>
<actuator name="hip_abduction_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_rotation_trans" params="side">
<transmission name="hip_rotation_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_${side}"/>
<actuator name="hip_rotation_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_flexion_trans" params="side">
<transmission name="hip_flexion_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_${side}"/>
<actuator name="hip_flexion_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="knee_joint_trans" params="side">
<transmission name="knee_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_${side}"/>
<actuator name="knee_joint_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="toe_joint_trans" params="side">
<transmission name="toe_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_${side}"/>
<actuator name="toe_joint_motor_${side}"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</xacro:macro>
<!-- Links -->
<xacro:torso cname="grey" color="${grey_RGB}" />
<xacro:top_lidar cname="cyan" color="${cyan_RGB}" />
<xacro:tilted_lidar cname="cyan" color="${cyan_RGB}" />
<xacro:front_camera cname="cyan" color="${cyan_RGB}" />
<xacro:back_camera cname="cyan" color="${cyan_RGB}" />
<xacro:vectorNav />
<xacro:pelvis cname="grey" color="${grey_RGB}" />
<xacro:pelvis_abduction side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext=""/>
<xacro:pelvis_rotation side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1" />
<xacro:hip side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" />
<xacro:thigh side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:knee side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:shin side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:tarsus side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:toe side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:pelvis_abduction side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:pelvis_rotation side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:hip side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:thigh side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:knee side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:shin side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:tarsus side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:toe side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<!-- Joints -->
<xacro:fixed_pelvis_to_torso/>
<xacro:fixed_torso_to_top_lidar/>
<xacro:fixed_torso_to_tilted_lidar/>
<xacro:fixed_torso_to_front_camera/>
<xacro:fixed_torso_to_back_camera/>
<xacro:fixed_pelvis_to_vectorNav />
<xacro:fixed_pelvis_to_abduction side="left" reflect="1"/>
<xacro:hip_abduction side="left"/>
<xacro:hip_rotation side="left"/>
<xacro:hip_flexion side="left"/>
<xacro:knee_joint side="left" reflect="1"/>
<xacro:knee_to_shin side="left"/>
<xacro:ankle_joint side="left"/>
<xacro:toe_joint side="left"/>
<xacro:fixed_pelvis_to_abduction side="right" reflect="-1"/>
<xacro:hip_abduction side="right"/>
<xacro:hip_rotation side="right"/>
<xacro:hip_flexion side="right"/>
<xacro:knee_joint side="right" reflect="-1"/>
<xacro:knee_to_shin side="right"/>
<xacro:ankle_joint side="right"/>
<xacro:toe_joint side="right"/>
<!-- Transmissions -->
<xacro:hip_abduction_trans side="left"/>
<xacro:hip_rotation_trans side="left"/>
<xacro:hip_flexion_trans side="left"/>
<xacro:knee_joint_trans side="left"/>
<xacro:toe_joint_trans side="left"/>
<xacro:hip_abduction_trans side="right"/>
<xacro:hip_rotation_trans side="right"/>
<xacro:hip_flexion_trans side="right"/>
<xacro:knee_joint_trans side="right"/>
<xacro:toe_joint_trans side="right"/>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie.xacro | <?xml version="1.0"?>
<!-- Author: Ross Hartley
Email: [email protected]
Date: 04/24/2016 -->
<robot name="cassie"
xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Properties -->
<xacro:property name="black_RGB" value="0.1 0.1 0.1 1" />
<xacro:property name="grey_RGB" value="0.35 0.35 0.35 1" />
<xacro:property name="orange_RGB" value=".9569 .5372 .2588 1" />
<xacro:property name="blue_RGB" value=".0157 .1176 .2588 1" />
<xacro:property name="maize_RGB" value=".9451 .7686 0 1" />
<xacro:property name="light_grey_RGB" value="0.75 0.75 0.75 1" />
<!-- Links -->
<xacro:vectorNav />
<xacro:pelvis cname="grey" color="${grey_RGB}" />
<xacro:pelvis_abduction side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext=""/>
<xacro:pelvis_rotation side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1" />
<xacro:hip side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" />
<xacro:thigh side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:knee side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:shin side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:tarsus side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:toe side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:pelvis_abduction side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:pelvis_rotation side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:hip side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:thigh side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:knee side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:shin side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:tarsus side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:toe side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<!-- Joints -->
<xacro:fixed_pelvis_to_vectorNav />
<xacro:fixed_pelvis_to_abduction side="left" reflect="1"/>
<xacro:hip_abduction side="left"/>
<xacro:hip_rotation side="left"/>
<xacro:hip_flexion side="left"/>
<xacro:knee_joint side="left" reflect="1"/>
<xacro:knee_to_shin side="left"/>
<xacro:ankle_joint side="left"/>
<xacro:toe_joint side="left"/>
<xacro:fixed_pelvis_to_abduction side="right" reflect="-1"/>
<xacro:hip_abduction side="right"/>
<xacro:hip_rotation side="right"/>
<xacro:hip_flexion side="right"/>
<xacro:knee_joint side="right" reflect="-1"/>
<xacro:knee_to_shin side="right"/>
<xacro:ankle_joint side="right"/>
<xacro:toe_joint side="right"/>
<!-- Transmissions -->
<xacro:hip_abduction_trans side="left"/>
<xacro:hip_rotation_trans side="left"/>
<xacro:hip_flexion_trans side="left"/>
<xacro:knee_joint_trans side="left"/>
<xacro:toe_joint_trans side="left"/>
<xacro:hip_abduction_trans side="right"/>
<xacro:hip_rotation_trans side="right"/>
<xacro:hip_flexion_trans side="right"/>
<xacro:knee_joint_trans side="right"/>
<xacro:toe_joint_trans side="right"/>
<!-- Link Definitions-->
<xacro:macro name="vectorNav">
<link name="vectorNav">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="pelvis" params="cname color">
<link name="pelvis">
<inertial>
<origin xyz=".0507 0 .0284" rpy="0 0 0"/>
<mass value="10.33" />
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_abduction" params="side cname color stl_ext">
<link name="${side}_pelvis_abduction">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/abduction${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_rotation" params="side cname color stl_ext reflect">
<link name="${side}_pelvis_rotation">
<inertial>
<origin xyz=".0257 ${reflect*.0001} .0179" rpy="0 0 0"/>
<mass value="1.82" />
<inertia ixx=".00272" ixy="${reflect*.000000703}" ixz=".00000153" iyy=".00559" iyz="${reflect*.00000261}" izz=".004640" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/yaw${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="hip" params="side cname color stl_ext">
<link name="${side}_hip">
<inertial>
<origin xyz="-.0557 0 0" rpy="0 0 0"/>
<mass value="1.17" />
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/hip${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="thigh" params="side cname color stl_ext reflect">
<link name="${side}_thigh">
<inertial>
<origin xyz=".0598 .0001 ${reflect*-.0358}" rpy="0 0 0"/>
<mass value="5.52" />
<inertia ixx=".018" ixy=".000284" ixz="${reflect*-.0117}" iyy=".0563" iyz="${reflect*-.0000193}" izz=".0498" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/thigh${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="knee" params="side cname color stl_ext reflect">
<link name="${side}_knee">
<inertial>
<origin xyz=".023 .0321 ${reflect*-.0022}" rpy="0 0 0"/>
<mass value=".758" />
<inertia ixx=".002160" ixy=".000956" ixz="${reflect*.00000284}" iyy=".00144" iyz="${reflect*.000000739}" izz=".00334" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="shin" params="side cname color stl_ext reflect">
<link name="${side}_shin">
<inertial>
<origin xyz=".1834 .0012 ${reflect*.0002}" rpy="0 0 0"/>
<mass value=".577" />
<inertia ixx=".000360" ixy=".000334" ixz="${reflect*-.000000194}" iyy=".0341" iyz="${reflect*.000000265}" izz=".0341" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="tarsus" params="side cname color stl_ext reflect">
<link name="${side}_tarsus">
<inertial>
<origin xyz=".1105 -.0306 ${reflect*-.0013}" rpy="0 0 0"/>
<mass value=".782" />
<inertia ixx=".00113" ixy="-.00288" ixz="${reflect*-.0000633}" iyy=".0231" iyz="${reflect*.0000362}" izz=".0239" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="toe" params="side cname color stl_ext reflect">
<link name="${side}_toe">
<inertial>
<origin xyz=".0047 .0275 ${reflect*-.0001}" rpy="0 0 0"/>
<mass value=".15" />
<inertia ixx=".000287" ixy="-.0000986" ixz="${reflect*-.00000146}" iyy=".000171" iyz="${reflect*.000000172}" izz=".000449" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/toe${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<!-- Joint Definitions -->
<xacro:macro name="fixed_pelvis_to_vectorNav">
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin xyz="0.03155 0 -0.07996" rpy="0 0 0"/>
<parent link="pelvis" />
<child link="vectorNav" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_pelvis_to_abduction" params="side reflect">
<joint name="fixed_${side}" type="fixed">
<origin xyz="0.021 ${reflect*0.135} 0" rpy="0 ${pi/2} 0"/>
<parent link="pelvis" />
<child link="${side}_pelvis_abduction" />
</joint>
</xacro:macro>
<xacro:macro name="hip_abduction" params="side">
<joint name="hip_abduction_${side}" type="continuous">
<origin xyz="0 0 -0.07" rpy="0 ${-pi/2} 0"/>
<axis xyz="1 0 0"/>
<parent link="${side}_pelvis_abduction" />
<child link="${side}_pelvis_rotation" />
<xacro:if value="${side == 'left'}">
<limit lower="-0.2618" upper="0.3927" effort="4.5" velocity="12.1475" />
</xacro:if>
<xacro:if value="${side == 'right'}">
<limit lower="-0.3927" upper="0.2618" effort="4.5" velocity="12.1475" />
</xacro:if>
</joint>
</xacro:macro>
<xacro:macro name="hip_rotation" params="side">
<joint name="hip_rotation_${side}" type="continuous">
<origin xyz="0 0 -0.09" rpy="0 ${pi/2} ${-pi/2}"/>
<axis xyz="-1 0 0"/>
<parent link="${side}_pelvis_rotation" />
<child link="${side}_hip" />
<limit lower="-0.3927" upper="0.3927" effort="4.5" velocity="12.1475" />
</joint>
</xacro:macro>
<xacro:macro name="hip_flexion" params="side">
<joint name="hip_flexion_${side}" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_hip" />
<child link="${side}_thigh" />
<limit lower="-0.8727" upper="1.3963" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_joint" params="side reflect">
<joint name="knee_joint_${side}" type="continuous">
<origin xyz="0.12 0 ${reflect*0.0045}" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_thigh" />
<child link="${side}_knee" />
<limit lower="-2.8623" upper="-0.6458" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_to_shin" params="side">
<joint name="knee_to_shin_${side}" type="continuous">
<origin xyz="0.0607 0.0474 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_knee" />
<child link="${side}_shin" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="ankle_joint" params="side">
<joint name="ankle_joint_${side}" type="continuous">
<origin xyz="0.4348 0.02 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_shin" />
<child link="${side}_tarsus" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="toe_joint" params="side">
<joint name="toe_joint_${side}" type="continuous">
<origin xyz="0.408 -0.04 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_tarsus" />
<child link="${side}_toe" />
<limit lower="-2.4435" upper="-0.5236" effort="0.9" velocity="11.5192" />
</joint>
</xacro:macro>
<!-- Transmission Definitions -->
<xacro:macro name="hip_abduction_trans" params="side">
<transmission name="hip_abduction_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_${side}"/>
<actuator name="hip_abduction_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_rotation_trans" params="side">
<transmission name="hip_rotation_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_${side}"/>
<actuator name="hip_rotation_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_flexion_trans" params="side">
<transmission name="hip_flexion_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_${side}"/>
<actuator name="hip_flexion_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="knee_joint_trans" params="side">
<transmission name="knee_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_${side}"/>
<actuator name="knee_joint_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="toe_joint_trans" params="side">
<transmission name="toe_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_${side}"/>
<actuator name="toe_joint_motor_${side}"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</xacro:macro>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie_with_base.xacro | <?xml version="1.0"?>
<!-- Author: Ross Hartley
Email: [email protected]
Date: 04/24/2016 -->
<robot name="cassie"
xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Properties -->
<xacro:property name="black_RGB" value="0.1 0.1 0.1 1" />
<xacro:property name="grey_RGB" value="0.35 0.35 0.35 1" />
<xacro:property name="orange_RGB" value=".9569 .5372 .2588 1" />
<xacro:property name="blue_RGB" value=".0157 .1176 .2588 1" />
<xacro:property name="maize_RGB" value=".9451 .7686 0 1" />
<xacro:property name="light_grey_RGB" value="0.75 0.75 0.75 1" />
<!-- Link Definitions-->
<xacro:macro name="map">
<link name="map">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="x_link">
<link name="x_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="y_link">
<link name="y_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="z_link">
<link name="z_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="yaw_link">
<link name="yaw_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="pitch_link">
<link name="pitch_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="vectorNav">
<link name="vectorNav">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
</link>
</xacro:macro>
<xacro:macro name="pelvis" params="cname color">
<link name="pelvis">
<inertial>
<origin xyz=".0507 0 .0284" rpy="0 0 0"/>
<mass value="10.33" />
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_abduction" params="side cname color stl_ext">
<link name="${side}_pelvis_abduction">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0" />
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/abduction${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="pelvis_rotation" params="side cname color stl_ext reflect">
<link name="${side}_pelvis_rotation">
<inertial>
<origin xyz=".0257 ${reflect*.0001} .0179" rpy="0 0 0"/>
<mass value="1.82" />
<inertia ixx=".00272" ixy="${reflect*.000000703}" ixz=".00000153" iyy=".00559" iyz="${reflect*.00000261}" izz=".004640" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/yaw${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="hip" params="side cname color stl_ext">
<link name="${side}_hip">
<inertial>
<origin xyz="-.0557 0 0" rpy="0 0 0"/>
<mass value="1.17" />
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/hip${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="thigh" params="side cname color stl_ext reflect">
<link name="${side}_thigh">
<inertial>
<origin xyz=".0598 .0001 ${reflect*-.0358}" rpy="0 0 0"/>
<mass value="5.52" />
<inertia ixx=".018" ixy=".000284" ixz="${reflect*-.0117}" iyy=".0563" iyz="${reflect*-.0000193}" izz=".0498" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/thigh${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="knee" params="side cname color stl_ext reflect">
<link name="${side}_knee">
<inertial>
<origin xyz=".023 .0321 ${reflect*-.0022}" rpy="0 0 0"/>
<mass value=".758" />
<inertia ixx=".002160" ixy=".000956" ixz="${reflect*.00000284}" iyy=".00144" iyz="${reflect*.000000739}" izz=".00334" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="shin" params="side cname color stl_ext reflect">
<link name="${side}_shin">
<inertial>
<origin xyz=".1834 .0012 ${reflect*.0002}" rpy="0 0 0"/>
<mass value=".577" />
<inertia ixx=".000360" ixy=".000334" ixz="${reflect*-.000000194}" iyy=".0341" iyz="${reflect*.000000265}" izz=".0341" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="tarsus" params="side cname color stl_ext reflect">
<link name="${side}_tarsus">
<inertial>
<origin xyz=".1105 -.0306 ${reflect*-.0013}" rpy="0 0 0"/>
<mass value=".782" />
<inertia ixx=".00113" ixy="-.00288" ixz="${reflect*-.0000633}" iyy=".0231" iyz="${reflect*.0000362}" izz=".0239" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<xacro:macro name="toe" params="side cname color stl_ext reflect">
<link name="${side}_toe">
<inertial>
<origin xyz=".0047 .0275 ${reflect*-.0001}" rpy="0 0 0"/>
<mass value=".15" />
<inertia ixx=".000287" ixy="-.0000986" ixz="${reflect*-.00000146}" iyy=".000171" iyz="${reflect*.000000172}" izz=".000449" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://cassie_description/meshes/toe${stl_ext}.stl" scale="1 1 1"/>
</geometry>
<material name="${cname}">
<color rgba="${color}" />
</material>
</visual>
</link>
</xacro:macro>
<!-- Joint Definitions -->
<xacro:macro name="x">
<joint name="x" type="prismatic">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<limit lower="-1000" upper="1000" effort="1000" velocity="1000" />
<parent link="map" />
<child link="x_link" />
</joint>
</xacro:macro>
<xacro:macro name="y">
<joint name="y" type="prismatic">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-1000" upper="1000" effort="1000" velocity="1000" />
<parent link="x_link" />
<child link="y_link" />
</joint>
</xacro:macro>
<xacro:macro name="z">
<joint name="z" type="prismatic">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-1000" upper="1000" effort="1000" velocity="1000" />
<parent link="y_link" />
<child link="z_link" />
</joint>
</xacro:macro>
<xacro:macro name="yaw">
<joint name="yaw" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="z_link" />
<child link="yaw_link" />
</joint>
</xacro:macro>
<xacro:macro name="pitch">
<joint name="pitch" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<parent link="yaw_link" />
<child link="pitch_link" />
</joint>
</xacro:macro>
<xacro:macro name="roll">
<joint name="roll" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="1 0 0"/>
<parent link="pitch_link" />
<child link="pelvis" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_pelvis_to_vectorNav">
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin xyz="0.03155 0 -0.07996" rpy="0 0 0"/>
<parent link="pelvis" />
<child link="vectorNav" />
</joint>
</xacro:macro>
<xacro:macro name="fixed_pelvis_to_abduction" params="side reflect">
<joint name="fixed_${side}" type="fixed">
<origin xyz="0.021 ${reflect*0.135} 0" rpy="0 ${pi/2} 0"/>
<parent link="pelvis" />
<child link="${side}_pelvis_abduction" />
</joint>
</xacro:macro>
<xacro:macro name="hip_abduction" params="side">
<joint name="hip_abduction_${side}" type="continuous">
<origin xyz="0 0 -0.07" rpy="0 ${-pi/2} 0"/>
<axis xyz="1 0 0"/>
<parent link="${side}_pelvis_abduction" />
<child link="${side}_pelvis_rotation" />
<xacro:if value="${side == 'left'}">
<limit lower="-0.2618" upper="0.3927" effort="4.5" velocity="12.1475" />
</xacro:if>
<xacro:if value="${side == 'right'}">
<limit lower="-0.3927" upper="0.2618" effort="4.5" velocity="12.1475" />
</xacro:if>
</joint>
</xacro:macro>
<xacro:macro name="hip_rotation" params="side">
<joint name="hip_rotation_${side}" type="continuous">
<origin xyz="0 0 -0.09" rpy="0 ${pi/2} ${-pi/2}"/>
<axis xyz="-1 0 0"/>
<parent link="${side}_pelvis_rotation" />
<child link="${side}_hip" />
<limit lower="-0.3927" upper="0.3927" effort="4.5" velocity="12.1475" />
</joint>
</xacro:macro>
<xacro:macro name="hip_flexion" params="side">
<joint name="hip_flexion_${side}" type="continuous">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_hip" />
<child link="${side}_thigh" />
<limit lower="-0.8727" upper="1.3963" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_joint" params="side reflect">
<joint name="knee_joint_${side}" type="continuous">
<origin xyz="0.12 0 ${reflect*0.0045}" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_thigh" />
<child link="${side}_knee" />
<limit lower="-2.8623" upper="-0.6458" effort="12.2" velocity="8.5085" />
</joint>
</xacro:macro>
<xacro:macro name="knee_to_shin" params="side">
<joint name="knee_to_shin_${side}" type="continuous">
<origin xyz="0.0607 0.0474 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_knee" />
<child link="${side}_shin" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="ankle_joint" params="side">
<joint name="ankle_joint_${side}" type="continuous">
<origin xyz="0.4348 0.02 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_shin" />
<child link="${side}_tarsus" />
<limit lower="-100" upper="100" effort="0" velocity="100" />
</joint>
</xacro:macro>
<xacro:macro name="toe_joint" params="side">
<joint name="toe_joint_${side}" type="continuous">
<origin xyz="0.408 -0.04 0" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="${side}_tarsus" />
<child link="${side}_toe" />
<limit lower="-2.4435" upper="-0.5236" effort="0.9" velocity="11.5192" />
</joint>
</xacro:macro>
<!-- Transmission Definitions -->
<xacro:macro name="hip_abduction_trans" params="side">
<transmission name="hip_abduction_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_${side}"/>
<actuator name="hip_abduction_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_rotation_trans" params="side">
<transmission name="hip_rotation_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_${side}"/>
<actuator name="hip_rotation_motor_${side}"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="hip_flexion_trans" params="side">
<transmission name="hip_flexion_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_${side}"/>
<actuator name="hip_flexion_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="knee_joint_trans" params="side">
<transmission name="knee_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_${side}"/>
<actuator name="knee_joint_motor_${side}"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
</xacro:macro>
<xacro:macro name="toe_joint_trans" params="side">
<transmission name="toe_joint_trans_${side}" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_${side}"/>
<actuator name="toe_joint_motor_${side}"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</xacro:macro>
<!-- Links -->
<xacro:map />
<xacro:x_link />
<xacro:y_link />
<xacro:z_link />
<xacro:yaw_link />
<xacro:pitch_link />
<xacro:vectorNav />
<xacro:pelvis cname="grey" color="${grey_RGB}" />
<xacro:pelvis_abduction side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext=""/>
<xacro:pelvis_rotation side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1" />
<xacro:hip side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" />
<xacro:thigh side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:knee side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:shin side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:tarsus side="left" cname="grey" color="${grey_RGB}" stl_ext="" reflect="1"/>
<xacro:toe side="left" cname="light_grey" color="${light_grey_RGB}" stl_ext="" reflect="1"/>
<xacro:pelvis_abduction side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:pelvis_rotation side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:hip side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror"/>
<xacro:thigh side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:knee side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:shin side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:tarsus side="right" cname="grey" color="${grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<xacro:toe side="right" cname="light_grey" color="${light_grey_RGB}" stl_ext="_mirror" reflect="-1"/>
<!-- Joints -->
<xacro:x />
<xacro:y />
<xacro:z />
<xacro:yaw />
<xacro:pitch />
<xacro:roll />
<xacro:fixed_pelvis_to_vectorNav />
<xacro:fixed_pelvis_to_abduction side="left" reflect="1"/>
<xacro:hip_abduction side="left"/>
<xacro:hip_rotation side="left"/>
<xacro:hip_flexion side="left"/>
<xacro:knee_joint side="left" reflect="1"/>
<xacro:knee_to_shin side="left"/>
<xacro:ankle_joint side="left"/>
<xacro:toe_joint side="left"/>
<xacro:fixed_pelvis_to_abduction side="right" reflect="-1"/>
<xacro:hip_abduction side="right"/>
<xacro:hip_rotation side="right"/>
<xacro:hip_flexion side="right"/>
<xacro:knee_joint side="right" reflect="-1"/>
<xacro:knee_to_shin side="right"/>
<xacro:ankle_joint side="right"/>
<xacro:toe_joint side="right"/>
<!-- Transmissions -->
<xacro:hip_abduction_trans side="left"/>
<xacro:hip_rotation_trans side="left"/>
<xacro:hip_flexion_trans side="left"/>
<xacro:knee_joint_trans side="left"/>
<xacro:toe_joint_trans side="left"/>
<xacro:hip_abduction_trans side="right"/>
<xacro:hip_rotation_trans side="right"/>
<xacro:hip_flexion_trans side="right"/>
<xacro:knee_joint_trans side="right"/>
<xacro:toe_joint_trans side="right"/>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie_with_torso.urdf | <?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from cassie_with_torso.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!-- Author: Bruce JK Huang
Email: [email protected]
Date: 10/10/2018 -->
<robot name="cassie" xmlns:xacro="http://ros.org/wiki/xacro">
<link name="torso">
<inertial>
<origin rpy="0 0 0" xyz="0.00637 -0.00235 0.0803"/>
<mass value="8.5"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/torso.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="top_lidar">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="tilted_lidar">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="front_camera">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="back_camera">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="vectorNav">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="pelvis">
<inertial>
<origin rpy="0 0 0" xyz=".0507 0 .0284"/>
<mass value="10.33"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="7.03e-07" ixz=".00000153" iyy=".00559" iyz="2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 -0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="-0.0117" iyy=".0563" iyz="-1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 -0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="2.84e-06" iyy=".00144" iyz="7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="-1.94e-07" iyy=".0341" iyz="2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 -0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="-6.33e-05" iyy=".0231" iyz="3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 -0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="-1.46e-06" iyy=".000171" iyz="1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 -0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="-7.03e-07" ixz=".00000153" iyy=".00559" iyz="-2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="0.0117" iyy=".0563" iyz="1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="-2.84e-06" iyy=".00144" iyz="-7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 -0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="1.94e-07" iyy=".0341" iyz="-2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="6.33e-05" iyy=".0231" iyz="-3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="1.46e-06" iyy=".000171" iyz="-1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<joint name="fixed_pelvis_to_torso" type="fixed">
<origin rpy="0 0 0" xyz="0.0218 0 0.2606"/>
<parent link="pelvis"/>
<child link="torso"/>
</joint>
<joint name="fixed_torso_to_top_lidar" type="fixed">
<origin rpy="0 0 0" xyz="0.0432 0 0.27"/>
<parent link="torso"/>
<child link="top_lidar"/>
</joint>
<joint name="fixed_torso_to_tilted_lidar" type="fixed">
<origin rpy="0 0.65 0" xyz="0.1182 0 0.13"/>
<parent link="torso"/>
<child link="tilted_lidar"/>
</joint>
<joint name="fixed_torso_to_front_camera" type="fixed">
<origin rpy="0 0 0" xyz="0.1382 0 0.07"/>
<parent link="torso"/>
<child link="front_camera"/>
</joint>
<joint name="fixed_torso_to_back_camera" type="fixed">
<origin rpy="0 0 3.14" xyz="-0.1418 0 0.07"/>
<parent link="torso"/>
<child link="back_camera"/>
</joint>
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin rpy="0 0 0" xyz="0.03155 0 -0.07996"/>
<parent link="pelvis"/>
<child link="vectorNav"/>
</joint>
<joint name="fixed_left" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 0.135 0"/>
<parent link="pelvis"/>
<child link="left_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_left" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="left_pelvis_abduction"/>
<child link="left_pelvis_rotation"/>
<limit effort="4.5" lower="-0.2618" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_left" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="left_pelvis_rotation"/>
<child link="left_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_left" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="left_hip"/>
<child link="left_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 0.0045"/>
<axis xyz="0 0 1"/>
<parent link="left_thigh"/>
<child link="left_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_left" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="left_knee"/>
<child link="left_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="left_shin"/>
<child link="left_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="left_tarsus"/>
<child link="left_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<joint name="fixed_right" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 -0.135 0"/>
<parent link="pelvis"/>
<child link="right_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_right" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="right_pelvis_abduction"/>
<child link="right_pelvis_rotation"/>
<limit effort="4.5" lower="-0.3927" upper="0.2618" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_right" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="right_pelvis_rotation"/>
<child link="right_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_right" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="right_hip"/>
<child link="right_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 -0.0045"/>
<axis xyz="0 0 1"/>
<parent link="right_thigh"/>
<child link="right_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_right" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="right_knee"/>
<child link="right_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="right_shin"/>
<child link="right_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="right_tarsus"/>
<child link="right_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<transmission name="hip_abduction_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_left"/>
<actuator name="hip_abduction_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_left"/>
<actuator name="hip_rotation_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_left"/>
<actuator name="hip_flexion_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_left"/>
<actuator name="knee_joint_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_left"/>
<actuator name="toe_joint_motor_left"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
<transmission name="hip_abduction_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_right"/>
<actuator name="hip_abduction_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_right"/>
<actuator name="hip_rotation_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_right"/>
<actuator name="hip_flexion_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_right"/>
<actuator name="knee_joint_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_right"/>
<actuator name="toe_joint_motor_right"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie_with_base.urdf | <?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from cassie_with_base.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!-- Author: Ross Hartley
Email: [email protected]
Date: 04/24/2016 -->
<robot name="cassie" xmlns:xacro="http://ros.org/wiki/xacro">
<link name="map">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="x_link">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="y_link">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="z_link">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="yaw_link">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="pitch_link">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="vectorNav">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="pelvis">
<inertial>
<origin rpy="0 0 0" xyz=".0507 0 .0284"/>
<mass value="10.33"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="7.03e-07" ixz=".00000153" iyy=".00559" iyz="2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 -0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="-0.0117" iyy=".0563" iyz="-1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 -0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="2.84e-06" iyy=".00144" iyz="7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="-1.94e-07" iyy=".0341" iyz="2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 -0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="-6.33e-05" iyy=".0231" iyz="3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 -0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="-1.46e-06" iyy=".000171" iyz="1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 -0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="-7.03e-07" ixz=".00000153" iyy=".00559" iyz="-2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="0.0117" iyy=".0563" iyz="1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="-2.84e-06" iyy=".00144" iyz="-7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 -0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="1.94e-07" iyy=".0341" iyz="-2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="6.33e-05" iyy=".0231" iyz="-3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="1.46e-06" iyy=".000171" iyz="-1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<joint name="x" type="prismatic">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="1 0 0"/>
<limit effort="1000" lower="-1000" upper="1000" velocity="1000"/>
<parent link="map"/>
<child link="x_link"/>
</joint>
<joint name="y" type="prismatic">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 1 0"/>
<limit effort="1000" lower="-1000" upper="1000" velocity="1000"/>
<parent link="x_link"/>
<child link="y_link"/>
</joint>
<joint name="z" type="prismatic">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<limit effort="1000" lower="-1000" upper="1000" velocity="1000"/>
<parent link="y_link"/>
<child link="z_link"/>
</joint>
<joint name="yaw" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="z_link"/>
<child link="yaw_link"/>
</joint>
<joint name="pitch" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 1 0"/>
<parent link="yaw_link"/>
<child link="pitch_link"/>
</joint>
<joint name="roll" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="1 0 0"/>
<parent link="pitch_link"/>
<child link="pelvis"/>
</joint>
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin rpy="0 0 0" xyz="0.03155 0 -0.07996"/>
<parent link="pelvis"/>
<child link="vectorNav"/>
</joint>
<joint name="fixed_left" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 0.135 0"/>
<parent link="pelvis"/>
<child link="left_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_left" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="left_pelvis_abduction"/>
<child link="left_pelvis_rotation"/>
<limit effort="4.5" lower="-0.2618" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_left" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="left_pelvis_rotation"/>
<child link="left_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_left" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="left_hip"/>
<child link="left_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 0.0045"/>
<axis xyz="0 0 1"/>
<parent link="left_thigh"/>
<child link="left_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_left" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="left_knee"/>
<child link="left_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="left_shin"/>
<child link="left_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="left_tarsus"/>
<child link="left_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<joint name="fixed_right" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 -0.135 0"/>
<parent link="pelvis"/>
<child link="right_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_right" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="right_pelvis_abduction"/>
<child link="right_pelvis_rotation"/>
<limit effort="4.5" lower="-0.3927" upper="0.2618" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_right" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="right_pelvis_rotation"/>
<child link="right_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_right" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="right_hip"/>
<child link="right_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 -0.0045"/>
<axis xyz="0 0 1"/>
<parent link="right_thigh"/>
<child link="right_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_right" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="right_knee"/>
<child link="right_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="right_shin"/>
<child link="right_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="right_tarsus"/>
<child link="right_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<transmission name="hip_abduction_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_left"/>
<actuator name="hip_abduction_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_left"/>
<actuator name="hip_rotation_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_left"/>
<actuator name="hip_flexion_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_left"/>
<actuator name="knee_joint_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_left"/>
<actuator name="toe_joint_motor_left"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
<transmission name="hip_abduction_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_right"/>
<actuator name="hip_abduction_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_right"/>
<actuator name="hip_rotation_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_right"/>
<actuator name="hip_flexion_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_right"/>
<actuator name="knee_joint_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_right"/>
<actuator name="toe_joint_motor_right"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/cassie.urdf | <?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from cassie.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!-- Author: Ross Hartley
Email: [email protected]
Date: 04/24/2016 -->
<robot name="cassie" xmlns:xacro="http://ros.org/wiki/xacro">
<link name="vectorNav">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
</link>
<link name="pelvis">
<inertial>
<origin rpy="0 0 0" xyz=".0507 0 .0284"/>
<mass value="10.33"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/pelvis.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="7.03e-07" ixz=".00000153" iyy=".00559" iyz="2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 -0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="-0.0117" iyy=".0563" iyz="-1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="left_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 -0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="2.84e-06" iyy=".00144" iyz="7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="-1.94e-07" iyy=".0341" iyz="2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 -0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="-6.33e-05" iyy=".0231" iyz="3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="left_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 -0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="-1.46e-06" iyy=".000171" iyz="1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_abduction">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/abduction_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_pelvis_rotation">
<inertial>
<origin rpy="0 0 0" xyz=".0257 -0.0001 .0179"/>
<mass value="1.82"/>
<inertia ixx=".00272" ixy="-7.03e-07" ixz=".00000153" iyy=".00559" iyz="-2.61e-06" izz=".004640"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/yaw_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_hip">
<inertial>
<origin rpy="0 0 0" xyz="-.0557 0 0"/>
<mass value="1.17"/>
<inertia ixx=".000842" ixy=".000000246" ixz="-.000000625" iyy=".006080" iyz="-.00000004" izz=".006440"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/hip_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_thigh">
<inertial>
<origin rpy="0 0 0" xyz=".0598 .0001 0.0358"/>
<mass value="5.52"/>
<inertia ixx=".018" ixy=".000284" ixz="0.0117" iyy=".0563" iyz="1.93e-05" izz=".0498"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/thigh_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<link name="right_knee">
<inertial>
<origin rpy="0 0 0" xyz=".023 .0321 0.0022"/>
<mass value=".758"/>
<inertia ixx=".002160" ixy=".000956" ixz="-2.84e-06" iyy=".00144" iyz="-7.39e-07" izz=".00334"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/knee-output_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_shin">
<inertial>
<origin rpy="0 0 0" xyz=".1834 .0012 -0.0002"/>
<mass value=".577"/>
<inertia ixx=".000360" ixy=".000334" ixz="1.94e-07" iyy=".0341" iyz="-2.65e-07" izz=".0341"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/shin-bone_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_tarsus">
<inertial>
<origin rpy="0 0 0" xyz=".1105 -.0306 0.0013"/>
<mass value=".782"/>
<inertia ixx=".00113" ixy="-.00288" ixz="6.33e-05" iyy=".0231" iyz="-3.62e-05" izz=".0239"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/tarsus_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="right_toe">
<inertial>
<origin rpy="0 0 0" xyz=".0047 .0275 0.0001"/>
<mass value=".15"/>
<inertia ixx=".000287" ixy="-.0000986" ixz="1.46e-06" iyy=".000171" iyz="-1.72e-07" izz=".000449"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/toe_mirror.stl" scale="1 1 1"/>
</geometry>
<material name="light_grey">
<color rgba="0.75 0.75 0.75 1"/>
</material>
</visual>
</link>
<joint name="fixed_pelvis_to_vectorNav" type="fixed">
<origin rpy="0 0 0" xyz="0.03155 0 -0.07996"/>
<parent link="pelvis"/>
<child link="vectorNav"/>
</joint>
<joint name="fixed_left" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 0.135 0"/>
<parent link="pelvis"/>
<child link="left_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_left" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="left_pelvis_abduction"/>
<child link="left_pelvis_rotation"/>
<limit effort="4.5" lower="-0.2618" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_left" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="left_pelvis_rotation"/>
<child link="left_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_left" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="left_hip"/>
<child link="left_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 0.0045"/>
<axis xyz="0 0 1"/>
<parent link="left_thigh"/>
<child link="left_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_left" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="left_knee"/>
<child link="left_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="left_shin"/>
<child link="left_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_left" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="left_tarsus"/>
<child link="left_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<joint name="fixed_right" type="fixed">
<origin rpy="0 1.57079632679 0" xyz="0.021 -0.135 0"/>
<parent link="pelvis"/>
<child link="right_pelvis_abduction"/>
</joint>
<joint name="hip_abduction_right" type="continuous">
<origin rpy="0 -1.57079632679 0" xyz="0 0 -0.07"/>
<axis xyz="1 0 0"/>
<parent link="right_pelvis_abduction"/>
<child link="right_pelvis_rotation"/>
<limit effort="4.5" lower="-0.3927" upper="0.2618" velocity="12.1475"/>
</joint>
<joint name="hip_rotation_right" type="continuous">
<origin rpy="0 1.57079632679 -1.57079632679" xyz="0 0 -0.09"/>
<axis xyz="-1 0 0"/>
<parent link="right_pelvis_rotation"/>
<child link="right_hip"/>
<limit effort="4.5" lower="-0.3927" upper="0.3927" velocity="12.1475"/>
</joint>
<joint name="hip_flexion_right" type="continuous">
<origin rpy="0 0 0" xyz="0 0 0"/>
<axis xyz="0 0 1"/>
<parent link="right_hip"/>
<child link="right_thigh"/>
<limit effort="12.2" lower="-0.8727" upper="1.3963" velocity="8.5085"/>
</joint>
<joint name="knee_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.12 0 -0.0045"/>
<axis xyz="0 0 1"/>
<parent link="right_thigh"/>
<child link="right_knee"/>
<limit effort="12.2" lower="-2.8623" upper="-0.6458" velocity="8.5085"/>
</joint>
<joint name="knee_to_shin_right" type="continuous">
<origin rpy="0 0 0" xyz="0.0607 0.0474 0"/>
<axis xyz="0 0 1"/>
<parent link="right_knee"/>
<child link="right_shin"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="ankle_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.4348 0.02 0"/>
<axis xyz="0 0 1"/>
<parent link="right_shin"/>
<child link="right_tarsus"/>
<limit effort="0" lower="-100" upper="100" velocity="100"/>
</joint>
<joint name="toe_joint_right" type="continuous">
<origin rpy="0 0 0" xyz="0.408 -0.04 0"/>
<axis xyz="0 0 1"/>
<parent link="right_tarsus"/>
<child link="right_toe"/>
<limit effort="0.9" lower="-2.4435" upper="-0.5236" velocity="11.5192"/>
</joint>
<transmission name="hip_abduction_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_left"/>
<actuator name="hip_abduction_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_left"/>
<actuator name="hip_rotation_motor_left"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_left"/>
<actuator name="hip_flexion_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_left"/>
<actuator name="knee_joint_motor_left"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_left" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_left"/>
<actuator name="toe_joint_motor_left"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
<transmission name="hip_abduction_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_abduction_right"/>
<actuator name="hip_abduction_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_rotation_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_rotation_right"/>
<actuator name="hip_rotation_motor_right"/>
<motorInertia>0.000061</motorInertia>
<mechanicalReduction>25</mechanicalReduction>
</transmission>
<transmission name="hip_flexion_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="hip_flexion_right"/>
<actuator name="hip_flexion_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="knee_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="knee_joint_right"/>
<actuator name="knee_joint_motor_right"/>
<motorInertia>0.000365</motorInertia>
<mechanicalReduction>16</mechanicalReduction>
</transmission>
<transmission name="toe_joint_trans_right" type="transmission_interface/SimpleTransmission">
<joint name="toe_joint_right"/>
<actuator name="toe_joint_motor_right"/>
<motorInertia>0.0000049</motorInertia>
<mechanicalReduction>50</mechanicalReduction>
</transmission>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/cassie_description-UMich-BipedLab/urdf/torso.urdf | <?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from cassie_with_torso.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!-- Author: Bruce JK Huang
Email: [email protected]
Date: 10/10/2018 -->
<robot name="cassie" xmlns:xacro="http://ros.org/wiki/xacro">
<link name="torso">
<inertial>
<origin rpy="0 0 0" xyz="0.00637 -0.00235 0.0803"/>
<mass value="8.5"/>
<inertia ixx=".0942" ixy=".000169" ixz=".015" iyy=".084" iyz=".000516" izz=".113"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://cassie_description/meshes/torso.stl" scale="1 1 1"/>
</geometry>
<material name="grey">
<color rgba="0.35 0.35 0.35 1"/>
</material>
</visual>
</link>
<link name="top_lidar">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="tilted_lidar">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="front_camera">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<link name="back_camera">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0 "/>
<geometry>
<sphere radius="0.01"/>
</geometry>
<material name="cyan">
<color rgba="0.267 0.89 1 1"/>
</material>
</visual>
</link>
<joint name="fixed_torso_to_top_lidar" type="fixed">
<origin rpy="0 0 0" xyz="0.0432 0 0.27"/>
<parent link="torso"/>
<child link="top_lidar"/>
</joint>
<joint name="fixed_torso_to_tilted_lidar" type="fixed">
<origin rpy="0 0.65 0" xyz="0.1182 0 0.13"/>
<parent link="torso"/>
<child link="tilted_lidar"/>
</joint>
<joint name="fixed_torso_to_front_camera" type="fixed">
<origin rpy="0 0 0" xyz="0.1382 0 0.07"/>
<parent link="torso"/>
<child link="front_camera"/>
</joint>
<joint name="fixed_torso_to_back_camera" type="fixed">
<origin rpy="0 0 3.14" xyz="-0.1418 0 0.07"/>
<parent link="torso"/>
<child link="back_camera"/>
</joint>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/calibrate_servos.py | from pupper.HardwareInterface import HardwareInterface
from pupper.Config import PWMParams, ServoParams
import numpy as np
import re
def get_motor_name(i, j):
motor_type = {0: "abduction", 1: "inner", 2: "outer"} # Top # Bottom
leg_pos = {0: "front-right", 1: "front-left", 2: "back-right", 3: "back-left"}
final_name = motor_type[i] + " " + leg_pos[j]
return final_name
def get_motor_setpoint(i, j):
data = np.array([[0, 0, 0, 0], [45, 45, 45, 45], [45, 45, 45, 45]])
return data[i, j]
def degrees_to_radians(input_array):
"""Converts degrees to radians.
Parameters
----------
input_array : Numpy array or float
Degrees
Returns
-------
Numpy array or float
Radians
"""
return input_array * np.pi / 180.0
def radians_to_degrees(input_array):
"""Converts degrees to radians.
Parameters
----------
input_array : Numpy array or float
Radians
Returns
-------
Numpy array or float
Degrees
"""
return input_array * 180.0 / np.pi
def step_until(hardware_interface, axis, leg, set_point):
"""Returns the angle offset needed to correct a given link by asking the user for input.
Returns
-------
Float
Angle offset needed to correct the link.
"""
found_position = False
set_names = ["horizontal", "horizontal", "vertical"]
offset = 0
while not found_position:
move_input = str(
input("Enter 'a' or 'b' to move the link until it is **" + set_names[axis] + "**. Enter 'd' when done. Input: "
)
)
if move_input == "a":
offset += 1.0
hardware_interface.set_actuator_position(
degrees_to_radians(set_point + offset),
axis,
leg,
)
elif move_input == "b":
offset -= 1.0
hardware_interface.set_actuator_position(
degrees_to_radians(set_point + offset),
axis,
leg,
)
elif move_input == "d":
found_position = True
print("Offset: ", offset)
return offset
def calibrate_angle_offset(hardware_interface):
"""Calibrate the angle offset for the twelve motors on the robot. Note that servo_params is modified in-place.
Parameters
----------
servo_params : ServoParams
Servo parameters. This variable is updated in-place.
pi_board : Pi
RaspberryPi object.
pwm_params : PWMParams
PWMParams object.
"""
# Found K value of (11.4)
print("The scaling constant for your servo represents how much you have to increase\nthe pwm pulse width (in microseconds) to rotate the servo output 1 degree.")
print("This value is currently set to: {:.3f}".format(degrees_to_radians(hardware_interface.servo_params.micros_per_rad)))
print("For newer CLS6336 and CLS6327 servos the value should be 11.333.")
ks = input("Press <Enter> to keep the current value, or enter a new value: ")
if ks != '':
k = float(ks)
hardware_interface.servo_params.micros_per_rad = k * 180 / np.pi
hardware_interface.servo_params.neutral_angle_degrees = np.zeros((3, 4))
for leg_index in range(4):
for axis in range(3):
# Loop until we're satisfied with the calibration
completed = False
while not completed:
motor_name = get_motor_name(axis, leg_index)
print("\n\nCalibrating the **" + motor_name + " motor **")
set_point = get_motor_setpoint(axis, leg_index)
# Zero out the neutral angle
hardware_interface.servo_params.neutral_angle_degrees[axis, leg_index] = 0
# Move servo to set_point angle
hardware_interface.set_actuator_position(
degrees_to_radians(set_point),
axis,
leg_index,
)
# Adjust the angle using keyboard input until it matches the reference angle
offset = step_until(
hardware_interface, axis, leg_index, set_point
)
print("Final offset: ", offset)
# The upper leg link has a different equation because we're calibrating to make it horizontal, not vertical
if axis == 1:
hardware_interface.servo_params.neutral_angle_degrees[axis, leg_index] = set_point - offset
else:
hardware_interface.servo_params.neutral_angle_degrees[axis, leg_index] = -(set_point + offset)
print("Calibrated neutral angle: ", hardware_interface.servo_params.neutral_angle_degrees[axis, leg_index])
# Send the servo command using the new beta value and check that it's ok
hardware_interface.set_actuator_position(
degrees_to_radians([0, 45, -45][axis]),
axis,
leg_index,
)
okay = ""
prompt = "The leg should be at exactly **" + ["horizontal", "45 degrees", "45 degrees"][axis] + "**. Are you satisfied? Enter 'yes' or 'no': "
while okay not in ["y", "n", "yes", "no"]:
okay = str(
input(prompt)
)
completed = okay == "y" or okay == "yes"
def overwrite_ServoCalibration_file(servo_params):
preamble = """# WARNING: This file is machine generated. Edit at your own risk.
import numpy as np
"""
# Format array object string for np.array
p1 = re.compile("([0-9]\.) ( *)") # pattern to replace the space that follows each number with a comma
partially_formatted_matrix = p1.sub(r"\1,\2", str(servo_params.neutral_angle_degrees))
p2 = re.compile("(\]\n)") # pattern to add a comma at the end of the first two lines
formatted_matrix_with_required_commas = p2.sub("],\n", partially_formatted_matrix)
# Overwrite pupper/ServoCalibration.py file with modified values
with open("pupper/ServoCalibration.py", "w") as f:
print(preamble, file = f)
print("MICROS_PER_RAD = {:.3f} * 180.0 / np.pi".format(degrees_to_radians(servo_params.micros_per_rad)), file = f)
print("NEUTRAL_ANGLE_DEGREES = np.array(", file = f)
print(formatted_matrix_with_required_commas, file = f)
print(")", file = f)
def main():
"""Main program
"""
hardware_interface = HardwareInterface()
calibrate_angle_offset(hardware_interface)
overwrite_ServoCalibration_file(hardware_interface.servo_params)
print("\n\n CALIBRATION COMPLETE!\n")
print("Calibrated neutral angles:")
print(hardware_interface.servo_params.neutral_angle_degrees)
main()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/install.sh | yes | sudo apt-get install libatlas-base-dev
yes | pip3 install numpy transforms3d pigpio pyserial
yes | pip install numpy transforms3d pigpio pyserial
yes | sudo pip install numpy transforms3d pigpio pyserial
cd ..
git clone https://github.com/stanfordroboticsclub/PupperCommand.git
cd PupperCommand
sudo bash install.sh
cd ..
git clone https://github.com/stanfordroboticsclub/PS4Joystick.git
cd PS4Joystick
sudo bash install.sh
cd ..
sudo systemctl enable joystick
wget https://github.com/joan2937/pigpio/archive/v74.zip
unzip v74.zip
cd pigpio-74
make
sudo make install
cd ..
cd StanfordQuadruped
sudo ln -s $(realpath .)/robot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable robot
sudo systemctl start robot
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/run_robot.py | import numpy as np
import time
from src.IMU import IMU
from src.Controller import Controller
from src.JoystickInterface import JoystickInterface
from src.State import State
from pupper.HardwareInterface import HardwareInterface
from pupper.Config import Configuration
from pupper.Kinematics import four_legs_inverse_kinematics
def main(use_imu=False):
"""Main program
"""
# Create config
config = Configuration()
hardware_interface = HardwareInterface()
# Create imu handle
if use_imu:
imu = IMU(port="/dev/ttyACM0")
imu.flush_buffer()
# Create controller and user input handles
controller = Controller(
config,
four_legs_inverse_kinematics,
)
state = State()
print("Creating joystick listener...")
joystick_interface = JoystickInterface(config)
print("Done.")
last_loop = time.time()
print("Summary of gait parameters:")
print("overlap time: ", config.overlap_time)
print("swing time: ", config.swing_time)
print("z clearance: ", config.z_clearance)
print("x shift: ", config.x_shift)
# Wait until the activate button has been pressed
while True:
print("Waiting for L1 to activate robot.")
while True:
command = joystick_interface.get_command(state)
joystick_interface.set_color(config.ps4_deactivated_color)
if command.activate_event == 1:
break
time.sleep(0.1)
print("Robot activated.")
joystick_interface.set_color(config.ps4_color)
while True:
now = time.time()
if now - last_loop < config.dt:
continue
last_loop = time.time()
# Parse the udp joystick commands and then update the robot controller's parameters
command = joystick_interface.get_command(state)
if command.activate_event == 1:
print("Deactivating Robot")
break
# Read imu data. Orientation will be None if no data was available
quat_orientation = (
imu.read_orientation() if use_imu else np.array([1, 0, 0, 0])
)
state.quat_orientation = quat_orientation
# Step the controller forward by dt
controller.run(state, command)
# Update the pwm widths going to the servos
hardware_interface.set_actuator_postions(state.joint_angles)
main()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/README.md | # Stanford Quadruped
## Overview
This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

Video of pupper in action: https://youtu.be/NIjodHA78UE
Project page: https://stanfordstudentrobotics.org/pupper
Documentation & build guide: https://pupper.readthedocs.io/en/latest/
## How it works

The main program is ```run_robot.py``` which is located in this directory. The robot code is run as a loop, with a joystick interface, a controller, and a hardware interface orchestrating the behavior.
The joystick interface is responsible for reading joystick inputs from a UDP socket and converting them into a generic robot ```command``` type. A separate program, ```joystick.py```, publishes these UDP messages, and is responsible for reading inputs from the PS4 controller over bluetooth. The controller does the bulk of the work, switching between states (trot, walk, rest, etc) and generating servo position targets. A detailed model of the controller is shown below. The third component of the code, the hardware interface, converts the position targets from the controller into PWM duty cycles, which it then passes to a Python binding to ```pigpiod```, which then generates PWM signals in software and sends these signals to the motors attached to the Raspberry Pi.

This diagram shows a breakdown of the robot controller. Inside, you can see four primary components: a gait scheduler (also called gait controller), a stance controller, a swing controller, and an inverse kinematics model.
The gait scheduler is responsible for planning which feet should be on the ground (stance) and which should be moving forward to the next step (swing) at any given time. In a trot for example, the diagonal pairs of legs move in sync and take turns between stance and swing. As shown in the diagram, the gait scheduler can be thought of as a conductor for each leg, switching it between stance and swing as time progresses.
The stance controller controls the feet on the ground, and is actually quite simple. It looks at the desired robot velocity, and then generates a body-relative target velocity for these stance feet that is in the opposite direction as the desired velocity. It also incorporates turning, in which case it rotates the feet relative to the body in the opposite direction as the desired body rotation.
The swing controller picks up the feet that just finished their stance phase, and brings them to their next touchdown location. The touchdown locations are selected so that the foot moves the same distance forward in swing as it does backwards in stance. For example, if in stance phase the feet move backwards at -0.4m/s (to achieve a body velocity of +0.4m/s) and the stance phase is 0.5 seconds long, then we know the feet will have moved backwards -0.20m. The swing controller will then move the feet forwards 0.20m to put the foot back in its starting place. You can imagine that if the swing controller only put the leg forward 0.15m, then every step the foot would lag more and more behind the body by -0.05m.
Both the stance and swing controllers generate target positions for the feet in cartesian coordinates relative the body center of mass. It's convenient to work in cartesian coordinates for the stance and swing planning, but we now need to convert them to motor angles. This is done by using an inverse kinematics model, which maps between cartesian body coordinates and motor angles. These motor angles, also called joint angles, are then populated into the ```state``` variable and returned by the model.
## How to Build Pupper
Main documentation: https://pupper.readthedocs.io/en/latest/
You can find the bill of materials, pre-made kit purchasing options, assembly instructions, software installation, etc at this website.
## Help
- Feel free to raise an issue (https://github.com/stanfordroboticsclub/StanfordQuadruped/issues/new/choose) or email me at nathankau [at] stanford [dot] edu
- We also have a Google group set up here: https://groups.google.com/forum/#!forum/stanford-quadrupeds
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/Gaits.py | class GaitController:
def __init__(self, config):
self.config = config
def phase_index(self, ticks):
"""Calculates which part of the gait cycle the robot should be in given the time in ticks.
Parameters
----------
ticks : int
Number of timesteps since the program started
gaitparams : GaitParams
GaitParams object
Returns
-------
Int
The index of the gait phase that the robot should be in.
"""
phase_time = ticks % self.config.phase_length
phase_sum = 0
for i in range(self.config.num_phases):
phase_sum += self.config.phase_ticks[i]
if phase_time < phase_sum:
return i
assert False
def subphase_ticks(self, ticks):
"""Calculates the number of ticks (timesteps) since the start of the current phase.
Parameters
----------
ticks : Int
Number of timesteps since the program started
gaitparams : GaitParams
GaitParams object
Returns
-------
Int
Number of ticks since the start of the current phase.
"""
phase_time = ticks % self.config.phase_length
phase_sum = 0
subphase_ticks = 0
for i in range(self.config.num_phases):
phase_sum += self.config.phase_ticks[i]
if phase_time < phase_sum:
subphase_ticks = phase_time - phase_sum + self.config.phase_ticks[i]
return subphase_ticks
assert False
def contacts(self, ticks):
"""Calculates which feet should be in contact at the given number of ticks
Parameters
----------
ticks : Int
Number of timesteps since the program started.
gaitparams : GaitParams
GaitParams object
Returns
-------
numpy array (4,)
Numpy vector with 0 indicating flight and 1 indicating stance.
"""
return self.config.contact_phases[:, self.phase_index(ticks)]
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/Command.py | import numpy as np
class Command:
"""Stores movement command
"""
def __init__(self):
self.horizontal_velocity = np.array([0, 0])
self.yaw_rate = 0.0
self.height = -0.16
self.pitch = 0.0
self.roll = 0.0
self.activation = 0
self.hop_event = False
self.trot_event = False
self.activate_event = False |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/SwingLegController.py | import numpy as np
from transforms3d.euler import euler2mat
class SwingController:
def __init__(self, config):
self.config = config
def raibert_touchdown_location(
self, leg_index, command
):
delta_p_2d = (
self.config.alpha
* self.config.stance_ticks
* self.config.dt
* command.horizontal_velocity
)
delta_p = np.array([delta_p_2d[0], delta_p_2d[1], 0])
theta = (
self.config.beta
* self.config.stance_ticks
* self.config.dt
* command.yaw_rate
)
R = euler2mat(0, 0, theta)
return R @ self.config.default_stance[:, leg_index] + delta_p
def swing_height(self, swing_phase, triangular=True):
if triangular:
if swing_phase < 0.5:
swing_height_ = swing_phase / 0.5 * self.config.z_clearance
else:
swing_height_ = self.config.z_clearance * (1 - (swing_phase - 0.5) / 0.5)
return swing_height_
def next_foot_location(
self,
swing_prop,
leg_index,
state,
command,
):
assert swing_prop >= 0 and swing_prop <= 1
foot_location = state.foot_locations[:, leg_index]
swing_height_ = self.swing_height(swing_prop)
touchdown_location = self.raibert_touchdown_location(leg_index, command)
time_left = self.config.dt * self.config.swing_ticks * (1.0 - swing_prop)
v = (touchdown_location - foot_location) / time_left * np.array([1, 1, 0])
delta_foot_location = v * self.config.dt
z_vector = np.array([0, 0, swing_height_ + command.height])
return foot_location * np.array([1, 1, 0]) + z_vector + delta_foot_location
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/State.py | import numpy as np
from enum import Enum
class State:
def __init__(self):
self.horizontal_velocity = np.array([0.0, 0.0])
self.yaw_rate = 0.0
self.height = -0.16
self.pitch = 0.0
self.roll = 0.0
self.activation = 0
self.behavior_state = BehaviorState.REST
self.ticks = 0
self.foot_locations = np.zeros((3, 4))
self.joint_angles = np.zeros((3, 4))
self.behavior_state = BehaviorState.REST
class BehaviorState(Enum):
DEACTIVATED = -1
REST = 0
TROT = 1
HOP = 2
FINISHHOP = 3 |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/__init__.py | |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/StanceController.py | import numpy as np
from transforms3d.euler import euler2mat
class StanceController:
def __init__(self, config):
self.config = config
def position_delta(self, leg_index, state, command):
"""Calculate the difference between the next desired body location and the current body location
Parameters
----------
z_measured : float
Z coordinate of the feet relative to the body.
stance_params : StanceParams
Stance parameters object.
movement_reference : MovementReference
Movement reference object.
gait_params : GaitParams
Gait parameters object.
Returns
-------
(Numpy array (3), Numpy array (3, 3))
(Position increment, rotation matrix increment)
"""
z = state.foot_locations[2, leg_index]
v_xy = np.array(
[
-command.horizontal_velocity[0],
-command.horizontal_velocity[1],
1.0
/ self.config.z_time_constant
* (state.height - z),
]
)
delta_p = v_xy * self.config.dt
delta_R = euler2mat(0, 0, -command.yaw_rate * self.config.dt)
return (delta_p, delta_R)
# TODO: put current foot location into state
def next_foot_location(self, leg_index, state, command):
foot_location = state.foot_locations[:, leg_index]
(delta_p, delta_R) = self.position_delta(leg_index, state, command)
incremented_location = delta_R @ foot_location + delta_p
return incremented_location
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/IMU.py | import serial
import numpy as np
import time
class IMU:
def __init__(self, port, baudrate=500000):
self.serial_handle = serial.Serial(
port=port,
baudrate=baudrate,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0,
)
self.last_quat = np.array([1, 0, 0, 0])
self.start_time = time.time()
def flush_buffer(self):
self.serial_handle.reset_input_buffer()
def read_orientation(self):
"""Reads quaternion measurements from the Teensy until none are left. Returns the last read quaternion.
Parameters
----------
serial_handle : Serial object
Handle to the pyserial Serial object
Returns
-------
np array (4,)
If there was quaternion data to read on the serial port returns the quaternion as a numpy array, otherwise returns the last read quaternion.
"""
while True:
x = self.serial_handle.readline().decode("utf").strip()
if x is "" or x is None:
return self.last_quat
else:
parsed = x.split(",")
if len(parsed) == 4:
self.last_quat = np.array(parsed, dtype=np.float64)
else:
print("Did not receive 4-vector from imu")
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/Tests.py | # using LinearAlgebra
# using Profile
# using StaticArrays
# using Plots
# using BenchmarkTools
# include("Kinematics.jl")
# include("PupperConfig.jl")
# include("Gait.jl")
# include("StanceController.jl")
# include("SwingLegController.jl")
# include("Types.jl")
# include("Controller.jl")
import numpy as np
import matplotlib.pyplot as plt
from Kinematics import leg_explicit_inverse_kinematics
from PupperConfig import *
from Gaits import *
from StanceController import position_delta, stance_foot_location
from SwingLegController import *
from Types import MovementReference, GaitParams, StanceParams, SwingParams
from Controller import *
# function round_(a, dec)
# return map(x -> round(x, digits=dec), a)
# end
# function testInverseKinematicsExplicit!()
# println("\n-------------- Testing Inverse Kinematics -----------")
# config = PupperConfig()
# println("\nTesting Inverse Kinematics")
# function testHelper(r, alpha_true, i; do_assert=true)
# eps = 1e-6
# @time α = leg_explicitinversekinematics_prismatic(r, i, config)
# println("Leg ", i, ": r: ", r, " -> α: ", α)
# if do_assert
# @assert norm(α - alpha_true) < eps
# end
# end
# c = config.LEG_L/sqrt(2)
# offset = config.ABDUCTION_OFFSET
# testHelper(SVector(0, offset, -0.125), SVector(0, 0, 0), 2)
# testHelper(SVector(c, offset, -c), SVector(0, -pi/4, 0), 2)
# testHelper(SVector(-c, offset, -c), SVector(0, pi/4, 0), 2)
# testHelper(SVector(0, c, -c), missing, 2, do_assert=false)
# testHelper(SVector(-c, -offset, -c), [0, pi/4, 0], 1)
# testHelper(SVector(config.LEG_L * sqrt(3)/2, offset, -config.LEG_L / 2), SVector(0, -pi/3, 0), 2)
# end
def test_inverse_kinematics_linkage():
print("\n-------------- Testing Five-bar Linkage Inverse Kinematics -----------")
config = PupperConfig()
print("\nTesting Inverse Kinematics")
def testHelper(r, alpha_true, i, do_assert=True):
eps = 1e-6
alpha = leg_explicit_inverse_kinematics(r, i, config)
print("Leg ", i, ": r: ", r, " -> α: ", alpha)
if do_assert:
assert np.linalg.norm(alpha - alpha_true) < eps
c = config.LEG_L / (2 ** 0.5)
offset = config.ABDUCTION_OFFSET
testHelper(np.array([0, offset, -0.125]), None, 1, do_assert=False)
testHelper(np.array([c, offset, -c]), None, 1, do_assert=False)
testHelper(np.array([-c, offset, -c]), None, 1, do_assert=False)
testHelper(np.array([0, c, -c]), None, 1, do_assert=False)
testHelper(np.array([-c, -offset, -c]), None, 0, do_assert=False)
testHelper(
np.array([config.LEG_L * (3 ** 0.5) / 2, offset, -config.LEG_L / 2]),
None,
1,
do_assert=False,
)
# function testForwardKinematics!()
# println("\n-------------- Testing Forward Kinematics -----------")
# config = PupperConfig()
# println("\nTesting Forward Kinematics")
# function testHelper(alpha, r_true, i; do_assert=true)
# eps = 1e-6
# r = zeros(3)
# println("Vectors")
# a = [alpha.data...]
# @time legForwardKinematics!(r, a, i, config)
# println("SVectors")
# @time r = legForwardKinematics(alpha, i, config)
# println("Leg ", i, ": α: ", alpha, " -> r: ", r)
# if do_assert
# @assert norm(r_true - r) < eps
# end
# end
# l = config.LEG_L
# offset = config.ABDUCTION_OFFSET
# testHelper(SVector{3}([0.0, 0.0, 0.0]), SVector{3}([0, offset, -l]), 2)
# testHelper(SVector{3}([0.0, pi/4, 0.0]), missing, 2, do_assert=false)
# # testHelper([0.0, 0.0, 0.0], [0, offset, -l], 2)
# # testHelper([0.0, pi/4, 0.0], missing, 2, do_assert=false)
# end
# function testForwardInverseAgreeance()
# println("\n-------------- Testing Forward/Inverse Consistency -----------")
# config = PupperConfig()
# println("\nTest forward/inverse consistency")
# eps = 1e-6
# for i in 1:10
# alpha = SVector(rand()-0.5, rand()-0.5, (rand()-0.5)*0.05)
# leg = rand(1:4)
# @time r = legForwardKinematics(alpha, leg, config)
# # @code_warntype legForwardKinematics!(r, alpha, leg, config)
# @time alpha_prime = leg_explicitinversekinematics_prismatic(r, leg, config)
# # @code_warntype inverseKinematicsExplicit!(alpha_prime, r, leg, config)
# println("Leg ", leg, ": α: ", round_(alpha, 3), " -> r_body_foot: ", round_(r, 3), " -> α': ", round_(alpha_prime, 3))
# @assert norm(alpha_prime - alpha) < eps
# end
# end
# function testAllInverseKinematics()
# println("\n-------------- Testing Four Leg Inverse Kinematics -----------")
# function helper(r_body, alpha_true; do_assert=true)
# println("Timing for fourlegs_inversekinematics")
# config = PupperConfig()
# @time alpha = fourlegs_inversekinematics(SMatrix(r_body), config)
# @code_warntype fourlegs_inversekinematics(SMatrix(r_body), config)
# println("r: ", r_body, " -> α: ", alpha)
# if do_assert
# @assert norm(alpha - alpha_true) < 1e-10
# end
# end
# config = PupperConfig()
# f = config.LEG_FB
# l = config.LEG_LR
# s = -0.125
# o = config.ABDUCTION_OFFSET
# r_body = MMatrix{3,4}(zeros(3,4))
# r_body[:,1] = [f, -l-o, s]
# r_body[:,2] = [f, l+o, s]
# r_body[:,3] = [-f, -l-o, s]
# r_body[:,4] = [-f, l+o, s]
# helper(r_body, zeros(3,4))
# helper(SMatrix{3,4}(zeros(3,4)), missing, do_assert=false)
# end
# function testKinematics()
# testInverseKinematicsExplicit!()
# testForwardKinematics!()
# testForwardInverseAgreeance()
# testAllInverseKinematics()
# end
# function testGait()
# println("\n-------------- Testing Gait -----------")
# p = GaitParams()
# # println("Gait params=",p)
# t = 680
# println("Timing for phaseindex")
# @time ph = phaseindex(t, p)
# # @code_warntype phaseindex(t, p)
# println("t=",t," phase=",ph)
# @assert ph == 4
# @assert phaseindex(0, p) == 1
# println("Timing for contacts")
# @time c = contacts(t, p)
# # @code_warntype contacts(t, p)
# @assert typeof(c) == SArray{Tuple{4},Int64,1,4}
# println("t=", t, " contacts=", c)
# end
def test_stance_controller():
print("\n-------------- Testing Stance Controller -----------")
stanceparams = StanceParams()
gaitparams = GaitParams()
zmeas = -0.20
mvref = MovementReference()
dp, dR = position_delta(zmeas, stanceparams, mvref, gaitparams)
assert np.linalg.norm(dR - np.eye(3)) < 1e-10
assert np.linalg.norm(dp - np.array([0, 0, gaitparams.dt * 0.04])) < 1e-10
zmeas = -0.18
mvref = MovementReference()
mvref.v_xy_ref = np.array([1.0, 0.0])
mvref.z_ref = -0.18
dp, dR = position_delta(zmeas, stanceparams, mvref, gaitparams)
zmeas = -0.20
mvref = MovementReference()
mvref.wz_ref = 1.0
mvref.z_ref = -0.20
dp, dR = position_delta(zmeas, stanceparams, mvref, gaitparams)
assert np.linalg.norm(dp - np.array([0, 0, 0])) < 1e-10
assert np.linalg.norm(dR[0, 1] - (gaitparams.dt)) < 1e-6
stancefootloc = np.zeros(3)
sloc = stance_foot_location(stancefootloc, stanceparams, gaitparams, mvref)
# function typeswinglegcontroller()
# println("\n--------------- Code warn type for raibert_tdlocation[s] ----------")
# swp = SwingParams()
# stp = StanceParams()
# gp = GaitParams()
# mvref = MovementReference(SVector(1.0, 0.0), 0, -0.18)
# raibert_tdlocations(swp, stp, gp, mvref)
# mvref = MovementReference(SVector(1.0, 0.0), 0, -0.18)
# raibert_tdlocation(1, swp, stp, gp, mvref)
# end
# function TestSwingLegController()
# println("\n-------------- Testing Swing Leg Controller -----------")
# swp = SwingParams()
# stp = StanceParams()
# gp = GaitParams()
# p = ControllerParams()
# println("Timing for swingheight:")
# @time z = swingheight(0.5, swp)
# println("z clearance at t=1/2swingtime =>",z)
# @assert abs(z - swp.zclearance) < 1e-10
# println("Timing for swingheight:")
# @time z = swingheight(0, swp)
# println("Z clearance at t=0 =>",z)
# @assert abs(z) < 1e-10
# mvref = MovementReference(SVector(1.0, 0.0), 0, -0.18)
# println("Timing for raibert tdlocation*s*:")
# @time l = raibert_tdlocations(swp, stp, gp, mvref)
# target = stp.defaultstance .+ [gp.stanceticks*gp.dt*0.5*1, 0, 0]
# println("Touchdown locations =>", l, " <?=> ", target)
# @assert norm(l - target) <= 1e-10
# mvref = MovementReference(SVector(1.0, 0.0), 0, -0.18)
# println("Timing for raibert tdlocation:")
# @time l = raibert_tdlocation(1, swp, stp, gp, mvref)
# fcurrent = SMatrix{3, 4, Float64}(stp.defaultstance)
# mvref = MovementReference()
# tswing = 0.125
# println("Timing for swingfootlocation*s* increment")
# @time l = swingfootlocations(tswing, fcurrent, swp, stp, gp, mvref)
# println(l)
# fcurrent = SVector{3, Float64}(0.0, 0.0, 0.0)
# println("Timing for swingfootlocation")
# @time swingfootlocation(tswing, fcurrent, 1, swp, stp, gp, mvref)
# typeswinglegcontroller()
# return nothing
# end
def test_run():
print("Run timing")
foot_loc_history, joint_angle_history = run()
plt.subplot(211)
x = plt.plot(foot_loc_history[0, :, :].T, label="x")
y = plt.plot(foot_loc_history[1, :, :].T, label="y")
z = plt.plot(foot_loc_history[2, :, :].T, label="z")
plt.subplot(212)
alpha = plt.plot(joint_angle_history[0, :, :].T, label="alpha")
beta = plt.plot(joint_angle_history[1, :, :].T, label="beta")
gamma = plt.plot(joint_angle_history[2, :, :].T, label="gamma")
plt.show()
# plot(x, β, y, α, z, γ, layout=(3,2), legend=false))
# function teststep()
# swingparams = SwingParams()
# stanceparams = StanceParams()
# gaitparams = GaitParams()
# mvref = MovementReference(vxyref=SVector{2}(0.2, 0.0), wzref=0.0)
# conparams = ControllerParams()
# robotconfig = PupperConfig()
# footlocations::SMatrix{3, 4, Float64, 12} = stanceparams.defaultstance .+ SVector{3, Float64}(0, 0, mvref.zref)
# ticks = 1
# println("Timing for step!")
# @btime step($ticks, $footlocations, $swingparams, $stanceparams, $gaitparams, $mvref, $conparams)
# @code_warntype step(ticks, footlocations, swingparams, stanceparams, gaitparams, mvref, conparams)
# end
# # testGait()
# # testKinematics()
# # TestStanceController()
# # testStaticArrays()
# # TestSwingLegController()
# test_inversekinematics_linkage()
# # teststep()
# # testrun()
test_inverse_kinematics_linkage()
test_stance_controller()
test_run()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/JoystickInterface.py | import UDPComms
import numpy as np
import time
from src.State import BehaviorState, State
from src.Command import Command
from src.Utilities import deadband, clipped_first_order_filter
class JoystickInterface:
def __init__(
self, config, udp_port=8830, udp_publisher_port = 8840,
):
self.config = config
self.previous_gait_toggle = 0
self.previous_state = BehaviorState.REST
self.previous_hop_toggle = 0
self.previous_activate_toggle = 0
self.message_rate = 50
self.udp_handle = UDPComms.Subscriber(udp_port, timeout=0.3)
self.udp_publisher = UDPComms.Publisher(udp_publisher_port)
def get_command(self, state, do_print=False):
try:
msg = self.udp_handle.get()
command = Command()
####### Handle discrete commands ########
# Check if requesting a state transition to trotting, or from trotting to resting
gait_toggle = msg["R1"]
command.trot_event = (gait_toggle == 1 and self.previous_gait_toggle == 0)
# Check if requesting a state transition to hopping, from trotting or resting
hop_toggle = msg["x"]
command.hop_event = (hop_toggle == 1 and self.previous_hop_toggle == 0)
activate_toggle = msg["L1"]
command.activate_event = (activate_toggle == 1 and self.previous_activate_toggle == 0)
# Update previous values for toggles and state
self.previous_gait_toggle = gait_toggle
self.previous_hop_toggle = hop_toggle
self.previous_activate_toggle = activate_toggle
####### Handle continuous commands ########
x_vel = msg["ly"] * self.config.max_x_velocity
y_vel = msg["lx"] * -self.config.max_y_velocity
command.horizontal_velocity = np.array([x_vel, y_vel])
command.yaw_rate = msg["rx"] * -self.config.max_yaw_rate
message_rate = msg["message_rate"]
message_dt = 1.0 / message_rate
pitch = msg["ry"] * self.config.max_pitch
deadbanded_pitch = deadband(
pitch, self.config.pitch_deadband
)
pitch_rate = clipped_first_order_filter(
state.pitch,
deadbanded_pitch,
self.config.max_pitch_rate,
self.config.pitch_time_constant,
)
command.pitch = state.pitch + message_dt * pitch_rate
height_movement = msg["dpady"]
command.height = state.height - message_dt * self.config.z_speed * height_movement
roll_movement = - msg["dpadx"]
command.roll = state.roll + message_dt * self.config.roll_speed * roll_movement
return command
except UDPComms.timeout:
if do_print:
print("UDP Timed out")
return Command()
def set_color(self, color):
joystick_msg = {"ps4_color": color}
self.udp_publisher.send(joystick_msg) |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/Utilities.py | import numpy as np
def deadband(value, band_radius):
return max(value - band_radius, 0) + min(value + band_radius, 0)
def clipped_first_order_filter(input, target, max_rate, tau):
rate = (target - input) / tau
return np.clip(rate, -max_rate, max_rate)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/src/Controller.py | from src.Gaits import GaitController
from src.StanceController import StanceController
from src.SwingLegController import SwingController
from src.Utilities import clipped_first_order_filter
from src.State import BehaviorState, State
import numpy as np
from transforms3d.euler import euler2mat, quat2euler
from transforms3d.quaternions import qconjugate, quat2axangle
from transforms3d.axangles import axangle2mat
class Controller:
"""Controller and planner object
"""
def __init__(
self,
config,
inverse_kinematics,
):
self.config = config
self.smoothed_yaw = 0.0 # for REST mode only
self.inverse_kinematics = inverse_kinematics
self.contact_modes = np.zeros(4)
self.gait_controller = GaitController(self.config)
self.swing_controller = SwingController(self.config)
self.stance_controller = StanceController(self.config)
self.hop_transition_mapping = {BehaviorState.REST: BehaviorState.HOP, BehaviorState.HOP: BehaviorState.FINISHHOP, BehaviorState.FINISHHOP: BehaviorState.REST, BehaviorState.TROT: BehaviorState.HOP}
self.trot_transition_mapping = {BehaviorState.REST: BehaviorState.TROT, BehaviorState.TROT: BehaviorState.REST, BehaviorState.HOP: BehaviorState.TROT, BehaviorState.FINISHHOP: BehaviorState.TROT}
self.activate_transition_mapping = {BehaviorState.DEACTIVATED: BehaviorState.REST, BehaviorState.REST: BehaviorState.DEACTIVATED}
def step_gait(self, state, command):
"""Calculate the desired foot locations for the next timestep
Returns
-------
Numpy array (3, 4)
Matrix of new foot locations.
"""
contact_modes = self.gait_controller.contacts(state.ticks)
new_foot_locations = np.zeros((3, 4))
for leg_index in range(4):
contact_mode = contact_modes[leg_index]
foot_location = state.foot_locations[:, leg_index]
if contact_mode == 1:
new_location = self.stance_controller.next_foot_location(leg_index, state, command)
else:
swing_proportion = (
self.gait_controller.subphase_ticks(state.ticks) / self.config.swing_ticks
)
new_location = self.swing_controller.next_foot_location(
swing_proportion,
leg_index,
state,
command
)
new_foot_locations[:, leg_index] = new_location
return new_foot_locations, contact_modes
def run(self, state, command):
"""Steps the controller forward one timestep
Parameters
----------
controller : Controller
Robot controller object.
"""
########## Update operating state based on command ######
if command.activate_event:
state.behavior_state = self.activate_transition_mapping[state.behavior_state]
elif command.trot_event:
state.behavior_state = self.trot_transition_mapping[state.behavior_state]
elif command.hop_event:
state.behavior_state = self.hop_transition_mapping[state.behavior_state]
if state.behavior_state == BehaviorState.TROT:
state.foot_locations, contact_modes = self.step_gait(
state,
command,
)
# Apply the desired body rotation
rotated_foot_locations = (
euler2mat(
command.roll, command.pitch, 0.0
)
@ state.foot_locations
)
# Construct foot rotation matrix to compensate for body tilt
(roll, pitch, yaw) = quat2euler(state.quat_orientation)
correction_factor = 0.8
max_tilt = 0.4
roll_compensation = correction_factor * np.clip(roll, -max_tilt, max_tilt)
pitch_compensation = correction_factor * np.clip(pitch, -max_tilt, max_tilt)
rmat = euler2mat(roll_compensation, pitch_compensation, 0)
rotated_foot_locations = rmat.T @ rotated_foot_locations
state.joint_angles = self.inverse_kinematics(
rotated_foot_locations, self.config
)
elif state.behavior_state == BehaviorState.HOP:
state.foot_locations = (
self.config.default_stance
+ np.array([0, 0, -0.09])[:, np.newaxis]
)
state.joint_angles = self.inverse_kinematics(
state.foot_locations, self.config
)
elif state.behavior_state == BehaviorState.FINISHHOP:
state.foot_locations = (
self.config.default_stance
+ np.array([0, 0, -0.22])[:, np.newaxis]
)
state.joint_angles = self.inverse_kinematics(
state.foot_locations, self.config
)
elif state.behavior_state == BehaviorState.REST:
yaw_proportion = command.yaw_rate / self.config.max_yaw_rate
self.smoothed_yaw += (
self.config.dt
* clipped_first_order_filter(
self.smoothed_yaw,
yaw_proportion * -self.config.max_stance_yaw,
self.config.max_stance_yaw_rate,
self.config.yaw_time_constant,
)
)
# Set the foot locations to the default stance plus the standard height
state.foot_locations = (
self.config.default_stance
+ np.array([0, 0, command.height])[:, np.newaxis]
)
# Apply the desired body rotation
rotated_foot_locations = (
euler2mat(
command.roll,
command.pitch,
self.smoothed_yaw,
)
@ state.foot_locations
)
state.joint_angles = self.inverse_kinematics(
rotated_foot_locations, self.config
)
state.ticks += 1
state.pitch = command.pitch
state.roll = command.roll
state.height = command.height
def set_pose_to_default(self):
state.foot_locations = (
self.config.default_stance
+ np.array([0, 0, self.config.default_z_ref])[:, np.newaxis]
)
state.joint_angles = controller.inverse_kinematics(
state.foot_locations, self.config
)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/ServoCalibration.py | # WARNING: This file is machine generated. Edit at your own risk.
import numpy as np
MICROS_PER_RAD = 11.333 * 180.0 / np.pi
NEUTRAL_ANGLE_DEGREES = np.array(
[[ 0., 0., 0., 0.],
[ 45., 45., 45., 45.],
[-45.,-45.,-45.,-45.]]
)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/__init__.py | |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/HardwareInterface.py | import pigpio
from pupper.Config import ServoParams, PWMParams
class HardwareInterface:
def __init__(self):
self.pi = pigpio.pi()
self.pwm_params = PWMParams()
self.servo_params = ServoParams()
initialize_pwm(self.pi, self.pwm_params)
def set_actuator_postions(self, joint_angles):
send_servo_commands(self.pi, self.pwm_params, self.servo_params, joint_angles)
def set_actuator_position(self, joint_angle, axis, leg):
send_servo_command(self.pi, self.pwm_params, self.servo_params, joint_angle, axis, leg)
def pwm_to_duty_cycle(pulsewidth_micros, pwm_params):
"""Converts a pwm signal (measured in microseconds) to a corresponding duty cycle on the gpio pwm pin
Parameters
----------
pulsewidth_micros : float
Width of the pwm signal in microseconds
pwm_params : PWMParams
PWMParams object
Returns
-------
float
PWM duty cycle corresponding to the pulse width
"""
return int(pulsewidth_micros / 1e6 * pwm_params.freq * pwm_params.range)
def angle_to_pwm(angle, servo_params, axis_index, leg_index):
"""Converts a desired servo angle into the corresponding PWM command
Parameters
----------
angle : float
Desired servo angle, relative to the vertical (z) axis
servo_params : ServoParams
ServoParams object
axis_index : int
Specifies which joint of leg to control. 0 is abduction servo, 1 is inner hip servo, 2 is outer hip servo.
leg_index : int
Specifies which leg to control. 0 is front-right, 1 is front-left, 2 is back-right, 3 is back-left.
Returns
-------
float
PWM width in microseconds
"""
angle_deviation = (
angle - servo_params.neutral_angles[axis_index, leg_index]
) * servo_params.servo_multipliers[axis_index, leg_index]
pulse_width_micros = (
servo_params.neutral_position_pwm
+ servo_params.micros_per_rad * angle_deviation
)
return pulse_width_micros
def angle_to_duty_cycle(angle, pwm_params, servo_params, axis_index, leg_index):
return pwm_to_duty_cycle(
angle_to_pwm(angle, servo_params, axis_index, leg_index), pwm_params
)
def initialize_pwm(pi, pwm_params):
for leg_index in range(4):
for axis_index in range(3):
pi.set_PWM_frequency(
pwm_params.pins[axis_index, leg_index], pwm_params.freq
)
pi.set_PWM_range(pwm_params.pins[axis_index, leg_index], pwm_params.range)
def send_servo_commands(pi, pwm_params, servo_params, joint_angles):
for leg_index in range(4):
for axis_index in range(3):
duty_cycle = angle_to_duty_cycle(
joint_angles[axis_index, leg_index],
pwm_params,
servo_params,
axis_index,
leg_index,
)
pi.set_PWM_dutycycle(pwm_params.pins[axis_index, leg_index], duty_cycle)
def send_servo_command(pi, pwm_params, servo_params, joint_angle, axis, leg):
duty_cycle = angle_to_duty_cycle(joint_angle, pwm_params, servo_params, axis, leg)
pi.set_PWM_dutycycle(pwm_params.pins[axis, leg], duty_cycle)
def deactivate_servos(pi, pwm_params):
for leg_index in range(4):
for axis_index in range(3):
pi.set_PWM_dutycycle(pwm_params.pins[axis_index, leg_index], 0)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/Kinematics.py | import numpy as np
from transforms3d.euler import euler2mat
def leg_explicit_inverse_kinematics(r_body_foot, leg_index, config):
"""Find the joint angles corresponding to the given body-relative foot position for a given leg and configuration
Parameters
----------
r_body_foot : [type]
[description]
leg_index : [type]
[description]
config : [type]
[description]
Returns
-------
numpy array (3)
Array of corresponding joint angles.
"""
(x, y, z) = r_body_foot
# Distance from the leg origin to the foot, projected into the y-z plane
R_body_foot_yz = (y ** 2 + z ** 2) ** 0.5
# Distance from the leg's forward/back point of rotation to the foot
R_hip_foot_yz = (R_body_foot_yz ** 2 - config.ABDUCTION_OFFSET ** 2) ** 0.5
# Interior angle of the right triangle formed in the y-z plane by the leg that is coincident to the ab/adduction axis
# For feet 2 (front left) and 4 (back left), the abduction offset is positive, for the right feet, the abduction offset is negative.
arccos_argument = config.ABDUCTION_OFFSETS[leg_index] / R_body_foot_yz
arccos_argument = np.clip(arccos_argument, -0.99, 0.99)
phi = np.arccos(arccos_argument)
# Angle of the y-z projection of the hip-to-foot vector, relative to the positive y-axis
hip_foot_angle = np.arctan2(z, y)
# Ab/adduction angle, relative to the positive y-axis
abduction_angle = phi + hip_foot_angle
# theta: Angle between the tilted negative z-axis and the hip-to-foot vector
theta = np.arctan2(-x, R_hip_foot_yz)
# Distance between the hip and foot
R_hip_foot = (R_hip_foot_yz ** 2 + x ** 2) ** 0.5
# Angle between the line going from hip to foot and the link L1
arccos_argument = (config.LEG_L1 ** 2 + R_hip_foot ** 2 - config.LEG_L2 ** 2) / (
2 * config.LEG_L1 * R_hip_foot
)
arccos_argument = np.clip(arccos_argument, -0.99, 0.99)
trident = np.arccos(arccos_argument)
# Angle of the first link relative to the tilted negative z axis
hip_angle = theta + trident
# Angle between the leg links L1 and L2
arccos_argument = (config.LEG_L1 ** 2 + config.LEG_L2 ** 2 - R_hip_foot ** 2) / (
2 * config.LEG_L1 * config.LEG_L2
)
arccos_argument = np.clip(arccos_argument, -0.99, 0.99)
beta = np.arccos(arccos_argument)
# Angle of the second link relative to the tilted negative z axis
knee_angle = hip_angle - (np.pi - beta)
return np.array([abduction_angle, hip_angle, knee_angle])
def four_legs_inverse_kinematics(r_body_foot, config):
"""Find the joint angles for all twelve DOF correspoinding to the given matrix of body-relative foot positions.
Parameters
----------
r_body_foot : numpy array (3,4)
Matrix of the body-frame foot positions. Each column corresponds to a separate foot.
config : Config object
Object of robot configuration parameters.
Returns
-------
numpy array (3,4)
Matrix of corresponding joint angles.
"""
alpha = np.zeros((3, 4))
for i in range(4):
body_offset = config.LEG_ORIGINS[:, i]
alpha[:, i] = leg_explicit_inverse_kinematics(
r_body_foot[:, i] - body_offset, i, config
)
return alpha
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/HardwareConfig.py | """
Per-robot configuration file that is particular to each individual robot, not just the type of robot.
"""
PS4_COLOR = {"red": 0, "blue": 0, "green": 255}
PS4_DEACTIVATED_COLOR = {"red": 0, "blue": 0, "green": 50} |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/pupper/Config.py | import numpy as np
from pupper.ServoCalibration import MICROS_PER_RAD, NEUTRAL_ANGLE_DEGREES
from pupper.HardwareConfig import PS4_COLOR, PS4_DEACTIVATED_COLOR
from enum import Enum
# TODO: put these somewhere else
class PWMParams:
def __init__(self):
self.pins = np.array([[2, 14, 18, 23], [3, 15, 27, 24], [4, 17, 22, 25]])
self.range = 4000
self.freq = 250
class ServoParams:
def __init__(self):
self.neutral_position_pwm = 1500 # Middle position
self.micros_per_rad = MICROS_PER_RAD # Must be calibrated
# The neutral angle of the joint relative to the modeled zero-angle in degrees, for each joint
self.neutral_angle_degrees = NEUTRAL_ANGLE_DEGREES
self.servo_multipliers = np.array(
[[1, 1, 1, 1], [-1, 1, -1, 1], [1, -1, 1, -1]]
)
@property
def neutral_angles(self):
return self.neutral_angle_degrees * np.pi / 180.0 # Convert to radians
class Configuration:
def __init__(self):
################# CONTROLLER BASE COLOR ##############
self.ps4_color = PS4_COLOR
self.ps4_deactivated_color = PS4_DEACTIVATED_COLOR
#################### COMMANDS ####################
self.max_x_velocity = 0.4
self.max_y_velocity = 0.3
self.max_yaw_rate = 2.0
self.max_pitch = 30.0 * np.pi / 180.0
#################### MOVEMENT PARAMS ####################
self.z_time_constant = 0.02
self.z_speed = 0.03 # maximum speed [m/s]
self.pitch_deadband = 0.02
self.pitch_time_constant = 0.25
self.max_pitch_rate = 0.15
self.roll_speed = 0.16 # maximum roll rate [rad/s]
self.yaw_time_constant = 0.3
self.max_stance_yaw = 1.2
self.max_stance_yaw_rate = 2.0
#################### STANCE ####################
self.delta_x = 0.1
self.delta_y = 0.09
self.x_shift = 0.0
self.default_z_ref = -0.16
#################### SWING ######################
self.z_coeffs = None
self.z_clearance = 0.07
self.alpha = (
0.5 # Ratio between touchdown distance and total horizontal stance movement
)
self.beta = (
0.5 # Ratio between touchdown distance and total horizontal stance movement
)
#################### GAIT #######################
self.dt = 0.01
self.num_phases = 4
self.contact_phases = np.array(
[[1, 1, 1, 0], [1, 0, 1, 1], [1, 0, 1, 1], [1, 1, 1, 0]]
)
self.overlap_time = (
0.10 # duration of the phase where all four feet are on the ground
)
self.swing_time = (
0.15 # duration of the phase when only two feet are on the ground
)
######################## GEOMETRY ######################
self.LEG_FB = 0.10 # front-back distance from center line to leg axis
self.LEG_LR = 0.04 # left-right distance from center line to leg plane
self.LEG_L2 = 0.115
self.LEG_L1 = 0.1235
self.ABDUCTION_OFFSET = 0.03 # distance from abduction axis to leg
self.FOOT_RADIUS = 0.01
self.HIP_L = 0.0394
self.HIP_W = 0.0744
self.HIP_T = 0.0214
self.HIP_OFFSET = 0.0132
self.L = 0.276
self.W = 0.100
self.T = 0.050
self.LEG_ORIGINS = np.array(
[
[self.LEG_FB, self.LEG_FB, -self.LEG_FB, -self.LEG_FB],
[-self.LEG_LR, self.LEG_LR, -self.LEG_LR, self.LEG_LR],
[0, 0, 0, 0],
]
)
self.ABDUCTION_OFFSETS = np.array(
[
-self.ABDUCTION_OFFSET,
self.ABDUCTION_OFFSET,
-self.ABDUCTION_OFFSET,
self.ABDUCTION_OFFSET,
]
)
################### INERTIAL ####################
self.FRAME_MASS = 0.560 # kg
self.MODULE_MASS = 0.080 # kg
self.LEG_MASS = 0.030 # kg
self.MASS = self.FRAME_MASS + (self.MODULE_MASS + self.LEG_MASS) * 4
# Compensation factor of 3 because the inertia measurement was just
# of the carbon fiber and plastic parts of the frame and did not
# include the hip servos and electronics
self.FRAME_INERTIA = tuple(
map(lambda x: 3.0 * x, (1.844e-4, 1.254e-3, 1.337e-3))
)
self.MODULE_INERTIA = (3.698e-5, 7.127e-6, 4.075e-5)
leg_z = 1e-6
leg_mass = 0.010
leg_x = 1 / 12 * self.LEG_L1 ** 2 * leg_mass
leg_y = leg_x
self.LEG_INERTIA = (leg_x, leg_y, leg_z)
@property
def default_stance(self):
return np.array(
[
[
self.delta_x + self.x_shift,
self.delta_x + self.x_shift,
-self.delta_x + self.x_shift,
-self.delta_x + self.x_shift,
],
[-self.delta_y, self.delta_y, -self.delta_y, self.delta_y],
[0, 0, 0, 0],
]
)
################## SWING ###########################
@property
def z_clearance(self):
return self.__z_clearance
@z_clearance.setter
def z_clearance(self, z):
self.__z_clearance = z
# b_z = np.array([0, 0, 0, 0, self.__z_clearance])
# A_z = np.array(
# [
# [0, 0, 0, 0, 1],
# [1, 1, 1, 1, 1],
# [0, 0, 0, 1, 0],
# [4, 3, 2, 1, 0],
# [0.5 ** 4, 0.5 ** 3, 0.5 ** 2, 0.5 ** 1, 0.5 ** 0],
# ]
# )
# self.z_coeffs = solve(A_z, b_z)
########################### GAIT ####################
@property
def overlap_ticks(self):
return int(self.overlap_time / self.dt)
@property
def swing_ticks(self):
return int(self.swing_time / self.dt)
@property
def stance_ticks(self):
return 2 * self.overlap_ticks + self.swing_ticks
@property
def phase_ticks(self):
return np.array(
[self.overlap_ticks, self.swing_ticks, self.overlap_ticks, self.swing_ticks]
)
@property
def phase_length(self):
return 2 * self.overlap_ticks + 2 * self.swing_ticks
class SimulationConfig:
def __init__(self):
self.XML_IN = "pupper.xml"
self.XML_OUT = "pupper_out.xml"
self.START_HEIGHT = 0.3
self.MU = 1.5 # coeff friction
self.DT = 0.001 # seconds between simulation steps
self.JOINT_SOLREF = "0.001 1" # time constant and damping ratio for joints
self.JOINT_SOLIMP = "0.9 0.95 0.001" # joint constraint parameters
self.GEOM_SOLREF = "0.01 1" # time constant and damping ratio for geom contacts
self.GEOM_SOLIMP = "0.9 0.95 0.001" # geometry contact parameters
# Joint params
G = 220 # Servo gear ratio
m_rotor = 0.016 # Servo rotor mass
r_rotor = 0.005 # Rotor radius
self.ARMATURE = G ** 2 * m_rotor * r_rotor ** 2 # Inertia of rotational joints
# print("Servo armature", self.ARMATURE)
NATURAL_DAMPING = 1.0 # Damping resulting from friction
ELECTRICAL_DAMPING = 0.049 # Damping resulting from back-EMF
self.REV_DAMPING = (
NATURAL_DAMPING + ELECTRICAL_DAMPING
) # Damping torque on the revolute joints
# Servo params
self.SERVO_REV_KP = 300 # Position gain [Nm/rad]
# Force limits
self.MAX_JOINT_TORQUE = 3.0
self.REVOLUTE_RANGE = 1.57
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/woofer/__init__.py | |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/woofer/HardwareInterface.py | import odrive
from odrive.enums import *
from woofer.Config import RobotConfig
from woofer.HardwareConfig import (
ODRIVE_SERIAL_NUMBERS,
ACTUATOR_DIRECTIONS,
ANGLE_OFFSETS,
map_actuators_to_axes,
)
import time
import threading
import numpy as np
class HardwareInterface:
def __init__(self):
self.config = RobotConfig()
assert len(ODRIVE_SERIAL_NUMBERS) == self.config.NUM_ODRIVES
self.odrives = [None for _ in range(self.config.NUM_ODRIVES)]
threads = []
for i in range(self.config.NUM_ODRIVES):
t = threading.Thread(target=find_odrive, args=(i, self.odrives))
threads.append(t)
t.start()
for t in threads:
t.join()
input("Press enter to calibrate odrives...")
calibrate_odrives(self.odrives)
set_position_control(self.odrives)
self.axes = assign_axes(self.odrives)
def set_actuator_postions(self, joint_angles):
set_all_odrive_positions(self.axes, joint_angles, self.config)
def deactivate_actuators(self):
set_odrives_idle(self.odrives)
def find_odrive(i, odrives):
o = odrive.find_any(serial_number=ODRIVE_SERIAL_NUMBERS[i])
print("Found odrive: ", i)
odrives[i] = o
def calibrate_odrives(odrives):
for odrv in odrives:
odrv.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
odrv.axis1.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
for odrv in odrives:
while (
odrv.axis0.current_state != AXIS_STATE_IDLE
or odrv.axis1.current_state != AXIS_STATE_IDLE
):
time.sleep(0.1) # busy waiting - not ideal
def set_position_control(odrives):
for odrv in odrives:
for axis in [odrv.axis0, odrv.axis1]:
axis.controller.config.pos_gain = 60
axis.controller.config.vel_gain = 0.002
axis.controller.config.vel_limit_tolerance = 0
axis.controller.config.vel_integrator_gain = 0
axis.motor.config.current_lim = 15
print("Updated gains")
odrv.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
def set_odrives_idle(odrives):
for odrv in odrives:
odrv.axis0.requested_state = AXIS_STATE_IDLE
odrv.axis1.requested_state = AXIS_STATE_IDLE
def assign_axes(odrives):
return map_actuators_to_axes(odrives)
def set_all_odrive_positions(axes, joint_angles, config):
for i in range(joint_angles.shape[0]):
for j in range(joint_angles.shape[1]):
axes[i][j].controller.pos_setpoint = actuator_angle_to_odrive(
joint_angles, i, j, config
)
def radians_to_encoder_count(angle, config):
return (angle / (2 * np.pi)) * config.ENCODER_CPR * config.MOTOR_REDUCTION
def actuator_angle_to_odrive(joint_angles, i, j, config):
offset_angle = joint_angles[i][j] + ANGLE_OFFSETS[i][j]
odrive_radians = offset_angle * ACTUATOR_DIRECTIONS[i][j]
return radians_to_encoder_count(odrive_radians, config)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/woofer/Kinematics.py | import numpy as np
def leg_forward_kinematics(alpha, leg_index, config):
"""Find the body-centric coordinates of a given foot given the joint angles.
Parameters
----------
alpha : Numpy array (3)
Joint angles ordered as (abduction, hip, knee)
leg_index : int
Leg index.
config : Config object
Robot parameters object
Returns
-------
Numpy array (3)
Body-centric coordinates of the specified foot
"""
pass
def leg_explicit_inverse_kinematics(r_body_foot, leg_index, config):
"""Find the joint angles corresponding to the given body-relative foot position for a given leg and configuration
Parameters
----------
r_body_foot : [type]
[description]
leg_index : [type]
[description]
config : [type]
[description]
Returns
-------
numpy array (3)
Array of corresponding joint angles.
"""
(x, y, z) = r_body_foot
# Distance from the leg origin to the foot, projected into the y-z plane
R_body_foot_yz = (y ** 2 + z ** 2) ** 0.5
# Distance from the leg's forward/back point of rotation to the foot
R_hip_foot_yz = (R_body_foot_yz ** 2 - config.ABDUCTION_OFFSET ** 2) ** 0.5
# Interior angle of the right triangle formed in the y-z plane by the leg that is coincident to the ab/adduction axis
# For feet 2 (front left) and 4 (back left), the abduction offset is positive, for the right feet, the abduction offset is negative.
cos_param = config.ABDUCTION_OFFSETS[leg_index] / R_body_foot_yz
if abs(cos_param) > 0.9:
print("Clipping 1st cos param")
cos_param = np.clip(cos_param, -0.9, 0.9)
phi = np.arccos(cos_param)
# Angle of the y-z projection of the hip-to-foot vector, relative to the positive y-axis
hip_foot_angle = np.arctan2(z, y)
# Ab/adduction angle, relative to the positive y-axis
abduction_angle = phi + hip_foot_angle
# theta: Angle between the tilted negative z-axis and the hip-to-foot vector
theta = np.arctan2(-x, R_hip_foot_yz)
# Distance between the hip and foot
R_hip_foot = (R_hip_foot_yz ** 2 + x ** 2) ** 0.5
# Using law of cosines to determine the angle between upper leg links
cos_param = (config.UPPER_LEG ** 2 + R_hip_foot ** 2 - config.LOWER_LEG ** 2) / (2.0*config.UPPER_LEG*R_hip_foot)
# Ensure that the leg isn't over or under extending
cos_param = np.clip(cos_param, -0.9, 0.9)
if abs(cos_param) > 0.9:
print("Clipping 2nd cos param")
# gamma: Angle between upper leg links and the center of the leg
gamma = np.arccos(cos_param)
return np.array([abduction_angle, theta - gamma, theta + gamma])
def four_legs_inverse_kinematics(r_body_foot, config):
"""Find the joint angles for all twelve DOF correspoinding to the given matrix of body-relative foot positions.
Parameters
----------
r_body_foot : numpy array (3,4)
Matrix of the body-frame foot positions. Each column corresponds to a separate foot.
config : Config object
Object of robot configuration parameters.
Returns
-------
numpy array (3,4)
Matrix of corresponding joint angles.
"""
alpha = np.zeros((3, 4))
for i in range(4):
body_offset = config.LEG_ORIGINS[:, i]
alpha[:, i] = leg_explicit_inverse_kinematics(
r_body_foot[:, i] - body_offset, i, config
)
return alpha |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/woofer/HardwareConfig.py | """
Per-robot configuration file that is particular to each individual robot, not just the type of robot.
"""
import numpy as np
ODRIVE_SERIAL_NUMBERS = [
"2065339F304B",
"208F3384304B",
"365833753037",
"207E35753748",
"208F3385304B",
"208E3387304B",
]
ACTUATOR_DIRECTIONS = np.array([[1, 1, -1, -1], [-1, -1, -1, -1], [1, 1, 1, 1]])
ANGLE_OFFSETS = np.array(
[
[0, 0, 0, 0],
[np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2],
[-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2],
]
)
def map_actuators_to_axes(odrives):
axes = [[None for _ in range(4)] for _ in range(3)]
axes[0][0] = odrives[1].axis1
axes[1][0] = odrives[0].axis0
axes[2][0] = odrives[0].axis1
axes[0][1] = odrives[1].axis0
axes[1][1] = odrives[2].axis1
axes[2][1] = odrives[2].axis0
axes[0][2] = odrives[4].axis1
axes[1][2] = odrives[5].axis0
axes[2][2] = odrives[5].axis1
axes[0][3] = odrives[4].axis0
axes[1][3] = odrives[3].axis1
axes[2][3] = odrives[3].axis0
return axes
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/StanfordQuadruped-pupper/woofer/Config.py | import numpy as np
from scipy.linalg import solve
class BehaviorState(Enum):
REST = 0
TROT = 1
HOP = 2
FINISHHOP = 3
class UserInputParams:
def __init__(self):
self.max_x_velocity = 0.5
self.max_y_velocity = 0.24
self.max_yaw_rate = 0.2
self.max_pitch = 30.0 * np.pi / 180.0
class MovementReference:
"""Stores movement reference
"""
def __init__(self):
self.v_xy_ref = np.array([0, 0])
self.wz_ref = 0.0
self.z_ref = -0.265
self.pitch = 0.0
self.roll = 0.0
class SwingParams:
"""Swing Parameters
"""
def __init__(self):
self.z_coeffs = None
self.z_clearance = 0.05
self.alpha = (
0.5
) # Ratio between touchdown distance and total horizontal stance movement
self.beta = (
0.5
) # Ratio between touchdown distance and total horizontal stance movement
@property
def z_clearance(self):
return self.__z_clearance
@z_clearance.setter
def z_clearance(self, z):
self.__z_clearance = z
b_z = np.array([0, 0, 0, 0, self.__z_clearance])
A_z = np.array(
[
[0, 0, 0, 0, 1],
[1, 1, 1, 1, 1],
[0, 0, 0, 1, 0],
[4, 3, 2, 1, 0],
[0.5 ** 4, 0.5 ** 3, 0.5 ** 2, 0.5 ** 1, 0.5 ** 0],
]
)
self.z_coeffs = solve(A_z, b_z)
class StanceParams:
"""Stance parameters
"""
def __init__(self):
self.z_time_constant = 0.02
self.z_speed = 0.03 # maximum speed [m/s]
self.pitch_deadband = 0.02
self.pitch_time_constant = 0.25
self.max_pitch_rate = 0.15
self.roll_speed = 0.16 # maximum roll rate [rad/s]
self.delta_x = 0.23
self.delta_y = 0.173
self.x_shift = -0.01
@property
def default_stance(self):
return np.array(
[
[
self.delta_x + self.x_shift,
self.delta_x + self.x_shift,
-self.delta_x + self.x_shift,
-self.delta_x + self.x_shift,
],
[-self.delta_y, self.delta_y, -self.delta_y, self.delta_y],
[0, 0, 0, 0],
]
)
class GaitParams:
"""Gait Parameters
"""
def __init__(self):
self.dt = 0.01
self.num_phases = 4
self.contact_phases = np.array(
[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
)
self.overlap_time = (
0.5 # duration of the phase where all four feet are on the ground
)
self.swing_time = (
0.5 # duration of the phase when only two feet are on the ground
)
@property
def overlap_ticks(self):
return int(self.overlap_time / self.dt)
@property
def swing_ticks(self):
return int(self.swing_time / self.dt)
@property
def stance_ticks(self):
return 2 * self.overlap_ticks + self.swing_ticks
@property
def phase_times(self):
return np.array(
[self.overlap_ticks, self.swing_ticks, self.overlap_ticks, self.swing_ticks]
)
@property
def phase_length(self):
return 2 * self.overlap_ticks + 2 * self.swing_ticks
class RobotConfig:
"""Woofer hardware parameters
"""
def __init__(self):
# Robot geometry
self.LEG_FB = 0.23 # front-back distance from center line to leg axis
self.LEG_LR = 0.109 # left-right distance from center line to leg plane
self.ABDUCTION_OFFSET = 0.064 # distance from abduction axis to leg
self.FOOT_RADIUS = 0.02
self.UPPER_LEG = 0.18
self.LOWER_LEG = 0.32
# Update hip geometry
self.HIP_L = 0.0394
self.HIP_W = 0.0744
self.HIP_T = 0.0214
self.HIP_OFFSET = 0.0132
self.L = 0.66
self.W = 0.176
self.T = 0.092
self.LEG_ORIGINS = np.array(
[
[self.LEG_FB, self.LEG_FB, -self.LEG_FB, -self.LEG_FB],
[-self.LEG_LR, self.LEG_LR, -self.LEG_LR, self.LEG_LR],
[0, 0, 0, 0],
]
)
self.ABDUCTION_OFFSETS = np.array(
[
-self.ABDUCTION_OFFSET,
self.ABDUCTION_OFFSET,
-self.ABDUCTION_OFFSET,
self.ABDUCTION_OFFSET,
]
)
self.START_HEIGHT = 0.3
# Robot inertia params
self.FRAME_MASS = 3.0 # kg
self.MODULE_MASS = 1.033 # kg
self.LEG_MASS = 0.15 # kg
self.MASS = self.FRAME_MASS + (self.MODULE_MASS + self.LEG_MASS) * 4
# Compensation factor of 3 because the inertia measurement was just
# of the carbon fiber and plastic parts of the frame and did not
# include the hip servos and electronics
self.FRAME_INERTIA = tuple(
map(lambda x: 3.0 * x, (1.844e-4, 1.254e-3, 1.337e-3))
)
self.MODULE_INERTIA = (3.698e-5, 7.127e-6, 4.075e-5)
leg_z = 1e-6
leg_mass = 0.010
leg_x = 1 / 12 * self.LOWER_LEG ** 2 * leg_mass
leg_y = leg_x
self.LEG_INERTIA = (leg_x, leg_y, leg_z)
# Joint params
G = 220 # Servo gear ratio
m_rotor = 0.016 # Servo rotor mass
r_rotor = 0.005 # Rotor radius
self.ARMATURE = G ** 2 * m_rotor * r_rotor ** 2 # Inertia of rotational joints
# print("Servo armature", self.ARMATURE)
NATURAL_DAMPING = 1.0 # Damping resulting from friction
ELECTRICAL_DAMPING = 0.049 # Damping resulting from back-EMF
self.REV_DAMPING = (
NATURAL_DAMPING + ELECTRICAL_DAMPING
) # Damping torque on the revolute joints
# Force limits
self.MAX_JOINT_TORQUE = 12.0
self.REVOLUTE_RANGE = 3
self.NUM_ODRIVES = 6
self.ENCODER_CPR = 2000
self.MOTOR_REDUCTION = 4
class EnvironmentConfig:
"""Environmental parameters
"""
def __init__(self):
self.MU = 1.5 # coeff friction
self.DT = 0.001 # seconds between simulation steps
class SolverConfig:
"""MuJoCo solver parameters
"""
def __init__(self):
self.JOINT_SOLREF = "0.001 1" # time constant and damping ratio for joints
self.JOINT_SOLIMP = "0.9 0.95 0.001" # joint constraint parameters
self.GEOM_SOLREF = "0.01 1" # time constant and damping ratio for geom contacts
self.GEOM_SOLIMP = "0.9 0.95 0.001" # geometry contact parameters
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/CMakeLists.txt |
cmake_minimum_required(VERSION 2.8.3)
project(mini-pupper_description)
find_package(catkin REQUIRED COMPONENTS)
catkin_package()
install(DIRECTORY meshes launch urdf rviz
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/package.xml | <?xml version="1.0"?>
<package format="2">
<name>mini-pupper_description</name>
<version>0.1.0</version>
<description>Mini-Pupper Description Package</description>
<maintainer email="[email protected]">nisshan.x</maintainer>
<author>nisshan</author>
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<exec_depend>roslaunch</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>urdf</exec_depend>
<exec_depend>xacro</exec_depend>
<exec_depend>rviz</exec_depend>
<exec_depend>gazebo_plugins</exec_depend>
<exec_depend>hector_gazebo_plugins</exec_depend>
<exec_depend>hector_sensors_description</exec_depend>
<exec_depend>velodyne_gazebo_plugins</exec_depend>
<exec_depend>realsense2_description</exec_depend>
</package> |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/README.md | # Mini Pupper Robot Description (URDF)
## Overview
This package contains a simplified robot description (URDF) of the [Mini Pupper](https://www.kickstarter.com/projects/336477435/mini-pupper-open-sourceros-robot-dog-kit) developed by [MangDang](https://twitter.com/LeggedRobot).
STL filesare forked from [mayataka/mini_pupper_trajopt](https://github.com/mayataka/mini_pupper_trajopt).
## License
This software is released under a [BSD 3-Clause license](LICENSE).
## Usage
See [CHAMP](https://github.com/chvmp/champ)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/launch/view_urdf.launch | <launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mini-pupper_description)/urdf/mini-pupper.urdf.xacro' " />
<node name="mini_pupper_robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
<param name="publish_frequency" type="double" value="30.0" />
<param name="ignore_timestamp" type="bool" value="true" />
</node>
<node type="rviz" name="rviz" pkg="rviz" args="-d $(find mini-pupper_description)/rviz/urdf_viewer.rviz" />
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="/use_gui" value="false"/>
<rosparam param="/source_list">[mini-pupper/joint_states]</rosparam>
</node>
</launch>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/launch/description.launch | <launch>
<arg name="description_name" default="robot_description"/>
<arg name="description_file" default="$(find mini-pupper_description)/urdf/mini-pupper.urdf"/>
<param name="$(arg description_name)" textfile="$(arg description_file)"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
<param name="use_tf_static" value="false"/>
<param name="publish_frequency" value="200"/>
<param name="ignore_timestamp" value="true"/>
<remap from="robot_description" to="$(arg description_name)"/>
</node>
<!-- debug -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find mini-pupper_description)/rviz/urdf_viewer.rviz"/>
</launch> |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/rviz/urdf_viewer.rviz | Panels:
- Class: rviz/Displays
Help Height: 78
Name: Displays
Property Tree Widget:
Expanded:
- /Grid1
- /TF1/Frames1
Splitter Ratio: 0.38333332538604736
Tree Height: 845
- Class: rviz/Selection
Name: Selection
- Class: rviz/Tool Properties
Expanded:
- /2D Pose Estimate1
- /2D Nav Goal1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Preferences:
PromptSaveOnExit: true
Toolbars:
toolButtonStyle: 2
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 1000
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Class: rviz/RobotModel
Collision Enabled: false
Enabled: true
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
base_inertia:
Alpha: 1
Show Axes: false
Show Trail: false
base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
camera_depth_frame:
Alpha: 1
Show Axes: false
Show Trail: false
camera_depth_optical_frame:
Alpha: 1
Show Axes: false
Show Trail: false
camera_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
camera_rgb_frame:
Alpha: 1
Show Axes: false
Show Trail: false
camera_rgb_optical_frame:
Alpha: 1
Show Axes: false
Show Trail: false
hokuyo_frame:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
imu_link:
Alpha: 1
Show Axes: false
Show Trail: false
lf_foot_link:
Alpha: 1
Show Axes: false
Show Trail: false
lf_hip_debug_link:
Alpha: 1
Show Axes: false
Show Trail: false
lf_hip_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
lf_lower_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
lf_upper_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
lh_foot_link:
Alpha: 1
Show Axes: false
Show Trail: false
lh_hip_debug_link:
Alpha: 1
Show Axes: false
Show Trail: false
lh_hip_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
lh_lower_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
lh_upper_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rf_foot_link:
Alpha: 1
Show Axes: false
Show Trail: false
rf_hip_debug_link:
Alpha: 1
Show Axes: false
Show Trail: false
rf_hip_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rf_lower_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rf_upper_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rh_foot_link:
Alpha: 1
Show Axes: false
Show Trail: false
rh_hip_debug_link:
Alpha: 1
Show Axes: false
Show Trail: false
rh_hip_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rh_lower_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
rh_upper_leg_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
Name: RobotModel
Robot Description: robot_description
TF Prefix: ""
Update Interval: 0
Value: true
Visual Enabled: true
- Class: rviz/Axes
Enabled: true
Length: 1
Name: Axes
Radius: 0.005
Reference Frame: <Fixed Frame>
Value: true
- Class: rviz/TF
Enabled: true
Frame Timeout: 15
Frames:
All Enabled: false
base_footprint:
Value: true
base_inertia:
Value: true
base_link:
Value: true
camera_depth_frame:
Value: true
camera_depth_optical_frame:
Value: true
camera_link:
Value: true
camera_rgb_frame:
Value: true
camera_rgb_optical_frame:
Value: true
hokuyo_frame:
Value: true
imu_link:
Value: true
lf_foot_link:
Value: true
lf_hip_debug_link:
Value: true
lf_hip_link:
Value: true
lf_lower_leg_link:
Value: true
lf_upper_leg_link:
Value: true
lh_foot_link:
Value: true
lh_hip_debug_link:
Value: true
lh_hip_link:
Value: true
lh_lower_leg_link:
Value: true
lh_upper_leg_link:
Value: true
odom:
Value: true
rf_foot_link:
Value: true
rf_hip_debug_link:
Value: true
rf_hip_link:
Value: true
rf_lower_leg_link:
Value: true
rf_upper_leg_link:
Value: true
rh_foot_link:
Value: true
rh_hip_debug_link:
Value: true
rh_hip_link:
Value: true
rh_lower_leg_link:
Value: true
rh_upper_leg_link:
Value: true
Marker Scale: 0.25
Name: TF
Show Arrows: true
Show Axes: false
Show Names: false
Tree:
odom:
base_footprint:
base_link:
base_inertia:
{}
camera_link:
camera_depth_frame:
camera_depth_optical_frame:
{}
camera_rgb_frame:
camera_rgb_optical_frame:
{}
hokuyo_frame:
{}
imu_link:
{}
lf_hip_debug_link:
{}
lf_hip_link:
lf_upper_leg_link:
lf_lower_leg_link:
lf_foot_link:
{}
lh_hip_debug_link:
{}
lh_hip_link:
lh_upper_leg_link:
lh_lower_leg_link:
lh_foot_link:
{}
rf_hip_debug_link:
{}
rf_hip_link:
rf_upper_leg_link:
rf_lower_leg_link:
rf_foot_link:
{}
rh_hip_debug_link:
{}
rh_hip_link:
rh_upper_leg_link:
rh_lower_leg_link:
rh_foot_link:
{}
Update Interval: 0
Value: true
- Class: rviz/MarkerArray
Enabled: false
Marker Topic: foot
Name: MarkerArray
Namespaces:
{}
Queue Size: 100
Value: false
- Alpha: 1
Axes Length: 1
Axes Radius: 0.10000000149011612
Class: rviz/Pose
Color: 255; 25; 0
Enabled: true
Head Length: 0.30000001192092896
Head Radius: 0.10000000149011612
Name: Pose
Shaft Length: 1
Shaft Radius: 0.05000000074505806
Shape: Arrow
Topic: /pose_debug
Unreliable: false
Value: true
Enabled: true
Global Options:
Background Color: 238; 238; 236
Default Light: true
Fixed Frame: /odom
Frame Rate: 30
Name: root
Tools:
- Class: rviz/Interact
Hide Inactive Objects: true
- Class: rviz/MoveCamera
- Class: rviz/Select
- Class: rviz/FocusCamera
- Class: rviz/Measure
- Class: rviz/SetInitialPose
Theta std deviation: 0.2617993950843811
Topic: /initialpose
X std deviation: 0.5
Y std deviation: 0.5
- Class: rviz/SetGoal
Topic: /move_base_simple/goal
- Class: rviz/PublishPoint
Single click: true
Topic: /clicked_point
Value: true
Views:
Current:
Class: rviz/Orbit
Distance: 4.856288433074951
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0.27266740798950195
Y: -0.10151305049657822
Z: 0.08205118030309677
Focal Shape Fixed Size: false
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.29539817571640015
Target Frame: base_footprint
Value: Orbit (rviz)
Yaw: 2.140366792678833
Saved: ~
Window Geometry:
Displays:
collapsed: true
Height: 1143
Hide Left Dock: true
Hide Right Dock: true
QMainWindow State: 000000ff00000000fd00000004000000000000021e000003d8fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073000000003d000003d8000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000003d8fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d000003d8000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000003ab0000003ffc0100000002fb0000000800540069006d00650100000000000003ab000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000003ab000003d800000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: true
Width: 939
X: 981
Y: 27
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/laser.urdf.xacro | <robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:property name="M_PI" value="3.1415926535897931" />
<xacro:macro name="laser" params="*origin update_rate ray_count min_angle max_angle min_range max_range parent">
<link name="laser">
<visual>
<origin xyz="0 0 -0.025" rpy="0 0 0"/>
<geometry>
<cylinder radius="0.0375" length="0.05"/>
</geometry>
<!-- <material name="green">
<color rgba="0.003 0.639 0.223 1.0"/>
</material> -->
<material name="black" />
</visual>
<collision>
<origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
<geometry>
<cylinder radius="0.0375" length="0.05"/>
</geometry>
</collision>
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.1"/>
<inertia ixx="${(2/5) * 0.1 * (0.0375 * 0.0375)}" ixy="0" ixz="0"
iyy="${(2/5) * 0.1 * (0.0375 * 0.0375)}" iyz="0"
izz="${(2/5) * 0.1 * (0.0375 * 0.0375)}" />
</inertial>
</link>
<gazebo reference="laser">
<visual>
<material>
<ambient>0.003 0.639 0.223 1.0</ambient>
<diffuse>0.003 0.639 0.223 1.0</diffuse>
<specular>0.003 0.639 0.223 1.0</specular>
<emissive>0.0 0.0 0.0 0.0</emissive>
</material>
</visual>
</gazebo>
<joint name="laser_to_base_link" type="fixed">
<!-- <parent link="base_link"/> -->
<parent link="${parent}"/>
<child link="laser"/>
<xacro:insert_block name="origin" />
</joint>
<gazebo reference="laser">
<sensor type="ray" name="head_hokuyo_sensor">
<always_on>true</always_on>
<update_rate>${update_rate}</update_rate>
<pose>0 0 0 0 0 0</pose>
<visualize>false</visualize>
<ray>
<scan>
<horizontal>
<samples>${ray_count}</samples>
<resolution>1</resolution>
<min_angle>${min_angle}</min_angle>
<max_angle>${max_angle}</max_angle>
</horizontal>
</scan>
<range>
<min>${min_range}</min>
<max>${max_range}</max>
<resolution>0.01</resolution>
</range>
</ray>
<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_ray_sensor.so">
<ros>
<argument>~/out:=scan</argument>
</ros>
<output_type>sensor_msgs/LaserScan</output_type>
<alwaysOn>true</alwaysOn>
<updateRate>${update_rate}</updateRate>
<topicName>scan</topicName>
<frame_name>laser</frame_name>
<output_type>sensor_msgs/LaserScan</output_type>
</plugin>
</sensor>
</gazebo>
</xacro:macro>
</robot> |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/leg.urdf.xacro | <?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:macro name="mini-pupper_leg" params="leg " >
<xacro:if value="${leg == 'lf'}">
<xacro:property name="base_to_hip_xyz" value="${base_to_hip_f_x} ${base_to_hip_y} ${base_to_hip_z}" />
<xacro:property name="hip_to_upper_leg" value="${hip_to_upper_leg_distance}" />
<xacro:property name="upper_leg_to_lower_leg" value="${upper_leg_to_lower_leg_distance}" />
<xacro:property name="hip_mesh_path" value="package://mini-pupper_description/meshes/${leg}_hip.stl" />
<xacro:property name="upper_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
<xacro:property name="lower_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
</xacro:if>
<xacro:if value="${leg == 'lh'}">
<xacro:property name="base_to_hip_xyz" value="-${base_to_hip_h_x} ${base_to_hip_y} ${base_to_hip_z}" />
<xacro:property name="hip_to_upper_leg" value="${hip_to_upper_leg_distance}" />
<xacro:property name="upper_leg_to_lower_leg" value="${upper_leg_to_lower_leg_distance}" />
<xacro:property name="hip_mesh_path" value="package://mini-pupper_description/meshes/${leg}_hip.stl" />
<xacro:property name="upper_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
<xacro:property name="lower_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
</xacro:if>
<xacro:if value="${leg == 'rf'}">
<xacro:property name="base_to_hip_xyz" value="${base_to_hip_f_x} -${base_to_hip_y} ${base_to_hip_z}" />
<xacro:property name="hip_to_upper_leg" value="-${hip_to_upper_leg_distance}" />
<xacro:property name="upper_leg_to_lower_leg" value="-${upper_leg_to_lower_leg_distance}" />
<xacro:property name="hip_mesh_path" value="package://mini-pupper_description/meshes/${leg}_hip.stl" />
<xacro:property name="upper_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
<xacro:property name="lower_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
</xacro:if>
<xacro:if value="${leg == 'rh'}">
<xacro:property name="base_to_hip_xyz" value="-${base_to_hip_h_x} -${base_to_hip_y} ${base_to_hip_z}" />
<xacro:property name="hip_to_upper_leg" value="-${hip_to_upper_leg_distance}" />
<xacro:property name="upper_leg_to_lower_leg" value="-${upper_leg_to_lower_leg_distance}" />
<xacro:property name="hip_mesh_path" value="package://mini-pupper_description/meshes/${leg}_hip.stl" />
<xacro:property name="upper_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
<xacro:property name="lower_leg_mesh_path" value="package://mini-pupper_description/meshes/${leg}_lower_leg.stl" />
</xacro:if>
<link name="${leg}_hip_debug_link"/>
<link name="${leg}_hip_link">
<inertial>
<mass value="${hip_mass}" />
<inertia ixx="${(1/12) * hip_mass * (hip_y_length * hip_y_length + hip_z_length * hip_z_length)}" ixy="0.0" ixz="0.0"
iyy="${(1/12) * hip_mass * (hip_x_length * hip_x_length + hip_z_length * hip_z_length)}" iyz="0.0"
izz="${(1/12) * hip_mass * (hip_x_length * hip_x_length + hip_y_length * hip_y_length)}" />
</inertial>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${hip_mesh_path}" scale="1 1 1" />
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${hip_mesh_path}" scale="1 1 1" />
</geometry>
<material name="dyellow" />
</visual>
</link>
<gazebo reference="${leg}_hip_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="${leg}_upper_leg_link">
<inertial>
<origin xyz="0 0 -${(upper_leg_z_length / 2) - ((upper_leg_z_length - upper_leg_to_lower_leg_distance) / 2)}" />
<mass value="${upper_leg_mass}" />
<inertia ixx="${(1/12) * upper_leg_mass * (upper_leg_y_length * upper_leg_y_length + upper_leg_z_length * upper_leg_z_length)}" ixy="0.0" ixz="0.0"
iyy="${(1/12) * upper_leg_mass * (upper_leg_x_length * upper_leg_x_length + upper_leg_z_length * upper_leg_z_length)}" iyz="0.0"
izz="${(1/12) * upper_leg_mass * (upper_leg_x_length * upper_leg_x_length + upper_leg_y_length * upper_leg_y_length)}" />
</inertial>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${upper_leg_mesh_path}" scale="1 1 1" />
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${upper_leg_mesh_path}" scale="1 1 1" />
</geometry>
<material name="dyellow" />
</visual>
</link>
<gazebo reference="${leg}_upper_leg_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="${leg}_lower_leg_link">
<inertial>
<origin xyz="0 0 -${(lower_leg_to_foot_distance - (lower_leg_z_length - lower_leg_to_foot_distance)) / 2}" />
<mass value="${lower_leg_mass}" />
<inertia ixx="${(1/12) * lower_leg_mass * (lower_leg_y_length * lower_leg_y_length + lower_leg_z_length * lower_leg_z_length)}" ixy="0.0" ixz="0.0"
iyy="${(1/12) * lower_leg_mass * (lower_leg_x_length * lower_leg_x_length + lower_leg_z_length * lower_leg_z_length)}" iyz="0.0"
izz="${(1/12) * lower_leg_mass * (lower_leg_x_length * lower_leg_x_length + lower_leg_y_length * lower_leg_y_length)}" />
</inertial>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${lower_leg_mesh_path}" scale="1 1 1" />
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${lower_leg_mesh_path}" scale="1 1 1" />
</geometry>
<material name="black" />
</visual>
</link>
<gazebo reference="${leg}_lower_leg_link">
<kp>1000000.0</kp>
<kd>1.0</kd>
<mu1>0.8</mu1>
<mu2>0.8</mu2>
<maxVel>0.0</maxVel>
<minDepth>0.001</minDepth>
<material>Gazebo/FlatBlack</material>
</gazebo>
<link name="${leg}_foot_link">
<inertial>
<origin xyz="0 0 0" />
<mass value="${foot_mass}" />
<inertia ixx="${(1/12) * foot_mass * (foot_y_length * foot_y_length + foot_z_length * foot_z_length)}" ixy="0.0" ixz="0.0"
iyy="${(1/12) * foot_mass * (foot_x_length * foot_x_length + foot_z_length * foot_z_length)}" iyz="0.0"
izz="${(1/12) * foot_mass * (foot_x_length * foot_x_length + foot_y_length * foot_y_length)}" />
</inertial>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${foot_mesh_path}" scale="1 1 1" />
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${foot_mesh_path}" scale="1 1 1" />
</geometry>
<material name="black" />
</visual>
</link>
<gazebo reference="${leg}_foot_link">
<material>Gazebo/FlatBlack</material>
</gazebo>
<joint name="${leg}_debug_joint" type="fixed">
<parent link="base_link" />
<child link="${leg}_hip_debug_link" />
<origin xyz="${base_to_hip_xyz}" rpy="0 0 0" />
</joint>
<joint name="${leg}_hip_joint" type="revolute">
<axis xyz="1 0 0" />
<limit effort="5" lower="-${pi}" upper="${pi}" velocity="2.5" />
<parent link="base_link" />
<child link="${leg}_hip_link" />
<origin xyz="${base_to_hip_xyz}" rpy="0 0 0" />
</joint>
<joint name="${leg}_upper_leg_joint" type="revolute">
<axis xyz="0 1 0" />
<limit effort="5" lower="-${pi}" upper="${pi}" velocity="2.5" />
<parent link="${leg}_hip_link" />
<child link="${leg}_upper_leg_link" />
<origin xyz="0 ${hip_to_upper_leg} 0" rpy="0 0 0" />
</joint>
<joint name="${leg}_lower_leg_joint" type="revolute">
<axis xyz="0 1 0" />
<limit effort="5" lower="-${pi}" upper="${pi}" velocity="2.5" />
<parent link="${leg}_upper_leg_link" />
<child link="${leg}_lower_leg_link" />
<origin xyz="0 ${upper_leg_to_lower_leg} -0.05" rpy="0 0 0" />
</joint>
<joint name="${leg}_foot_joint" type="fixed">
<parent link="${leg}_lower_leg_link" />
<child link="${leg}_foot_link" />
<origin xyz="0 0 -${lower_leg_to_foot_distance}" rpy="0 0 0" />
</joint>
<transmission name="${leg}_hip_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${leg}_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="${leg}_hip_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="${leg}_upper_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${leg}_upper_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="${leg}_upper_leg_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="${leg}_lower_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${leg}_lower_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="${leg}_lower_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
</robot> |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/mini-pupper.urdf | <?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from mini-pupper.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="mini-pupper">
<material name="black">
<color rgba="0.15 0.15 0.15 1.0"/>
</material>
<material name="dyellow">
<color rgba="0.95 0.93 0.13 1.0"/>
</material>
<material name="white">
<color rgba="0.97 0.97 0.97 1.0"/>
</material>
<link name="base_link">
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/base.stl" scale="0.001 0.001 0.001"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/base.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<link name="base_inertia">
<inertial>
<origin xyz="0 0 0"/>
<mass value="1.0"/>
<inertia ixx="0.0008166666666666667" ixy="0.0" ixz="0.0" iyy="0.0036096666666666673" iyz="0.0" izz="0.0036096666666666673"/>
</inertial>
</link>
<joint name="base_link_to_base_inertia" type="fixed">
<parent link="base_link"/>
<child link="base_inertia"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
</joint>
<!--
<link name="face">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0406 0.031086"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="black" />
</visual>
</link>
<joint name="base_link_to_face" type="fixed">
<parent link="base_link"/>
<child link="face"/>
<origin xyz="${base_x_length/2 - 0.0015} 0 0.0225" rpy="0 0 0"/>
</joint>
<link name="eye_l">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0083 0.014"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="white" />
</visual>
</link>
<joint name="face_to_eye_l" type="fixed">
<parent link="face"/>
<child link="eye_l"/>
<origin xyz="0.00005 -0.006 0" rpy="0 0 0"/>
</joint>
<link name="eye_r">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0083 0.014"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="white" />
</visual>
</link>
<joint name="face_to_eye_r" type="fixed">
<parent link="face"/>
<child link="eye_r"/>
<origin xyz="0.00005 0.006 0" rpy="0 0 0"/>
</joint> -->
<gazebo reference="base_link">
<material>Gazebo/ZincYellow</material>
</gazebo>
<!-- <gazebo reference="face">
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="eye_l">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="eye_r">
<material>Gazebo/White</material>
</gazebo> -->
<joint name="hokuyo_joint" type="fixed">
<origin rpy="0 0 0" xyz="-0.05 0.0 0.1"/>
<parent link="base_link"/>
<child link="hokuyo_frame"/>
</joint>
<link name="hokuyo_frame">
<inertial>
<mass value="0.270"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<inertia ixx="2.632e-4" ixy="0" ixz="0" iyy="2.632e-4" iyz="0" izz="1.62e-4"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://hector_sensors_description/meshes/hokuyo_utm30lx/hokuyo_utm_30lx.dae"/>
</geometry>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 -0.0115"/>
<geometry>
<box size="0.058 0.058 0.087"/>
<!--<mesh filename="package://hector_sensors_description/meshes/hokuyo_utm30lx/hokuyo_utm_30lx.stl"/>-->
</geometry>
</collision>
</link>
<gazebo reference="hokuyo_frame">
<sensor name="hokuyo" type="ray">
<always_on>true</always_on>
<update_rate>30</update_rate>
<pose>0 0 0 0 0 0</pose>
<visualize>false</visualize>
<ray>
<scan>
<horizontal>
<samples>1040</samples>
<resolution>1</resolution>
<min_angle>2.2689280275926285</min_angle>
<max_angle>-2.2689280275926285</max_angle>
</horizontal>
</scan>
<range>
<min>0.2</min>
<max>30.0</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.004</stddev>
</noise>
</ray>
<plugin filename="libgazebo_ros_laser.so" name="gazebo_ros_hokuyo_controller">
<topicName>scan</topicName>
<frameName>hokuyo_frame</frameName>
</plugin>
</sensor>
</gazebo>
<joint name="camera_joint" type="fixed">
<origin rpy="0 0 0" xyz="0.098 0.0 0.082"/>
<parent link="base_link"/>
<child link="camera_link"/>
</joint>
<link name="camera_link">
<inertial>
<mass value="0.200"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<inertia ixx="5.8083e-4" ixy="0" ixz="0" iyy="3.0833e-5" iyz="0" izz="5.9083e-4"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://hector_sensors_description/meshes/asus_camera/asus_camera_simple.dae"/>
</geometry>
</visual>
<!--
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<box size="0.035 0.185 0.025"/>
</geometry>
</collision>
-->
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://hector_sensors_description/meshes/asus_camera/asus_camera_simple.dae"/>
</geometry>
</collision>
</link>
<joint name="camera_depth_joint" type="fixed">
<origin rpy="0 0 0" xyz="0.0 0.049 0.0"/>
<parent link="camera_link"/>
<child link="camera_depth_frame"/>
</joint>
<link name="camera_depth_frame"/>
<joint name="camera_depth_optical_joint" type="fixed">
<origin rpy="-1.5707963267948966 0.0 -1.5707963267948966" xyz="0 0 0"/>
<parent link="camera_depth_frame"/>
<child link="camera_depth_optical_frame"/>
</joint>
<link name="camera_depth_optical_frame"/>
<joint name="camera_rgb_joint" type="fixed">
<origin rpy="0 0 0" xyz="0.0 0.022 0.0"/>
<parent link="camera_link"/>
<child link="camera_rgb_frame"/>
</joint>
<link name="camera_rgb_frame"/>
<joint name="camera_rgb_optical_joint" type="fixed">
<origin rpy="-1.5707963267948966 0.0 -1.5707963267948966" xyz="0 0 0"/>
<parent link="camera_rgb_frame"/>
<child link="camera_rgb_optical_frame"/>
</joint>
<link name="camera_rgb_optical_frame"/>
<!-- ASUS Xtion PRO camera for simulation -->
<gazebo reference="camera_depth_frame">
<sensor name="camera" type="depth">
<update_rate>20</update_rate>
<camera>
<horizontal_fov>1.0960667702524387</horizontal_fov>
<image>
<format>R8G8B8</format>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.5</near>
<far>9</far>
</clip>
</camera>
<plugin filename="libgazebo_ros_openni_kinect.so" name="camera_camera_controller">
<imageTopicName>camera/rgb/image_raw</imageTopicName>
<cameraInfoTopicName>camera/rgb/camera_info</cameraInfoTopicName>
<depthImageTopicName>camera/depth/image_raw</depthImageTopicName>
<depthImageCameraInfoTopicName>camera/depth/camera_info</depthImageCameraInfoTopicName>
<pointCloudTopicName>camera/depth/points</pointCloudTopicName>
<frameName>camera_depth_optical_frame</frameName>
</plugin>
</sensor>
</gazebo>
<gazebo>
<plugin filename="libhector_gazebo_ros_imu.so" name="imu_controller">
<updateRate>50.0</updateRate>
<bodyName>imu_link</bodyName>
<topicName>imu/data</topicName>
<accelDrift>0.005 0.005 0.005</accelDrift>
<accelGaussianNoise>0.005 0.005 0.005</accelGaussianNoise>
<rateDrift>0.005 0.005 0.005 </rateDrift>
<rateGaussianNoise>0.005 0.005 0.005 </rateGaussianNoise>
<headingDrift>0.005</headingDrift>
<headingGaussianNoise>0.005</headingGaussianNoise>
</plugin>
</gazebo>
<link name="imu_link">
<inertial>
<mass value="0.001"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<inertia ixx="1e-09" ixy="0.0" ixz="0.0" iyy="1e-09" iyz="0.0" izz="1e-09"/>
</inertial>
</link>
<joint name="imu_joint" type="fixed">
<parent link="base_link"/>
<child link="imu_link"/>
</joint>
<!-- <xacro:include filename="$(find velodyne_description)/urdf/VLP-16.urdf.xacro"/>
<xacro:VLP-16 parent="${base_name}" name="velodyne" topic="velodyne_points" hz="10" samples="1024" gpu="false" lasers="16" max_range="100">
<origin xyz="0 0 ${base_height / 2}" rpy="0 0 0" />
</xacro:VLP-16>
<xacro:include filename="$(find champ_arm_description)/urdf/champ_arm.urdf.xacro" />
<xacro:champ_arm parent="${base_name}">
<origin xyz="0.07 0.0 ${base_height / 2}" rpy="0 0 0"/>
</xacro:champ_arm> -->
<link name="lf_hip_debug_link"/>
<link name="lf_hip_link">
<inertial>
<mass value="0.25"/>
<inertia ixx="7.298104166666667e-05" ixy="0.0" ixz="0.0" iyy="8.328208333333335e-05" iyz="0.0" izz="8.450270833333332e-05"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_hip.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_hip.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="lf_hip_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="lf_upper_leg_link">
<inertial>
<origin xyz="0 0 -0.002375000000000002"/>
<mass value="0.0625"/>
<inertia ixx="3.159338020833334e-05" ixy="0.0" ixz="0.0" iyy="3.7282633854166664e-05" iyz="0.0" izz="7.931013020833332e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="lf_upper_leg_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="lf_lower_leg_link">
<inertial>
<origin xyz="0 0 -0.016780000000000003"/>
<mass value="0.125"/>
<inertia ixx="6.411545416666666e-05" ixy="0.0" ixz="0.0" iyy="6.491712083333332e-05" iyz="0.0" izz="8.485416666666666e-07"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lf_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="lf_lower_leg_link">
<kp>1000000.0</kp>
<kd>1.0</kd>
<mu1>0.8</mu1>
<mu2>0.8</mu2>
<maxVel>0.0</maxVel>
<minDepth>0.001</minDepth>
<material>Gazebo/FlatBlack</material>
</gazebo>
<link name="lf_foot_link">
<inertial>
<origin xyz="0 0 0"/>
<mass value="0.0625"/>
<inertia ixx="2.41921875e-06" ixy="0.0" ixz="0.0" iyy="3.7369270833333336e-06" iyz="0.0" izz="1.6927083333333335e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="lf_foot_link">
<material>Gazebo/FlatBlack</material>
</gazebo>
<joint name="lf_debug_joint" type="fixed">
<parent link="base_link"/>
<child link="lf_hip_debug_link"/>
<origin rpy="0 0 0" xyz="0.06014 0.0235 0.0171"/>
</joint>
<joint name="lf_hip_joint" type="revolute">
<axis xyz="1 0 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="base_link"/>
<child link="lf_hip_link"/>
<origin rpy="0 0 0" xyz="0.06014 0.0235 0.0171"/>
</joint>
<joint name="lf_upper_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="lf_hip_link"/>
<child link="lf_upper_leg_link"/>
<origin rpy="0 0 0" xyz="0 0.0197 0"/>
</joint>
<joint name="lf_lower_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="lf_upper_leg_link"/>
<child link="lf_lower_leg_link"/>
<origin rpy="0 0 0" xyz="0 0.00475 -0.05"/>
</joint>
<joint name="lf_foot_joint" type="fixed">
<parent link="lf_lower_leg_link"/>
<child link="lf_foot_link"/>
<origin rpy="0 0 0" xyz="0 0 -0.056"/>
</joint>
<transmission name="lf_hip_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lf_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lf_hip_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="lf_upper_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lf_upper_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lf_upper_leg_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="lf_lower_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lf_lower_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lf_lower_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<link name="lh_hip_debug_link"/>
<link name="lh_hip_link">
<inertial>
<mass value="0.25"/>
<inertia ixx="7.298104166666667e-05" ixy="0.0" ixz="0.0" iyy="8.328208333333335e-05" iyz="0.0" izz="8.450270833333332e-05"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_hip.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_hip.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="lh_hip_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="lh_upper_leg_link">
<inertial>
<origin xyz="0 0 -0.002375000000000002"/>
<mass value="0.0625"/>
<inertia ixx="3.159338020833334e-05" ixy="0.0" ixz="0.0" iyy="3.7282633854166664e-05" iyz="0.0" izz="7.931013020833332e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="lh_upper_leg_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="lh_lower_leg_link">
<inertial>
<origin xyz="0 0 -0.016780000000000003"/>
<mass value="0.125"/>
<inertia ixx="6.411545416666666e-05" ixy="0.0" ixz="0.0" iyy="6.491712083333332e-05" iyz="0.0" izz="8.485416666666666e-07"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/lh_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="lh_lower_leg_link">
<kp>1000000.0</kp>
<kd>1.0</kd>
<mu1>0.8</mu1>
<mu2>0.8</mu2>
<maxVel>0.0</maxVel>
<minDepth>0.001</minDepth>
<material>Gazebo/FlatBlack</material>
</gazebo>
<link name="lh_foot_link">
<inertial>
<origin xyz="0 0 0"/>
<mass value="0.0625"/>
<inertia ixx="2.41921875e-06" ixy="0.0" ixz="0.0" iyy="3.7369270833333336e-06" iyz="0.0" izz="1.6927083333333335e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="lh_foot_link">
<material>Gazebo/FlatBlack</material>
</gazebo>
<joint name="lh_debug_joint" type="fixed">
<parent link="base_link"/>
<child link="lh_hip_debug_link"/>
<origin rpy="0 0 0" xyz="-0.05886 0.0235 0.0171"/>
</joint>
<joint name="lh_hip_joint" type="revolute">
<axis xyz="1 0 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="base_link"/>
<child link="lh_hip_link"/>
<origin rpy="0 0 0" xyz="-0.05886 0.0235 0.0171"/>
</joint>
<joint name="lh_upper_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="lh_hip_link"/>
<child link="lh_upper_leg_link"/>
<origin rpy="0 0 0" xyz="0 0.0197 0"/>
</joint>
<joint name="lh_lower_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="lh_upper_leg_link"/>
<child link="lh_lower_leg_link"/>
<origin rpy="0 0 0" xyz="0 0.00475 -0.05"/>
</joint>
<joint name="lh_foot_joint" type="fixed">
<parent link="lh_lower_leg_link"/>
<child link="lh_foot_link"/>
<origin rpy="0 0 0" xyz="0 0 -0.056"/>
</joint>
<transmission name="lh_hip_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lh_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lh_hip_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="lh_upper_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lh_upper_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lh_upper_leg_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="lh_lower_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="lh_lower_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="lh_lower_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<link name="rf_hip_debug_link"/>
<link name="rf_hip_link">
<inertial>
<mass value="0.25"/>
<inertia ixx="7.298104166666667e-05" ixy="0.0" ixz="0.0" iyy="8.328208333333335e-05" iyz="0.0" izz="8.450270833333332e-05"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_hip.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_hip.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="rf_hip_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="rf_upper_leg_link">
<inertial>
<origin xyz="0 0 -0.002375000000000002"/>
<mass value="0.0625"/>
<inertia ixx="3.159338020833334e-05" ixy="0.0" ixz="0.0" iyy="3.7282633854166664e-05" iyz="0.0" izz="7.931013020833332e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="rf_upper_leg_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="rf_lower_leg_link">
<inertial>
<origin xyz="0 0 -0.016780000000000003"/>
<mass value="0.125"/>
<inertia ixx="6.411545416666666e-05" ixy="0.0" ixz="0.0" iyy="6.491712083333332e-05" iyz="0.0" izz="8.485416666666666e-07"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rf_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="rf_lower_leg_link">
<kp>1000000.0</kp>
<kd>1.0</kd>
<mu1>0.8</mu1>
<mu2>0.8</mu2>
<maxVel>0.0</maxVel>
<minDepth>0.001</minDepth>
<material>Gazebo/FlatBlack</material>
</gazebo>
<link name="rf_foot_link">
<inertial>
<origin xyz="0 0 0"/>
<mass value="0.0625"/>
<inertia ixx="2.41921875e-06" ixy="0.0" ixz="0.0" iyy="3.7369270833333336e-06" iyz="0.0" izz="1.6927083333333335e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="rf_foot_link">
<material>Gazebo/FlatBlack</material>
</gazebo>
<joint name="rf_debug_joint" type="fixed">
<parent link="base_link"/>
<child link="rf_hip_debug_link"/>
<origin rpy="0 0 0" xyz="0.06014 -0.0235 0.0171"/>
</joint>
<joint name="rf_hip_joint" type="revolute">
<axis xyz="1 0 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="base_link"/>
<child link="rf_hip_link"/>
<origin rpy="0 0 0" xyz="0.06014 -0.0235 0.0171"/>
</joint>
<joint name="rf_upper_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="rf_hip_link"/>
<child link="rf_upper_leg_link"/>
<origin rpy="0 0 0" xyz="0 -0.0197 0"/>
</joint>
<joint name="rf_lower_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="rf_upper_leg_link"/>
<child link="rf_lower_leg_link"/>
<origin rpy="0 0 0" xyz="0 -0.00475 -0.05"/>
</joint>
<joint name="rf_foot_joint" type="fixed">
<parent link="rf_lower_leg_link"/>
<child link="rf_foot_link"/>
<origin rpy="0 0 0" xyz="0 0 -0.056"/>
</joint>
<transmission name="rf_hip_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rf_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rf_hip_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="rf_upper_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rf_upper_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rf_upper_leg_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="rf_lower_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rf_lower_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rf_lower_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<link name="rh_hip_debug_link"/>
<link name="rh_hip_link">
<inertial>
<mass value="0.25"/>
<inertia ixx="7.298104166666667e-05" ixy="0.0" ixz="0.0" iyy="8.328208333333335e-05" iyz="0.0" izz="8.450270833333332e-05"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_hip.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_hip.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="rh_hip_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="rh_upper_leg_link">
<inertial>
<origin xyz="0 0 -0.002375000000000002"/>
<mass value="0.0625"/>
<inertia ixx="3.159338020833334e-05" ixy="0.0" ixz="0.0" iyy="3.7282633854166664e-05" iyz="0.0" izz="7.931013020833332e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="dyellow"/>
</visual>
</link>
<gazebo reference="rh_upper_leg_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="rh_lower_leg_link">
<inertial>
<origin xyz="0 0 -0.016780000000000003"/>
<mass value="0.125"/>
<inertia ixx="6.411545416666666e-05" ixy="0.0" ixz="0.0" iyy="6.491712083333332e-05" iyz="0.0" izz="8.485416666666666e-07"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_lower_leg.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/rh_lower_leg.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="rh_lower_leg_link">
<kp>1000000.0</kp>
<kd>1.0</kd>
<mu1>0.8</mu1>
<mu2>0.8</mu2>
<maxVel>0.0</maxVel>
<minDepth>0.001</minDepth>
<material>Gazebo/FlatBlack</material>
</gazebo>
<link name="rh_foot_link">
<inertial>
<origin xyz="0 0 0"/>
<mass value="0.0625"/>
<inertia ixx="2.41921875e-06" ixy="0.0" ixz="0.0" iyy="3.7369270833333336e-06" iyz="0.0" izz="1.6927083333333335e-06"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
</collision>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="package://mini-pupper_description/meshes/foot.stl" scale="1 1 1"/>
</geometry>
<material name="black"/>
</visual>
</link>
<gazebo reference="rh_foot_link">
<material>Gazebo/FlatBlack</material>
</gazebo>
<joint name="rh_debug_joint" type="fixed">
<parent link="base_link"/>
<child link="rh_hip_debug_link"/>
<origin rpy="0 0 0" xyz="-0.05886 -0.0235 0.0171"/>
</joint>
<joint name="rh_hip_joint" type="revolute">
<axis xyz="1 0 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="base_link"/>
<child link="rh_hip_link"/>
<origin rpy="0 0 0" xyz="-0.05886 -0.0235 0.0171"/>
</joint>
<joint name="rh_upper_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="rh_hip_link"/>
<child link="rh_upper_leg_link"/>
<origin rpy="0 0 0" xyz="0 -0.0197 0"/>
</joint>
<joint name="rh_lower_leg_joint" type="revolute">
<axis xyz="0 1 0"/>
<limit effort="5" lower="-3.141592653589793" upper="3.141592653589793" velocity="2.5"/>
<parent link="rh_upper_leg_link"/>
<child link="rh_lower_leg_link"/>
<origin rpy="0 0 0" xyz="0 -0.00475 -0.05"/>
</joint>
<joint name="rh_foot_joint" type="fixed">
<parent link="rh_lower_leg_link"/>
<child link="rh_foot_link"/>
<origin rpy="0 0 0" xyz="0 0 -0.056"/>
</joint>
<transmission name="rh_hip_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rh_hip_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rh_hip_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="rh_upper_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rh_upper_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rh_upper_leg_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="rh_lower_leg_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="rh_lower_leg_joint">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="rh_lower_joint_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<gazebo>
<plugin filename="libgazebo_ros_p3d.so" name="p3d_base_controller">
<alwaysOn>true</alwaysOn>
<updateRate>10.0</updateRate>
<bodyName>base_link</bodyName>
<topicName>odom/ground_truth</topicName>
<gaussianNoise>0.01</gaussianNoise>
<frameName>world</frameName>
<xyzOffsets>0 0 0</xyzOffsets>
<rpyOffsets>0 0 0</rpyOffsets>
</plugin>
</gazebo>
<gazebo>
<plugin filename="libgazebo_ros_control.so" name="gazebo_ros_control">
<legacyModeNS>true</legacyModeNS>
</plugin>
</gazebo>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/ld06.urdf.xacro | <?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:macro name="ld06" params="*origin parent">
<xacro:include filename="$(find mini-pupper_description)/urdf/laser.urdf.xacro" />
<xacro:laser
parent="${parent}"
update_rate="10"
ray_count="360"
min_angle="-3.1416"
max_angle="3.1416"
min_range="0.08"
max_range="12.0"
>
<xacro:insert_block name="origin" />
</xacro:laser>
</xacro:macro>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/accessories.urdf.xacro | <?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:macro name="accessories" params="base_name base_length base_height " >
<xacro:include filename="$(find hector_sensors_description)/urdf/hokuyo_utm30lx.urdf.xacro" />
<xacro:include filename="$(find hector_sensors_description)/urdf/asus_camera.urdf.xacro" />
<xacro:hokuyo_utm30lx
name="hokuyo"
parent="${base_name}"
ros_topic="scan"
update_rate="30"
ray_count="1040"
min_angle="130"
max_angle="-130" >
<origin xyz="-0.05 0.0 ${base_height + 0.03}" rpy="0 0 0"/>
</xacro:hokuyo_utm30lx>
<xacro:asus_camera
parent="${base_name}"
name="camera">
<origin xyz="${base_length / 2} 0.0 ${base_height + 0.012}" rpy="0 0 0"/>
</xacro:asus_camera>
<gazebo>
<plugin name="imu_controller" filename="libhector_gazebo_ros_imu.so">
<updateRate>50.0</updateRate>
<bodyName>imu_link</bodyName>
<topicName>imu/data</topicName>
<accelDrift>0.005 0.005 0.005</accelDrift>
<accelGaussianNoise>0.005 0.005 0.005</accelGaussianNoise>
<rateDrift>0.005 0.005 0.005 </rateDrift>
<rateGaussianNoise>0.005 0.005 0.005 </rateGaussianNoise>
<headingDrift>0.005</headingDrift>
<headingGaussianNoise>0.005</headingGaussianNoise>
</plugin>
</gazebo>
<link name="imu_link">
<inertial>
<mass value="0.001"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
<inertia ixx="1e-09" ixy="0.0" ixz="0.0" iyy="1e-09" iyz="0.0" izz="1e-09"/>
</inertial>
</link>
<joint name="imu_joint" type="fixed">
<parent link="${base_name}" />
<child link="imu_link" />
</joint>
<!-- <xacro:include filename="$(find velodyne_description)/urdf/VLP-16.urdf.xacro"/>
<xacro:VLP-16 parent="${base_name}" name="velodyne" topic="velodyne_points" hz="10" samples="1024" gpu="false" lasers="16" max_range="100">
<origin xyz="0 0 ${base_height / 2}" rpy="0 0 0" />
</xacro:VLP-16>
<xacro:include filename="$(find champ_arm_description)/urdf/champ_arm.urdf.xacro" />
<xacro:champ_arm parent="${base_name}">
<origin xyz="0.07 0.0 ${base_height / 2}" rpy="0 0 0"/>
</xacro:champ_arm> -->
</xacro:macro>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/mini-pupper.urdf.xacro | <?xml version="1.0"?>
<robot name="mini-pupper" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(find mini-pupper_description)/urdf/properties.urdf.xacro" />
<material name="black"><color rgba="0.15 0.15 0.15 1.0" /></material>
<material name="dyellow"><color rgba="0.95 0.93 0.13 1.0" /></material>
<material name="white"><color rgba="0.97 0.97 0.97 1.0" /></material>
<link name="base_link">
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="${base_mesh_path}" scale="0.001 0.001 0.001" />
</geometry>
</collision>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://mini-pupper_description/meshes/base.stl" scale="1 1 1" />
</geometry>
<material name="dyellow" />
</visual>
</link>
<link name="base_inertia">
<inertial>
<origin xyz="0 0 0" />
<mass value="${base_mass}" />
<inertia ixx="${(1/12) * base_mass * (base_y_length * base_y_length + base_z_length * base_z_length)}" ixy="0.0" ixz="0.0"
iyy="${(1/12) * base_mass * (base_x_length * base_x_length + base_z_length * base_z_length)}" iyz="0.0"
izz="${(1/12) * base_mass * (base_x_length * base_x_length + base_y_length * base_y_length)}" />
</inertial>
</link>
<joint name="base_link_to_base_inertia" type="fixed">
<parent link="base_link"/>
<child link="base_inertia"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
</joint>
<!--
<link name="face">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0406 0.031086"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="black" />
</visual>
</link>
<joint name="base_link_to_face" type="fixed">
<parent link="base_link"/>
<child link="face"/>
<origin xyz="${base_x_length/2 - 0.0015} 0 0.0225" rpy="0 0 0"/>
</joint>
<link name="eye_l">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0083 0.014"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="white" />
</visual>
</link>
<joint name="face_to_eye_l" type="fixed">
<parent link="face"/>
<child link="eye_l"/>
<origin xyz="0.00005 -0.006 0" rpy="0 0 0"/>
</joint>
<link name="eye_r">
<inertial>
<origin xyz="0 0 0" />
<mass value="0.0" />
<inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0" />
</inertial>
<visual>
<geometry>
<box size="0.005 0.0083 0.014"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="white" />
</visual>
</link>
<joint name="face_to_eye_r" type="fixed">
<parent link="face"/>
<child link="eye_r"/>
<origin xyz="0.00005 0.006 0" rpy="0 0 0"/>
</joint> -->
<gazebo reference="base_link">
<material>Gazebo/ZincYellow</material>
</gazebo>
<!-- <gazebo reference="face">
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="eye_l">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="eye_r">
<material>Gazebo/White</material>
</gazebo> -->
<xacro:include filename="$(find mini-pupper_description)/urdf/leg.urdf.xacro" />
<xacro:include filename="$(find mini-pupper_description)/urdf/accessories.urdf.xacro" />
<xacro:accessories
base_name="base_link"
base_length="${base_x_length}"
base_height="${base_z_length}"
/>
<xacro:mini-pupper_leg leg="lf"/>
<xacro:mini-pupper_leg leg="lh"/>
<xacro:mini-pupper_leg leg="rf"/>
<xacro:mini-pupper_leg leg="rh"/>
<gazebo>
<plugin name="p3d_base_controller" filename="libgazebo_ros_p3d.so">
<alwaysOn>true</alwaysOn>
<updateRate>10.0</updateRate>
<bodyName>base_link</bodyName>
<topicName>odom/ground_truth</topicName>
<gaussianNoise>0.01</gaussianNoise>
<frameName>world</frameName>
<xyzOffsets>0 0 0</xyzOffsets>
<rpyOffsets>0 0 0</rpyOffsets>
</plugin>
</gazebo>
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<legacyModeNS>true</legacyModeNS>
</plugin>
</gazebo>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/properties.urdf.xacro | <?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:property name="base_to_hip_f_x" value="0.06014" />
<xacro:property name="base_to_hip_h_x" value="0.05886" />
<xacro:property name="base_to_hip_y" value="0.0235" />
<xacro:property name="base_to_hip_z" value="0.0171" />
<xacro:property name="hip_to_upper_leg_distance" value="0.0197" />
<xacro:property name="upper_leg_to_lower_leg_distance" value="0.00475" />
<xacro:property name="lower_leg_to_foot_distance" value="0.056" />
<xacro:property name="hip_mass" value="0.250" />
<xacro:property name="hip_x_length" value="0.0477" />
<xacro:property name="hip_y_length" value="0.0422" />
<xacro:property name="hip_z_length" value="0.0415" />
<xacro:property name="upper_leg_mass" value="0.0625" />
<xacro:property name="upper_leg_x_length" value="0.03616" />
<xacro:property name="upper_leg_y_length" value="0.01467" />
<xacro:property name="upper_leg_z_length" value="0.07649" />
<xacro:property name="lower_leg_mass" value="0.125" />
<xacro:property name="lower_leg_x_length" value="0.0089" />
<xacro:property name="lower_leg_y_length" value="0.0015" />
<xacro:property name="lower_leg_z_length" value="0.07844" />
<xacro:property name="base_mesh_path" value="package://mini-pupper_description/meshes/base.stl" />
<xacro:property name="base_mass" value="1.0" />
<!-- <xacro:property name="base_mass" value="2.0" /> -->
<xacro:property name="base_x_length" value="0.196" />
<xacro:property name="base_y_length" value="0.07" />
<xacro:property name="base_z_length" value="0.07" />
<xacro:property name="foot_mesh_path" value="package://mini-pupper_description/meshes/foot.stl" />
<xacro:property name="foot_mass" value="0.0625" />
<xacro:property name="foot_x_length" value="0.017" />
<xacro:property name="foot_y_length" value="0.006" />
<xacro:property name="foot_z_length" value="0.0207" />
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/mini_pupper_simplified/urdf/accessories_another.urdf.xacro | <?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:macro name="accessories" params="base_name base_length base_height " >
<xacro:include filename="$(find mini-pupper_description)/urdf/ld06.urdf.xacro" />
<xacro:include filename="$(find realsense2_description)/urdf/_d435i.urdf.xacro" />
<xacro:ld06
parent="${base_name}" >
<origin xyz="-0.05 0.0 ${base_height / 2 + 0.060}" rpy="0 0 0"/>
</xacro:ld06>
<xacro:sensor_d435i
parent="${base_name}"
name="camera">
<origin xyz="${base_length / 2 + 0.01} 0.0 ${base_height - 0.025}" rpy="0 0 0"/>
</xacro:sensor_d435i>
<gazebo>
<plugin name="imu_controller" filename="libhector_gazebo_ros_imu.so">
<updateRate>50.0</updateRate>
<bodyName>imu_link</bodyName>
<topicName>imu/data</topicName>
<accelDrift>0.005 0.005 0.005</accelDrift>
<accelGaussianNoise>0.005 0.005 0.005</accelGaussianNoise>
<rateDrift>0.005 0.005 0.005 </rateDrift>
<rateGaussianNoise>0.005 0.005 0.005 </rateGaussianNoise>
<headingDrift>0.005</headingDrift>
<headingGaussianNoise>0.005</headingGaussianNoise>
</plugin>
</gazebo>
<link name="imu_link">
<inertial>
<mass value="0.001"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
<inertia ixx="1e-09" ixy="0.0" ixz="0.0" iyy="1e-09" iyz="0.0" izz="1e-09"/>
</inertial>
</link>
<joint name="imu_joint" type="fixed">
<parent link="${base_name}" />
<child link="imu_link" />
</joint>
<!-- <xacro:include filename="$(find velodyne_description)/urdf/VLP-16.urdf.xacro"/>
<xacro:VLP-16 parent="${base_name}" name="velodyne" topic="velodyne_points" hz="10" samples="1024" gpu="false" lasers="16" max_range="100">
<origin xyz="0 0 ${base_height / 2}" rpy="0 0 0" />
</xacro:VLP-16>
<xacro:include filename="$(find mini-pupper_arm_description)/urdf/mini-pupper_arm.urdf.xacro" />
<xacro:mini-pupper_arm parent="${base_name}">
<origin xyz="0.07 0.0 ${base_height / 2}" rpy="0 0 0"/>
</xacro:mini-pupper_arm> -->
</xacro:macro>
</robot>
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/install.sh | #!/usr/bin/env sh
# Install Mangdang Pupper-Mini
# Overlay dtbo, IO configuration and services
sudo cp Mangdang/PWMController/i2c-pwm-pca9685a.dtbo /boot/firmware/overlays/
sudo cp Mangdang/EEPROM/i2c3.dtbo /boot/firmware/overlays/
sudo cp Mangdang/IO_Configuration/syscfg.txt /boot/firmware/ -f
sudo cp Mangdang/IO_Configuration/config.txt /boot/firmware/ -f
sudo cp Mangdang/stuff/*.mp3 /home/ubuntu/Music/ -f
# Install mangdang power-on service
cd /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/FuelGauge
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/FuelGauge/install.sh
cd /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/System
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/System/install.sh
# Install Mangdang EEPROM
cd /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/EEPROM
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/EEPROM/install.sh
# Install PCA9685 driver
cd /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/PWMController
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/Mangdang/PWMController/install.sh
# Install standford robot and UDPComms services
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/StanfordQuadruped/install.sh
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/UDPComms/install.sh
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/_config.yml | # Google Analytics
google_analytics:G-2V4C4SB10V
theme: jekyll-theme-cayman |
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/README.md | ## Installation
### Flash Ubuntu preinstalled image to the SD card.
* Download `ubuntu-22.04.2-preinstalled-desktop-arm64+raspi.img.xz` from [the official website](https://ubuntu.com/download/raspberry-pi) or
* [MangDang Google drive share link](https://drive.google.com/drive/folders/1qprrK9C3pHTdDHjV_EAo2a8XZseoxD0H)
### Boot Raspberry Pi
```sh
cd ~
sudo apt-get update
sudo apt install git
mkdir Robotics
cd Robotics
git clone https://github.com/mangdangroboticsclub/QuadrupedRobot
cd QuadrupedRobot/Legacy/
sudo bash pre_install.sh
cd ..
sudo bash install.sh
sudo reboot
sudo mv Mangdang/System/restart_joy.service /usr/lib/systemd/system/
sudo mv Mangdang/System/joystart.sh /usr/sbin/
sudo systemctl enable restart_joy
sudo reboot
```
# [Mini Pupper 2](https://www.kickstarter.com/projects/336477435/mini-pupper-2-open-source-ros2-robot-kit-for-dreamers) is already launched on Kickstarter
https://www.kickstarter.com/projects/336477435/mini-pupper-2-open-source-ros2-robot-kit-for-dreamers

# Mini Pupper - ROS, OpenCV, Open-source, Pi Robot Dog
Online channel: [Discord](https://discord.gg/xJdt3dHBVw), [FaceBook](https://www.facebook.com/groups/716473723088464), [Youtube](https://www.youtube.com/channel/UCqHWYGXmnoO7VWHmENje3ug/featured), [Twitter](https://twitter.com/LeggedRobot)
Document: https://minipupperdocs.readthedocs.io/en/latest/index.html
Mini Pupper will make robotics easier for schools, homeschool families, enthusiasts and beyond.
- ROS: support ROS SLAM&Navigation robot dog at low-cost price, endorsed by ROS.
- OpenCV: support OpenCV official OAK-D-Lite 3D camera module, endorsed by OpenCV.
- Open-source: DIY and custom what you want, won a HackadayPrize!
- Raspberry Pi: it’s super expandable, endorsed by Raspberry Pi.

Mini Pupper was showed both on the first page of Kickstarter and Makuake campaign platform, and got many backers!

Mini Pupper had [a wonderful workshop](https://www.youtube.com/watch?v=bUaszjfQXk4) on Amazon 2022 re:MARS event.

Mini Pupper will have [a workshop](https://roscon.ros.org/2022/) on ROSCon 2022 event.

Regarding the Mini Pupper story, you can find more in the interviews with [Katherine Scott@ROS](https://www.youtube.com/watch?v=CP1ytNGgsUE&t=8s) and [Audrow Nash@Sense Think Act Podcast #18](https://www.youtube.com/watch?v=aFBhgRr6pyI&t=139s).



## Background
You maybe see many demos from Boston Dynamics Spot Mini, and so on, many guys want to own their own robot dog to explore the functions, but the price is too high to accept, and it is not easy to explore the robot dog features.
TurtleBot is very convenient for wheeled robot study, but not legged robots. That means, there is no ROS, open-source robot dog platform to study at less than $1,000USD.
Beginning 2020, as Stanford Pupper vendor, we shipped many Stanford Pupper units worldwide. After such global success with Pupper, we took to heart all the feedback from this endeavor. What do our customers want in our products? What kind of products do they like? After more than 11 months pursuing these requests, we would like to show you what we came up with. Mini Pupper!

## Solution and Product
Mini Pupper is the ROS, open-source robot dog platform that supports ROS SLAM, Navigation, and OpenCV AI features with Lidar, camera sensors. It's really a Boston Dynamics Spot Robot Dog in the Palm and legged "TurtleBot" for study at less than $500USD.

Mini Pupper will make robotics easier for schools, homeschool families, enthusiasts, and beyond.


The project is generously supported by [Nathan Kau](https://github.com/stanfordroboticsclub/StanfordQuadruped), a member of [Stanford Student Robotics](https://stanfordstudentrobotics.org/), and [MangDang Technology Co., Limited](https://www.mangdang.net/)
## Design
Our Mini Pupper servo is a custom servo to meet the requirements of our new Pupper! Compact, Durable, Unique. To run the Mini Pupper organically and smoothly, high torque & high-fidelity servos were required. We tested many servos on the market and have not found any 9g servo up to the task. After too many Q.C issues we finally gave up on off-the-shelf hobbyist servos, the last thing we want is for our intelligent customers to be let down by poor quality servos. So, we spent several months optimizing and configuring a servo that would work for our project, including tuning the servo parameters ourselves! It is now named Mini Pupper servo.

## Explore the Gait Performances
You can use our Mini Pupper to explore many gait performances, such as Trot (diagonal pairs), Pace (lateral pairs), and the Bound (front and rear pairs). We’re confident our Mini Pupper Servos will outperform any servo for the balance of performance and price.

## The Mechanical Design
The mechanical design is simple, stable, and beautiful. You can find many prototype quadruped robots, but few can go to market because of their complex design! Difficult to assemble, lack stability while trotting, and require unpredictable costly repairs. For the average engineering student or extremely curious individual these quadrupeds will work, however, they are not suitable for mass production. The Mini Pupper addresses these issues by creating a professional robot designed specifically for mass production, driving unit costs low enough for even low-budget schools to acquire the robots for learning. Driving innovation for the next generation of robotics enthusiasts. Unlike other 3D printed robots, we use metal threaded inserts to ensure customers can disassemble and reassemble easily while making repairs after extensive use. All parts are secured with quality fasteners ensuring great fit and function as well as durability of the unit. Cleaner builds were achieved by customizing the servo cable length and integrating the IMU into our carry board to reduce the wiring necessary and have an overall clean setup in the body of Mini Pupper. No lose wires! Unlike other enthusiast-made kits, our Mini Pupper does not require the user to plug or unplug wires to power the unit on and off. A simple flick of a switch is all you need! The Mini Pupper battery is charged without the need to remove the battery from the robot, onboard voltmeters will sound alarm and warn you that your unit needs energy. Mini Pupper's design was based on the feedback we received from our existing customers. Because of this we now have a quadruped robot easier to set up and play with than any other robot on the market. Customers with minimal or no experience will be able to use this robot.

The Mini Pupper has 12 DOF (degree of freedom), unlike the 8 DOF available through similar projects. There was a lot of debate within our team about whether we should keep with norms and produce the same 8 DOF. After much debate, we concluded 8 DOF robots lack the ability to follow natural biological movements. The benefits of an 8 DOF quadruped only seemed to benefit the producer as the cost of the robot and parts required would be less. But we would have lost the original inspiration of the project… Which was to provide our customers with the highest quality best performing robot in this price range. All the servos are controlled one by one by a PCA9685. The gait performance is dependent on the 12 servos control loop time, requiring more effort to optimize 12 DOF vs 8DOF. There were doubts we could accomplish this with such a low price point. Although it was a challenge, after several months Mini Pupper is the first consumer 12 DOF quadruped robot in the world with a mass production intention.
## The HMI (Human-Machine-Interface)
The HMI (Human-Machine-Interface) LCD is another wonderful function. Taking Mini Pupper from a bunch of screws and motors, an animalistic appearance is given to Mini Pupper. You can communicate with it, you can customize it. Mini Pupper is the first consumer quadruped robot with LCD’s adding animal behaviors to your robot.

## Education Courses
We are targeting Mini Pupper for education. [Education courses](https://minipupperdocs.readthedocs.io/en/latest/) are also coming. To make the study of Mini Pupper easy and convenient, the courses will be released step by step, including mechanical, hardware, ROS, SLAM, navigation, AI functions, and so on. If you’ve been searching for an open-sourced consumer-grade quadruped research robot, Mini Pupper is the best platform for you.
We are inviting 10 professional hackers worldwide to prepare the courses. It will be unlike anything that you've ever seen before.

## How to Work Smart
The main software improvement from Pupper is our FSN (Full Self-Navigation) system, based on Ubuntu&ROS and OpenCV. We are moving forward to the FSN target step by step. The interface is also open, we absolutely welcome people to contribute to the project. If you want to join us and move together with us, please don't hesitate to send us an email!

## How to Build
To get started, check out the pages linked below on part sourcing and assembly.
- BOM list: https://drive.google.com/file/d/18phJat8GdK5Yq5p4K1ZmfY1-nMf1lQw4/view?usp=sharing
- Documents: https://minipupperdocs.readthedocs.io/en/latest/index.html
## How to Purchase
If you purchase the parts yourself one by one, it’ll run you about $800 and more time. However, you can purchase a kit to build the robot from MangDang channel for cheaper and one-stop shopping.
The [Kickstarter](https://www.kickstarter.com/projects/336477435/mini-pupper-open-sourceros-robot-dog-kit),[Indiegogo](https://www.indiegogo.com/projects/mini-pupper-open-source-ros-robot-dog-kit/), [Makuake](https://www.makuake.com/project/mini_pupper/) Crowdfunding Campaigns already closed. You can order by the below channels:
- [Our Website](https://www.mangdang.net/Product)
- [Our Shopify](https://mangdang.myshopify.com/)
- Amazon: [Amazon US](https://www.amazon.com/s?me=A3V5171RNQ5C18&marketplaceID=ATVPDKIKX0DER) , [Amazon Japan](https://www.amazon.co.jp/s?me=A14LOTMOI42BRX&marketplaceID=A1VC38T7YXB528)
- [Robotshop](https://www.robotshop.com/en/mini-pupper.html)
- [Aliexpress](https://www.aliexpress.com/store/911381222?spm=a2g0o.detail.1000007.1.2ed464e6sdYBwy)
- [Taobao](https://item.taobao.com/item.htm?spm=a230r.1.14.6.443b6a738ut6AT&id=669862578963&ns=1&abbucket=11#detail)
## About Stanford Student Robotics
[Stanford Student Robotics](https://stanfordstudentrobotics.org/) is an entirely student-run group dedicated to building cool robots and learning new things. You can find many amazing projects on the website. Mini Pupper project is supported by [Nathan Kau](https://github.com/stanfordroboticsclub/StanfordQuadruped) from Stanford Student Robotics.
## About MangDang Technology Co., Limited
Founded in 2020, [MangDang](https://www.mangdang.net/) specializes in the research, development, and production of robot products that make peoples lives better. Mangdang is headquartered in HongKong, with offices in Beijing/China, Tokyo/Japan. We are a global team with members from many countries and regions such as the United States, Japan, Europe, China and so on.
We are all dreamers, we look forward to connecting talents worldwide and innovating together to perform splendid times!
- For business, you can connect us by mail([email protected]).
- Our online channel: [Discord](https://discord.gg/xJdt3dHBVw), [Youtube](https://www.youtube.com/channel/UCqHWYGXmnoO7VWHmENje3ug/featured), [Twitter](https://twitter.com/LeggedRobot), [FaceBook](https://www.facebook.com/groups/716473723088464)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/install.sh | #!/usr/bin/env sh
#Uses python magic vs realpath so it also works on a mac
FOLDER=$(python3 -c "import os; print(os.path.dirname(os.path.realpath('$0')))")
cd $FOLDER
#The `clean --all` removes the build directory automatically which makes reinstalling new versions possible with the same command.
python3 setup.py clean --all install
# Install rover command
sudo ln -s $FOLDER/rover.py /usr/local/bin/rover
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/rover.py | #!/usr/bin/env python3
import sys
import argparse
import json
import time
import select
import pexpect
import UDPComms
import msgpack
def peek_func(port):
sub = UDPComms.Subscriber(port, timeout = 10)
while 1:
try:
data = sub.recv()
print( json.dumps(data) )
except UDPComms.timeout:
exit()
def poke_func(port, rate):
pub = UDPComms.Publisher(port)
data = None
while 1:
if select.select([sys.stdin], [], [], 0)[0]:
line = sys.stdin.readline()
# detailed behaviour
# reading from file: -ignores empty lines -repeats last line forever
# reading from terminal: -repeats last command
if line.rstrip():
data = line.rstrip()
elif len(line) == 0:
# exit() #uncomment to quit on end of file
pass
else:
continue
if data != None:
pub.send( json.loads(data) )
time.sleep( rate/1000 )
def call_func(command, ssh = True):
child = pexpect.spawn(command)
if ssh:
i = 1
while i == 1:
try:
i = child.expect(['password:',
'Are you sure you want to continue connecting',
'Welcome'], timeout=20)
except pexpect.EOF:
print("Can't connect to device")
exit()
except pexpect.TIMEOUT:
print("Interaction with device failed")
exit()
if i == 1:
child.sendline('yes')
if i == 0:
child.sendline('raspberry')
else:
try:
child.expect('robot:', timeout=1)
child.sendline('hello')
except pexpect.TIMEOUT:
pass
child.interact()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subparser')
peek = subparsers.add_parser("peek")
peek.add_argument('port', help="UDP port to subscribe to", type=int)
poke = subparsers.add_parser("poke")
poke.add_argument('port', help="UDP port to publish the data to", type=int)
poke.add_argument('rate', help="how often to republish (ms)", type=float)
peek = subparsers.add_parser("discover")
commands = ['status', 'log', 'start', 'stop', 'restart', 'enable', 'disable']
for command in commands:
status = subparsers.add_parser(command)
status.add_argument('host', help="Which device to look for this program on")
status.add_argument('unit', help="The unit whose status we want to know",
nargs='?', default=None)
connect = subparsers.add_parser('connect')
connect.add_argument('host', help="Which device to log into")
args = parser.parse_args()
if args.subparser == 'peek':
peek_func(args.port)
elif args.subparser == 'poke':
poke_func(args.port, args.rate)
elif args.subparser == 'connect':
call_func("ssh pi@"+args.host+".local")
elif args.subparser == 'discover':
call_func("nmap -sP 10.0.0.0/24", ssh=False)
elif args.subparser in commands:
if args.unit is None:
args.unit = args.host
if args.host == 'local':
prefix = ""
ssh = False
else:
prefix = "ssh pi@"+args.host+".local "
ssh = True
if args.subparser == 'status':
call_func(prefix + "sudo systemctl status "+args.unit, ssh)
elif args.subparser == 'log':
call_func(prefix + "sudo journalctl -f -u "+args.unit, ssh)
elif args.subparser == 'start':
call_func(prefix + "sudo systemctl start "+args.unit, ssh)
elif args.subparser == 'stop':
call_func(prefix + "sudo systemctl stop "+args.unit, ssh)
elif args.subparser == 'restart':
call_func(prefix + "sudo systemctl restart "+args.unit, ssh)
elif args.subparser == 'enable':
call_func(prefix + "sudo systemctl enable "+args.unit, ssh)
elif args.subparser == 'disable':
call_func(prefix + "sudo systemctl disable "+args.unit, ssh)
else:
parser.print_help()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/__init__.py | from .UDPComms import Publisher
from .UDPComms import Subscriber
from .UDPComms import timeout
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/setup.py | #!/usr/bin/env python
from distutils.core import setup
setup(name='UDPComms',
version='1.1dev',
py_modules=['UDPComms'],
description='Simple library for sending messages over UDP',
author='Michal Adamkiewicz',
author_email='[email protected]',
url='https://github.com/stanfordroboticsclub/UDP-Comms',
)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/UDPComms.py |
import socket
import struct
from collections import namedtuple
from time import monotonic
import msgpack
import time
timeout = socket.timeout
MAX_SIZE = 65507
class Publisher:
def __init__(self, port_tx,port):
""" Create a Publisher Object
Arguments:
port -- the port to publish the messages on
"""
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.des_address = ("127.0.0.1",port_tx)
self.sock.bind(("127.0.0.1", port))
self.sock.settimeout(0.2)
def send(self, obj):
""" Publish a message. The obj can be any nesting of standard python types """
msg = msgpack.dumps(obj, use_bin_type=False)
assert len(msg) < MAX_SIZE, "Encoded message too big!"
self.sock.sendto(msg,self.des_address)
def __del__(self):
self.sock.close()
class Subscriber:
def __init__(self, port_rx, timeout=0.2):
""" Create a Subscriber Object
Arguments:
port -- the port to listen to messages on
timeout -- how long to wait before a message is considered out of date
"""
self.max_size = MAX_SIZE
self.timeout = timeout
self.last_data = None
self.last_time = float('-inf')
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.settimeout(timeout)
self.sock.bind(("127.0.0.1", port_rx))
def recv(self):
""" Receive a single message from the socket buffer. It blocks for up to timeout seconds.
If no message is received before timeout it raises a UDPComms.timeout exception"""
try:
self.last_data, address = self.sock.recvfrom(3)
except BlockingIOError:
raise socket.timeout("no messages in buffer and called with timeout = 0")
print(self.last_data)
self.last_time = monotonic()
return msgpack.loads(self.last_data, raw=False)
def get(self):
""" Returns the latest message it can without blocking. If the latest massage is
older then timeout seconds it raises a UDPComms.timeout exception"""
try:
self.sock.settimeout(0)
while True:
self.last_data, address = self.sock.recvfrom(self.max_size)
self.last_time = monotonic()
except socket.error:
pass
finally:
self.sock.settimeout(self.timeout)
current_time = monotonic()
if (current_time - self.last_time) < self.timeout:
return msgpack.loads(self.last_data, raw=False)
else:
raise socket.timeout("timeout=" + str(self.timeout) + \
", last message time=" + str(self.last_time) + \
", current time=" + str(current_time))
def get_list(self):
""" Returns list of messages, in the order they were received"""
msg_bufer = []
try:
self.sock.settimeout(0)
while True:
self.last_data, address = self.sock.recvfrom(self.max_size)
self.last_time = monotonic()
msg = msgpack.loads(self.last_data, raw=False)
msg_bufer.append(msg)
except socket.error:
pass
finally:
self.sock.settimeout(self.timeout)
return msg_bufer
def __del__(self):
self.sock.close()
class Subscriber:
def __init__(self, port, timeout=0.2):
""" Create a Subscriber Object
Arguments:
port -- the port to listen to messages on
timeout -- how long to wait before a message is considered out of date
"""
self.max_size = MAX_SIZE
self.port = port
self.timeout = timeout
self.last_data = None
self.last_time = float('-inf')
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if hasattr(socket, "SO_REUSEPORT"):
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.sock.settimeout(timeout)
self.sock.bind(("", port))
def recv(self):
""" Receive a single message from the socket buffer. It blocks for up to timeout seconds.
If no message is received before timeout it raises a UDPComms.timeout exception"""
try:
self.last_data, address = self.sock.recvfrom(self.max_size)
except BlockingIOError:
raise socket.timeout("no messages in buffer and called with timeout = 0")
self.last_time = monotonic()
return msgpack.loads(self.last_data, raw=False)
def get(self):
""" Returns the latest message it can without blocking. If the latest massage is
older then timeout seconds it raises a UDPComms.timeout exception"""
try:
self.sock.settimeout(0)
while True:
self.last_data, address = self.sock.recvfrom(self.max_size)
self.last_time = monotonic()
except socket.error:
pass
finally:
self.sock.settimeout(self.timeout)
current_time = monotonic()
if (current_time - self.last_time) < self.timeout:
return msgpack.loads(self.last_data, raw=False)
else:
raise socket.timeout("timeout=" + str(self.timeout) + \
", last message time=" + str(self.last_time) + \
", current time=" + str(current_time))
def get_list(self):
""" Returns list of messages, in the order they were received"""
msg_bufer = []
try:
self.sock.settimeout(0)
while True:
self.last_data, address = self.sock.recvfrom(self.max_size)
self.last_time = monotonic()
msg = msgpack.loads(self.last_data, raw=False)
msg_bufer.append(msg)
except socket.error:
pass
finally:
self.sock.settimeout(self.timeout)
return msg_bufer
def __del__(self):
self.sock.close()
if __name__ == "__main__":
msg = 'very important data'
a = Publisher(1000)
a.send( {"text": "magic", "number":5.5, "bool":False} )
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/UDPComms/README.md | # UDPComms
This is a simple library to enable communication between different processes (potentially on different machines) over a network using UDP. It's goals a simplicity and easy of understanding and reliability. It works for devices on the `10.0.0.X` subnet although this can easiliy be changed.
Currently it works in python 2 and 3 but it should be relatively simple to extend it to other languages such as C (to run on embeded devices) or Julia (to interface with faster solvers).
This new verison of the library automatically determines the type of the message and trasmits it along with it, so the subscribers can decode it correctly. While faster to prototype with then systems with explicit type declaration (such as ROS) its easy to shoot yourself in the foot if types are mismatched between publisher and subscriber.
### To Send Messages
```
>>> from UDPComms import Publisher
>>> a = Publisher(5500)
>>> a.send({"name":"Bob", "age": 20, "height": 180.5, "mass": 70.1})
```
### To Receive Messages
#### recv Method
Note: before using the `Subsciber.recv()` method read about the `Subsciber.get()` and understand the difference between them. The `Subsciber.recv()` method will pull a message from the socket buffer and it won't necessary be the most recent message. If you are calling it too slowly and there is a lot of messages you will be getting old messages. The `Subsciber.recv()` can also block for up to `timeout` seconds messing up timing.
```
>>> from UDPComms import Subscriber
>>> a = Subscriber(5500)
>>> message = a.recv()
>>> message['age']
20
>>> message['height']
180.5
>>> message['name']
"Bob"
>>> message
{"name":"Bob", "age": 20, "height": 180.5, "mass": 70.1}
```
#### get Method
The preferred way of accessing messages is the `Subsciber.get()` method (as opposed to the `recv()` method). It is guaranteed to be nonblocking so it can be used in places without messing with timing. It checks for any new messages and returns the newest one.
If the newest message is older then `timeout` seconds it raises the `UDPComms.timeout` exception. **This is an important safety feature!** Make sure to catch the timeout using `try: ... except UDPComms.timeout: ...` and put the robot in a safe configuration (e.g. turn off motors, when the joystick stop sending messages)
Note that if you call `.get` immediately after creating a subscriber it is possible its hasn't received any messages yet and it will timeout. In general it is better to have a short timeout and gracefully catch timeouts then to have long timeouts
```
>>> from UDPComms import Subscriber, timout
>>> a = Subscriber(5500)
>>> while 1:
>>> try:
>>> message = a.get()
>>> print("got", message)
>>> except timeout:
>>> print("safing robot")
```
#### get_list Method
Although UDPComms isn't ideal for commands that need to be processed in order (as the underlying UDP protocol has no guarantees of deliverry) it can be used as such in a pinch. The `Subsciber.get_list()` method will return all the messages we haven't seen yet in a list
```
>>> from UDPComms import Subscriber, timout
>>> a = Subscriber(5500)
>>> messages = a.get_list()
>>> for message in messages:
>>> print("got", message)
```
### Publisher Arguments
- `port`
The port the messages will be sent on. If you are part of Stanford Student Robotics make sure there isn't any port conflicts by checking the `UDP Ports` sheet of the [CS Comms System](https://docs.google.com/spreadsheets/d/1pqduUwYa1_sWiObJDrvCCz4Al3pl588ytE4u-Dwa6Pw/edit?usp=sharing) document. If you are not I recommend keep track of your port numbers somewhere. It's possible that in the future UDPComms will have a system of naming (with a string) as opposed to numbering publishers.
- `ip` By default UDPComms sends to the `10.0.0.X` subnet, but can be changed to a different ip using this argument. Set to localhost (`127.0.0.1`) for development on the same computer.
### Subscriber Arguments
- `port`
The port the subscriber will be listen on.
- `timeout`
If the `recv()` method don't get a message in `timeout` seconds it throws a `UDPComms.timeout` exception
### Rover
The library also comes with the `rover` command that can be used to interact with the messages manually.
| Command | Descripion |
|---------|------------|
| `rover peek port` | print messages sent on port `port` |
| `rover poke port rate` | send messages to `port` once every `rate` milliseconds. Type message in json format and press return |
There are more commands used for starting and stoping services described in [this repo](https://github.com/stanfordroboticsclub/RPI-Setup/blob/master/README.md)
### To Install
```
$git clone https://github.com/stanfordroboticsclub/UDPComms.git
$sudo bash UDPComms/install.sh
```
### To Update
```
$cd UDPComms
$git pull
$sudo bash install.sh
```
### Developing without hardware
Because this library expects you to be connected to the robot (`10.0.0.X`) network you won't be able to send messages between two programs on your computer without any other hardware connected. You can get around this by forcing your (unused) ethernet interface to get an ip on the rover network without anything being connected to it. On my computer you can do this using this command:
`sudo ifconfig en1 10.0.0.52 netmask 255.255.255.0`
Note that the exact command depends which interface on your computer is unused and what ip you want. So only use this if you know what you are doing.
If you have internet access a slightly cleaner way to do it is to setup [RemoteVPN](https://github.com/stanfordroboticsclub/RemoteVPN) on your development computer and simply connect to a development network (given if you are the only computer there)
### Known issues:
- Macs have issues sending large messages. They are fine receiving them. I think it is related to [this issue](https://github.com/BanTheRewind/Cinder-Asio/issues/9). I wonder does it work on Linux by chance (as the packets happen to be in order) but so far we didn't have issues.
- Messages over the size of one MTU (typically 1500 bytes) will be split up into multiple frames which reduces their chance of getting to their destination on wireless networks.
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Doc/guide/software_installation.rst | =====================
Software Installation
=====================
.. contents:: :depth: 4
Setting up your Raspberry Pi
------------------------------
* Raspberry Pi 4(2GB DDR for normal use, 4GB DDR for install and debug by self)
* SD Card (32GB recommended)
* Raspberry Pi 4 power supply (USB-C, 5V, >=3A)
* Ethernet cable
Preparing the Pi's SD card
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From your desktop / laptop:
1. Put the SD card into your desktop / laptop.
###############################################
2. Download this version of Ubuntu 21.10
#################################################################
Download Ubuntu21.10 server version 64bit image(NOT including desktop). Use `this version <https://drive.google.com/file/d/1JVtjFTKE6FloG3giyMN_VuS0dKt4n2xq/view?usp=sharing>`_ so everyone is using the same version. Unzip and extract the file.
You can also check the version from `ubuntu offical website. <https://ubuntu.com/download/raspberry-pi>`_
3. Use `etcher <https://www.balena.io/etcher/>`_ to flash the card.
##########################################################################################
* For quick start, you can also download the `pre-installed image <https://drive.google.com/drive/folders/12FDFbZzO61Euh8pJI9oCxN-eLVm5zjyi?usp=sharing>`_ , (username: ubuntu , password: mangdang ) flash it into the card, then skip all the following steps and start to calibarte the Pupper Mini.
* If you are using the recommended etcher, this is the start-up menu. Select ubuntu-21.10-preinstalled-server-arm64+raspi.img (file inside zip )and the SD card.
.. image:: ../_static/flash1.png
:align: center
* Image of SD card being flashed.
.. image:: ../_static/flash2.png
:align: center
* Done!
.. image:: ../_static/flash3.png
:align: center
Enabling Basic Functionality
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Turn on your Raspberry Pi.
###################################################################################################
Remove SD card from computer and put it into your Raspberry Pi.
Connect the IO board to the Pi,
Connect battery power from IO board power interface,
Connect keyboard, and mouse to the Pi as well.
Connect the Pi to a displayer by HDMI line.
Switch power on/off button to set up the Pi.
Follow the prompts to change the password((The default password is ``mangdang``)), and then install desktop.
Before installation, please make sure that raspberry pi is plugged into the network cable to access the Internet.
After installing the desktop, you only need to reboot it one time. The system will enter the desktop system by default.
Run ``$sudo apt install ubuntu-desktop``
.. image:: ../_static/installDesktop.jpg
:align: center
2. Initial Ubuntu server
########################################################
* The install time depends on your network speed, probably dozens of minutes.
Input "Y" to continue, and then input "startx" to boot up desktop at first time.
.. image:: ../_static/installDesktop2.jpg
:align: center
Reboot it only at first time, and then check the IP address, you can connect it later by SSH.
.. image:: ../_static/bootupDesktop4.jpg
:align: center
2. SSH into the pi from your computer and install the robot program.
######################################
Run ``ssh ubuntu@IP address`` (The default password is ``mangdang``)
.. image:: ../_static/ssh.png
:align: center
Make ``Robotics`` folder and download the source code.
Run ``git clone -b MiniPupper_V2 https://github.com/mangdangroboticsclub/QuadrupedRobot.git``
.. image:: ../_static/gitclonesourcecode.png
:align: center
Install requirements (on the Pi).
Run ``sudo bash Legacy/pre_install.sh``, the pre-install time depends on your network speed, maybe dezons of minutes, or several hours.
.. image:: ../_static/preInstall.png
:align: center
Insall the pupper robot program.
* ``cd QuadrupedRobot``
* ``sudo bash install.sh``
.. image:: ../_static/preInstall.png
:align: center
3. Power-cycle the robot
#############################
Unplug the battery, wait about 30 seconds, and then plug it back in.
4. Verify everything is working
###############################
#. If you just powered on the Pi, wait about 30 seconds until the green light stops blinking.
#. SSH into the robot
* Run ``ssh [email protected] (where xx is the IP address you chose for the robot)``
#. Check the status for the joystick service
* Run ``sudo systemctl status joystick``
* If you haven't yet connected the PS4 controller, it should say something like ::
pi@pupper(rw):~/StanfordQuadruped$ sudo systemctl status joystick
● joystick.service - Pupper Joystick service
Loaded: loaded (/home/pi/PupperCommand/joystick.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-03-01 06:57:20 GMT; 1s ago
Main PID: 5692 (python3)
Tasks: 3 (limit: 4035)
Memory: 7.1M
CGroup: /system.slice/joystick.service
├─5692 /usr/bin/python3 /home/pi/PupperCommand/joystick.py
└─5708 hcitool scan --flush
Mar 01 06:57:20 pupper systemd[1]: Started Pupper Joystick service.
Mar 01 06:57:21 pupper python3[5692]: [info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event0 (evdev)
Mar 01 06:57:21 pupper python3[5692]: [info][bluetooth] Scanning for devices
#. Connect the PS4 controller to the Pi by putting it pairing mode.
* To put it into pairing mode, hold the share button and circular Playstation button at the same time until it starts making quick double flashes.
* If it starts making slow single flashes, hold the Playstation button down until it stops blinking and try again.
#. Once the controller is connected, check the status again
* Run ``sudo systemctl status joystick``
* It should now look something like::
pi@pupper(rw):~/StanfordQuadruped$ sudo systemctl status joystick
● joystick.service - Pupper Joystick service
Loaded: loaded (/home/pi/PupperCommand/joystick.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-03-01 06:57:20 GMT; 55s ago
Main PID: 5692 (python3)
Tasks: 2 (limit: 4035)
Memory: 7.3M
CGroup: /system.slice/joystick.service
└─5692 /usr/bin/python3 /home/pi/PupperCommand/joystick.py
Mar 01 06:57:20 pupper systemd[1]: Started Pupper Joystick service.
Mar 01 06:57:21 pupper python3[5692]: [info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event0 (evdev)
Mar 01 06:57:21 pupper python3[5692]: [info][bluetooth] Scanning for devices
Mar 01 06:58:12 pupper python3[5692]: [info][bluetooth] Found device A0:AB:51:33:B5:A0
Mar 01 06:58:13 pupper python3[5692]: [info][controller 1] Connected to Bluetooth Controller (A0:AB:51:33:B5:A0)
Mar 01 06:58:14 pupper python3[5692]: running
Mar 01 06:58:14 pupper python3[5692]: [info][controller 1] Battery: 50%
* If the pi can't find the joystick after a minute or two, it's possible that the pi's bluetooth controller was never turned on. Run ``sudo hciconfig hci0 up`` to turn the radio on. Then restart the pi.
#. Check the status of the robot service
* Run ``sudo systemctl status robot``
* The output varies depending on the order of you running various programs, but just check that it doesn't have any red text saying that it failed.
* If it did fail, usually this fixes it: ``sudo systemctl restart robot``
7. Done!
#########
Continue to Calibration.
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/ReadMe.txt | ############################################################
This folder is for Mangdang additional code.
1. IO_Configuration : configure IO for Mangdang pupper mini feature
i2c-1 : for pwm controller PCA9685
i2c-3 : for EEPROM
i2c-4 : for fuel gauge max17205
spi0-0 : for LCD
2. FuelGauge: battery monitor deamon and max17205 driver
3. PWMController : PCA9685 dtbo
4. Adafruit_GPIO : Third party Adafruit interface
5. EEPROM: bl24c08 driver
6. LCD: ST7789-based IPS LCD driver interface
7. Tools: Mangdang tools about
8. Example: the examples for developers
9. Stuff: mp3 files
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Example/display/demo.py | import os
import sys
from PIL import Image
sys.path.append("/home/ubuntu/Robotics/QuadrupedRobot")
sys.path.extend([os.path.join(root, name) for root, dirs, _ in os.walk("/home/ubuntu/Robotics/QuadrupedRobot") for name in dirs])
from Mangdang.LCD.ST7789 import ST7789
def main():
""" The demo for picture show
"""
# init st7789 device
disp = ST7789()
disp.begin()
disp.clear()
# show exaple picture
image=Image.open("./dog.png")
image.resize((320,240))
disp.display(image)
main()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Example/display/ReadMe.txt | ####
#### The demo for developers to change the display show
####
This is a demo for developers to change his owm pic to the LCD
If you install official ubuntu rom , you need to append "dtoverlay=spi0-1cs" into syscfg.txt. If Mangdang release rom , don't need to do this.
Before you work, the following steps are recommended:
1. "ls -l /dev/spidev0.0" to check if spi node exist
2. "sudo systemctl stop robot" to stop robot service owing to it has occupied LCD device to show mangdang pictures
After finishing your work , you can run you code by root permission
####
#### run this demo
####
sudo python3 demo.py
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/PWMController/pwm-pca9685.c | // SPDX-License-Identifier: GPL-2.0-only
/*
* Driver for PCA9685 16-channel 12-bit PWM LED controller
*
* Copyright (C) 2013 Steffen Trumtrar <[email protected]>
* Copyright (C) 2015 Clemens Gruber <[email protected]>
*
* based on the pwm-twl-led.c driver
*/
#include <linux/acpi.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/bitmap.h>
/*
* Because the PCA9685 has only one prescaler per chip, only the first channel
* that is enabled is allowed to change the prescale register.
* PWM channels requested afterwards must use a period that results in the same
* prescale setting as the one set by the first requested channel.
* GPIOs do not count as enabled PWMs as they are not using the prescaler.
*/
#define PCA9685_MODE1 0x00
#define PCA9685_MODE2 0x01
#define PCA9685_SUBADDR1 0x02
#define PCA9685_SUBADDR2 0x03
#define PCA9685_SUBADDR3 0x04
#define PCA9685_ALLCALLADDR 0x05
#define PCA9685_LEDX_ON_L 0x06
#define PCA9685_LEDX_ON_H 0x07
#define PCA9685_LEDX_OFF_L 0x08
#define PCA9685_LEDX_OFF_H 0x09
#define PCA9685_ALL_LED_ON_L 0xFA
#define PCA9685_ALL_LED_ON_H 0xFB
#define PCA9685_ALL_LED_OFF_L 0xFC
#define PCA9685_ALL_LED_OFF_H 0xFD
#define PCA9685_PRESCALE 0xFE
#define PCA9685_PRESCALE_MIN 0x03 /* => max. frequency of 1526 Hz */
#define PCA9685_PRESCALE_MAX 0xFF /* => min. frequency of 24 Hz */
#define PCA9685_COUNTER_RANGE 4096
#define PCA9685_OSC_CLOCK_MHZ 25 /* Internal oscillator with 25 MHz */
#define PCA9685_NUMREGS 0xFF
#define PCA9685_MAXCHAN 0x10
#define LED_FULL BIT(4)
#define MODE1_ALLCALL BIT(0)
#define MODE1_SUB3 BIT(1)
#define MODE1_SUB2 BIT(2)
#define MODE1_SUB1 BIT(3)
#define MODE1_SLEEP BIT(4)
#define MODE2_INVRT BIT(4)
#define MODE2_OUTDRV BIT(2)
#define LED_N_ON_H(N) (PCA9685_LEDX_ON_H + (4 * (N)))
#define LED_N_ON_L(N) (PCA9685_LEDX_ON_L + (4 * (N)))
#define LED_N_OFF_H(N) (PCA9685_LEDX_OFF_H + (4 * (N)))
#define LED_N_OFF_L(N) (PCA9685_LEDX_OFF_L + (4 * (N)))
#define REG_ON_H(C) ((C) >= PCA9685_MAXCHAN ? PCA9685_ALL_LED_ON_H : LED_N_ON_H((C)))
#define REG_ON_L(C) ((C) >= PCA9685_MAXCHAN ? PCA9685_ALL_LED_ON_L : LED_N_ON_L((C)))
#define REG_OFF_H(C) ((C) >= PCA9685_MAXCHAN ? PCA9685_ALL_LED_OFF_H : LED_N_OFF_H((C)))
#define REG_OFF_L(C) ((C) >= PCA9685_MAXCHAN ? PCA9685_ALL_LED_OFF_L : LED_N_OFF_L((C)))
struct pca9685 {
struct pwm_chip chip;
struct regmap *regmap;
struct mutex lock;
DECLARE_BITMAP(pwms_enabled, PCA9685_MAXCHAN + 1);
#if IS_ENABLED(CONFIG_GPIOLIB)
struct gpio_chip gpio;
DECLARE_BITMAP(pwms_inuse, PCA9685_MAXCHAN + 1);
#endif
};
static inline struct pca9685 *to_pca(struct pwm_chip *chip)
{
return container_of(chip, struct pca9685, chip);
}
/* This function is supposed to be called with the lock mutex held */
static bool pca9685_prescaler_can_change(struct pca9685 *pca, int channel)
{
/* No PWM enabled: Change allowed */
if (bitmap_empty(pca->pwms_enabled, PCA9685_MAXCHAN + 1))
return true;
/* More than one PWM enabled: Change not allowed */
if (bitmap_weight(pca->pwms_enabled, PCA9685_MAXCHAN + 1) > 1)
return false;
/*
* Only one PWM enabled: Change allowed if the PWM about to
* be changed is the one that is already enabled
*/
return test_bit(channel, pca->pwms_enabled);
}
/* Helper function to set the duty cycle ratio to duty/4096 (e.g. duty=2048 -> 50%) */
static void pca9685_pwm_set_duty(struct pca9685 *pca, int channel, unsigned int duty)
{
if (duty == 0) {
/* Set the full OFF bit, which has the highest precedence */
regmap_write(pca->regmap, REG_OFF_H(channel), LED_FULL);
} else if (duty >= PCA9685_COUNTER_RANGE) {
/* Set the full ON bit and clear the full OFF bit */
regmap_write(pca->regmap, REG_ON_H(channel), LED_FULL);
regmap_write(pca->regmap, REG_OFF_H(channel), 0);
} else {
/* Set OFF time (clears the full OFF bit) */
regmap_write(pca->regmap, REG_OFF_L(channel), duty & 0xff);
regmap_write(pca->regmap, REG_OFF_H(channel), (duty >> 8) & 0xf);
/* Clear the full ON bit */
regmap_write(pca->regmap, REG_ON_H(channel), 0);
}
}
static unsigned int pca9685_pwm_get_duty(struct pca9685 *pca, int channel)
{
unsigned int off_h = 0, val = 0;
if (WARN_ON(channel >= PCA9685_MAXCHAN)) {
/* HW does not support reading state of "all LEDs" channel */
return 0;
}
regmap_read(pca->regmap, LED_N_OFF_H(channel), &off_h);
if (off_h & LED_FULL) {
/* Full OFF bit is set */
return 0;
}
regmap_read(pca->regmap, LED_N_ON_H(channel), &val);
if (val & LED_FULL) {
/* Full ON bit is set */
return PCA9685_COUNTER_RANGE;
}
if (regmap_read(pca->regmap, LED_N_OFF_L(channel), &val)) {
/* Reset val to 0 in case reading LED_N_OFF_L failed */
val = 0;
}
return ((off_h & 0xf) << 8) | (val & 0xff);
}
#if IS_ENABLED(CONFIG_GPIOLIB)
static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx)
{
bool is_inuse;
mutex_lock(&pca->lock);
if (pwm_idx >= PCA9685_MAXCHAN) {
/*
* "All LEDs" channel:
* pretend already in use if any of the PWMs are requested
*/
if (!bitmap_empty(pca->pwms_inuse, PCA9685_MAXCHAN)) {
is_inuse = true;
goto out;
}
} else {
/*
* Regular channel:
* pretend already in use if the "all LEDs" channel is requested
*/
if (test_bit(PCA9685_MAXCHAN, pca->pwms_inuse)) {
is_inuse = true;
goto out;
}
}
is_inuse = test_and_set_bit(pwm_idx, pca->pwms_inuse);
out:
mutex_unlock(&pca->lock);
return is_inuse;
}
static void pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
{
mutex_lock(&pca->lock);
clear_bit(pwm_idx, pca->pwms_inuse);
mutex_unlock(&pca->lock);
}
static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
{
struct pca9685 *pca = gpiochip_get_data(gpio);
if (pca9685_pwm_test_and_set_inuse(pca, offset))
return -EBUSY;
pm_runtime_get_sync(pca->chip.dev);
return 0;
}
static int pca9685_pwm_gpio_get(struct gpio_chip *gpio, unsigned int offset)
{
struct pca9685 *pca = gpiochip_get_data(gpio);
return pca9685_pwm_get_duty(pca, offset) != 0;
}
static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
int value)
{
struct pca9685 *pca = gpiochip_get_data(gpio);
pca9685_pwm_set_duty(pca, offset, value ? PCA9685_COUNTER_RANGE : 0);
}
static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
{
struct pca9685 *pca = gpiochip_get_data(gpio);
pca9685_pwm_set_duty(pca, offset, 0);
pm_runtime_put(pca->chip.dev);
pca9685_pwm_clear_inuse(pca, offset);
}
static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
/* Always out */
return GPIO_LINE_DIRECTION_OUT;
}
static int pca9685_pwm_gpio_direction_input(struct gpio_chip *gpio,
unsigned int offset)
{
return -EINVAL;
}
static int pca9685_pwm_gpio_direction_output(struct gpio_chip *gpio,
unsigned int offset, int value)
{
pca9685_pwm_gpio_set(gpio, offset, value);
return 0;
}
/*
* The PCA9685 has a bit for turning the PWM output full off or on. Some
* boards like Intel Galileo actually uses these as normal GPIOs so we
* expose a GPIO chip here which can exclusively take over the underlying
* PWM channel.
*/
static int pca9685_pwm_gpio_probe(struct pca9685 *pca)
{
struct device *dev = pca->chip.dev;
pca->gpio.label = dev_name(dev);
pca->gpio.parent = dev;
pca->gpio.request = pca9685_pwm_gpio_request;
pca->gpio.free = pca9685_pwm_gpio_free;
pca->gpio.get_direction = pca9685_pwm_gpio_get_direction;
pca->gpio.direction_input = pca9685_pwm_gpio_direction_input;
pca->gpio.direction_output = pca9685_pwm_gpio_direction_output;
pca->gpio.get = pca9685_pwm_gpio_get;
pca->gpio.set = pca9685_pwm_gpio_set;
pca->gpio.base = -1;
pca->gpio.ngpio = PCA9685_MAXCHAN;
pca->gpio.can_sleep = true;
return devm_gpiochip_add_data(dev, &pca->gpio, pca);
}
#else
static inline bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca,
int pwm_idx)
{
return false;
}
static inline void
pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
{
}
static inline int pca9685_pwm_gpio_probe(struct pca9685 *pca)
{
return 0;
}
#endif
static void pca9685_set_sleep_mode(struct pca9685 *pca, bool enable)
{
regmap_update_bits(pca->regmap, PCA9685_MODE1,
MODE1_SLEEP, enable ? MODE1_SLEEP : 0);
if (!enable) {
/* Wait 500us for the oscillator to be back up */
udelay(500);
}
}
static int __pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state)
{
struct pca9685 *pca = to_pca(chip);
unsigned long long duty, prescale;
unsigned int val = 0;
if (state->polarity != PWM_POLARITY_NORMAL)
return -EINVAL;
prescale = DIV_ROUND_CLOSEST_ULL(PCA9685_OSC_CLOCK_MHZ * state->period,
PCA9685_COUNTER_RANGE * 1000) - 1;
if (prescale < PCA9685_PRESCALE_MIN || prescale > PCA9685_PRESCALE_MAX) {
dev_err(chip->dev, "pwm not changed: period out of bounds!\n");
return -EINVAL;
}
if (!state->enabled) {
pca9685_pwm_set_duty(pca, pwm->hwpwm, 0);
return 0;
}
regmap_read(pca->regmap, PCA9685_PRESCALE, &val);
if (prescale != val) {
if (!pca9685_prescaler_can_change(pca, pwm->hwpwm)) {
dev_err(chip->dev,
"pwm not changed: periods of enabled pwms must match!\n");
return -EBUSY;
}
/*
* Putting the chip briefly into SLEEP mode
* at this point won't interfere with the
* pm_runtime framework, because the pm_runtime
* state is guaranteed active here.
*/
/* Put chip into sleep mode */
pca9685_set_sleep_mode(pca, true);
/* Change the chip-wide output frequency */
regmap_write(pca->regmap, PCA9685_PRESCALE, prescale);
/* Wake the chip up */
pca9685_set_sleep_mode(pca, false);
}
duty = PCA9685_COUNTER_RANGE * state->duty_cycle;
duty = DIV_ROUND_UP_ULL(duty, state->period);
pca9685_pwm_set_duty(pca, pwm->hwpwm, duty);
return 0;
}
static int pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state)
{
struct pca9685 *pca = to_pca(chip);
int ret;
mutex_lock(&pca->lock);
ret = __pca9685_pwm_apply(chip, pwm, state);
if (ret == 0) {
if (state->enabled)
set_bit(pwm->hwpwm, pca->pwms_enabled);
else
clear_bit(pwm->hwpwm, pca->pwms_enabled);
}
mutex_unlock(&pca->lock);
return ret;
}
static void pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
struct pwm_state *state)
{
struct pca9685 *pca = to_pca(chip);
unsigned long long duty;
unsigned int val = 0;
/* Calculate (chip-wide) period from prescale value */
regmap_read(pca->regmap, PCA9685_PRESCALE, &val);
/*
* PCA9685_OSC_CLOCK_MHZ is 25, i.e. an integer divider of 1000.
* The following calculation is therefore only a multiplication
* and we are not losing precision.
*/
state->period = (PCA9685_COUNTER_RANGE * 1000 / PCA9685_OSC_CLOCK_MHZ) *
(val + 1);
/* The (per-channel) polarity is fixed */
state->polarity = PWM_POLARITY_NORMAL;
if (pwm->hwpwm >= PCA9685_MAXCHAN) {
/*
* The "all LEDs" channel does not support HW readout
* Return 0 and disabled for backwards compatibility
*/
state->duty_cycle = 0;
state->enabled = false;
return;
}
state->enabled = true;
duty = pca9685_pwm_get_duty(pca, pwm->hwpwm);
state->duty_cycle = DIV_ROUND_DOWN_ULL(duty * state->period, PCA9685_COUNTER_RANGE);
}
static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct pca9685 *pca = to_pca(chip);
if (pca9685_pwm_test_and_set_inuse(pca, pwm->hwpwm))
return -EBUSY;
if (pwm->hwpwm < PCA9685_MAXCHAN) {
/* PWMs - except the "all LEDs" channel - default to enabled */
mutex_lock(&pca->lock);
set_bit(pwm->hwpwm, pca->pwms_enabled);
mutex_unlock(&pca->lock);
}
pm_runtime_get_sync(chip->dev);
return 0;
}
static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct pca9685 *pca = to_pca(chip);
mutex_lock(&pca->lock);
pca9685_pwm_set_duty(pca, pwm->hwpwm, 0);
clear_bit(pwm->hwpwm, pca->pwms_enabled);
mutex_unlock(&pca->lock);
pm_runtime_put(chip->dev);
pca9685_pwm_clear_inuse(pca, pwm->hwpwm);
}
static const struct pwm_ops pca9685_pwm_ops = {
.apply = pca9685_pwm_apply,
.get_state = pca9685_pwm_get_state,
.request = pca9685_pwm_request,
.free = pca9685_pwm_free,
.owner = THIS_MODULE,
};
static const struct regmap_config pca9685_regmap_i2c_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = PCA9685_NUMREGS,
.cache_type = REGCACHE_NONE,
};
static int pca9685_pwm_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct pca9685 *pca;
unsigned int reg;
int ret;
pca = devm_kzalloc(&client->dev, sizeof(*pca), GFP_KERNEL);
if (!pca)
return -ENOMEM;
pca->regmap = devm_regmap_init_i2c(client, &pca9685_regmap_i2c_config);
if (IS_ERR(pca->regmap)) {
ret = PTR_ERR(pca->regmap);
dev_err(&client->dev, "Failed to initialize register map: %d\n",
ret);
return ret;
}
i2c_set_clientdata(client, pca);
mutex_init(&pca->lock);
regmap_read(pca->regmap, PCA9685_MODE2, ®);
if (device_property_read_bool(&client->dev, "invert"))
reg |= MODE2_INVRT;
else
reg &= ~MODE2_INVRT;
if (device_property_read_bool(&client->dev, "open-drain"))
reg &= ~MODE2_OUTDRV;
else
reg |= MODE2_OUTDRV;
regmap_write(pca->regmap, PCA9685_MODE2, reg);
/* Disable all LED ALLCALL and SUBx addresses to avoid bus collisions */
regmap_read(pca->regmap, PCA9685_MODE1, ®);
reg &= ~(MODE1_ALLCALL | MODE1_SUB1 | MODE1_SUB2 | MODE1_SUB3);
regmap_write(pca->regmap, PCA9685_MODE1, reg);
/* Reset OFF registers to POR default */
regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_L, LED_FULL);
regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_H, LED_FULL);
pca->chip.ops = &pca9685_pwm_ops;
/* Add an extra channel for ALL_LED */
pca->chip.npwm = PCA9685_MAXCHAN + 1;
pca->chip.dev = &client->dev;
ret = pwmchip_add(&pca->chip);
if (ret < 0)
return ret;
ret = pca9685_pwm_gpio_probe(pca);
if (ret < 0) {
pwmchip_remove(&pca->chip);
return ret;
}
pm_runtime_enable(&client->dev);
if (pm_runtime_enabled(&client->dev)) {
/*
* Although the chip comes out of power-up in the sleep state,
* we force it to sleep in case it was woken up before
*/
pca9685_set_sleep_mode(pca, true);
pm_runtime_set_suspended(&client->dev);
} else {
/* Wake the chip up if runtime PM is disabled */
pca9685_set_sleep_mode(pca, false);
}
return 0;
}
static int pca9685_pwm_remove(struct i2c_client *client)
{
struct pca9685 *pca = i2c_get_clientdata(client);
int ret;
//ret = pwmchip_remove(&pca->chip);
pwmchip_remove(&pca->chip);
//if (ret)
// return ret;
if (!pm_runtime_enabled(&client->dev)) {
/* Put chip in sleep state if runtime PM is disabled */
pca9685_set_sleep_mode(pca, true);
}
pm_runtime_disable(&client->dev);
return 0;
}
static int __maybe_unused pca9685_pwm_runtime_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct pca9685 *pca = i2c_get_clientdata(client);
pca9685_set_sleep_mode(pca, true);
return 0;
}
static int __maybe_unused pca9685_pwm_runtime_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct pca9685 *pca = i2c_get_clientdata(client);
pca9685_set_sleep_mode(pca, false);
return 0;
}
static const struct i2c_device_id pca9685_id[] = {
{ "pca9685", 0 },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(i2c, pca9685_id);
#ifdef CONFIG_ACPI
static const struct acpi_device_id pca9685_acpi_ids[] = {
{ "INT3492", 0 },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(acpi, pca9685_acpi_ids);
#endif
#ifdef CONFIG_OF
static const struct of_device_id pca9685_dt_ids[] = {
{ .compatible = "nxp,pca9685-pwm", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, pca9685_dt_ids);
#endif
static const struct dev_pm_ops pca9685_pwm_pm = {
SET_RUNTIME_PM_OPS(pca9685_pwm_runtime_suspend,
pca9685_pwm_runtime_resume, NULL)
};
static struct i2c_driver pca9685_i2c_driver = {
.driver = {
.name = "pca9685-pwm",
.acpi_match_table = ACPI_PTR(pca9685_acpi_ids),
.of_match_table = of_match_ptr(pca9685_dt_ids),
.pm = &pca9685_pwm_pm,
},
.probe = pca9685_pwm_probe,
.remove = pca9685_pwm_remove,
.id_table = pca9685_id,
};
module_i2c_driver(pca9685_i2c_driver);
MODULE_AUTHOR("Steffen Trumtrar <[email protected]>");
MODULE_DESCRIPTION("PWM driver for PCA9685");
MODULE_LICENSE("GPL");
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/PWMController/install.sh | #!/usr/bin/env sh
# Install pca9685 driver
#
set -x
sudo cp i2c-pwm-pca9685a.dtbo /boot/firmware/overlays/
make
make install
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/IO_Configuration/syscfg.txt | # This file is intended to contain system-made configuration changes. User
# configuration changes should be placed in "usercfg.txt". Please refer to the
# README file for a description of the various configuration files on the boot
# partition.
dtparam=i2c1
dtoverlay=i2c4,pins_6_7
dtoverlay=spi0-1cs
dtoverlay=i2c-pwm-pca9685a
dtoverlay=act-led,activelow=on
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
# For MP devices
[gpio27=0]
dtoverlay=gpio-fan
dtoverlay=i2c3,pins_4_5
dtparam=audio=on
dtoverlay=audremap,pins_18_19
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/IO_Configuration/config.txt | [pi4]
max_framebuffers=2
[all]
kernel=vmlinuz
cmdline=cmdline.txt
initramfs initrd.img followkernel
# Enable the audio output, I2C and SPI interfaces on the GPIO header
# dtparam=audio=on
# dtparam=i2c_arm=on
# dtparam=spi=on
# Enable the KMS ("full" KMS) graphics overlay, and allocate 128Mb to the GPU
# memory. The full KMS overlay is required for X11 application support under
# wayland
dtoverlay=vc4-kms-v3d
gpu_mem=128
# Uncomment the following to enable the Raspberry Pi camera module firmware.
# Be warned that there *may* be incompatibilities with the "full" KMS overlay
#start_x=1
# Comment out the following line if the edges of the desktop appear outside
# the edges of your display
disable_overscan=1
# If you have issues with audio, you may try uncommenting the following line
# which forces the HDMI output into HDMI mode instead of DVI (which doesn't
# support audio output)
#hdmi_drive=2
# If you have a CM4, uncomment the following line to enable the USB2 outputs
# on the IO board (assuming your CM4 is plugged into such a board)
#dtoverlay=dwc2,dr_mode=host
# Config settings specific to arm64
arm_64bit=1
dtoverlay=dwc2
arm_boost=1
include syscfg.txt
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Tools/run_set_neatral.sh | #!/usr/bin/env sh
# step 1 stop robot service
systemctl stop robot
# step 2 set neatral position
echo 1500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo "pwm 0 setting pwm off parameter --> 90 degree "
echo 1500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
echo "pwm 1 setting pwm off parameter --> 90 degree"
echo 500000 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle
echo "pwm 2 setting pwm off parameter --> 0 degree"
echo 2500000 > /sys/class/pwm/pwmchip0/pwm3/duty_cycle
echo "pwm 3 setting pwm off parameter --> 180 degree"
sleep 1
echo "Done ! "
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/System/joystart.sh | sleep 10
systemctl restart joystick
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/System/install.sh | # The command script to init system for mini pupper
set -x
sudo cp 20auto-upgrades /etc/apt/apt.conf.d/
#sudo apt-get remove -y ubuntu-release-upgrader-core
sudo chmod 440 sudoers
sudo cp sudoers /etc/
sudo cp rc.local /etc/
sudo cp rc-local.service /lib/systemd/system/
sudo systemctl enable rc-local
sudo systemctl start rc-local.service
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/EEPROM/at24.c | // SPDX-License-Identifier: GPL-2.0-or-later
/*
* at24.c - handle most I2C EEPROMs
*
* Copyright (C) 2005-2007 David Brownell
* Copyright (C) 2008 Wolfram Sang, Pengutronix
*/
#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/capability.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/nvmem-provider.h>
#include <linux/of_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
/* Address pointer is 16 bit. */
#define AT24_FLAG_ADDR16 BIT(7)
/* sysfs-entry will be read-only. */
#define AT24_FLAG_READONLY BIT(6)
/* sysfs-entry will be world-readable. */
#define AT24_FLAG_IRUGO BIT(5)
/* Take always 8 addresses (24c00). */
#define AT24_FLAG_TAKE8ADDR BIT(4)
/* Factory-programmed serial number. */
#define AT24_FLAG_SERIAL BIT(3)
/* Factory-programmed mac address. */
#define AT24_FLAG_MAC BIT(2)
/* Does not auto-rollover reads to the next slave address. */
#define AT24_FLAG_NO_RDROL BIT(1)
/*
* I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
* Differences between different vendor product lines (like Atmel AT24C or
* MicroChip 24LC, etc) won't much matter for typical read/write access.
* There are also I2C RAM chips, likewise interchangeable. One example
* would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes).
*
* However, misconfiguration can lose data. "Set 16-bit memory address"
* to a part with 8-bit addressing will overwrite data. Writing with too
* big a page size also loses data. And it's not safe to assume that the
* conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC
* uses 0x51, for just one example.
*
* Accordingly, explicit board-specific configuration data should be used
* in almost all cases. (One partial exception is an SMBus used to access
* "SPD" data for DRAM sticks. Those only use 24c02 EEPROMs.)
*
* So this driver uses "new style" I2C driver binding, expecting to be
* told what devices exist. That may be in arch/X/mach-Y/board-Z.c or
* similar kernel-resident tables; or, configuration data coming from
* a bootloader.
*
* Other than binding model, current differences from "eeprom" driver are
* that this one handles write access and isn't restricted to 24c02 devices.
* It also handles larger devices (32 kbit and up) with two-byte addresses,
* which won't work on pure SMBus systems.
*/
struct at24_client {
struct i2c_client *client;
struct regmap *regmap;
};
struct at24_data {
/*
* Lock protects against activities from other Linux tasks,
* but not from changes by other I2C masters.
*/
struct mutex lock;
unsigned int write_max;
unsigned int num_addresses;
unsigned int offset_adj;
u32 byte_len;
u16 page_size;
u8 flags;
struct nvmem_device *nvmem;
struct regulator *vcc_reg;
void (*read_post)(unsigned int off, char *buf, size_t count);
/*
* Some chips tie up multiple I2C addresses; dummy devices reserve
* them for us, and we'll use them with SMBus calls.
*/
struct at24_client client[];
};
/*
* This parameter is to help this driver avoid blocking other drivers out
* of I2C for potentially troublesome amounts of time. With a 100 kHz I2C
* clock, one 256 byte read takes about 1/43 second which is excessive;
* but the 1/170 second it takes at 400 kHz may be quite reasonable; and
* at 1 MHz (Fm+) a 1/430 second delay could easily be invisible.
*
* This value is forced to be a power of two so that writes align on pages.
*/
static unsigned int at24_io_limit = 128;
module_param_named(io_limit, at24_io_limit, uint, 0);
MODULE_PARM_DESC(at24_io_limit, "Maximum bytes per I/O (default 128)");
/*
* Specs often allow 5 msec for a page write, sometimes 20 msec;
* it's important to recover from write timeouts.
*/
static unsigned int at24_write_timeout = 25;
module_param_named(write_timeout, at24_write_timeout, uint, 0);
MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
struct at24_chip_data {
u32 byte_len;
u8 flags;
void (*read_post)(unsigned int off, char *buf, size_t count);
};
#define AT24_CHIP_DATA(_name, _len, _flags) \
static const struct at24_chip_data _name = { \
.byte_len = _len, .flags = _flags, \
}
#define AT24_CHIP_DATA_CB(_name, _len, _flags, _read_post) \
static const struct at24_chip_data _name = { \
.byte_len = _len, .flags = _flags, \
.read_post = _read_post, \
}
static void at24_read_post_vaio(unsigned int off, char *buf, size_t count)
{
int i;
if (capable(CAP_SYS_ADMIN))
return;
/*
* Hide VAIO private settings to regular users:
* - BIOS passwords: bytes 0x00 to 0x0f
* - UUID: bytes 0x10 to 0x1f
* - Serial number: 0xc0 to 0xdf
*/
for (i = 0; i < count; i++) {
if ((off + i <= 0x1f) ||
(off + i >= 0xc0 && off + i <= 0xdf))
buf[i] = 0;
}
}
/* needs 8 addresses as A0-A2 are ignored */
AT24_CHIP_DATA(at24_data_24c00, 128 / 8, AT24_FLAG_TAKE8ADDR);
/* old variants can't be handled with this generic entry! */
AT24_CHIP_DATA(at24_data_24c01, 1024 / 8, 0);
AT24_CHIP_DATA(at24_data_24cs01, 16,
AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24c02, 2048 / 8, 0);
AT24_CHIP_DATA(at24_data_24cs02, 16,
AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24mac402, 48 / 8,
AT24_FLAG_MAC | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24mac602, 64 / 8,
AT24_FLAG_MAC | AT24_FLAG_READONLY);
/* spd is a 24c02 in memory DIMMs */
AT24_CHIP_DATA(at24_data_spd, 2048 / 8,
AT24_FLAG_READONLY | AT24_FLAG_IRUGO);
/* 24c02_vaio is a 24c02 on some Sony laptops */
AT24_CHIP_DATA_CB(at24_data_24c02_vaio, 2048 / 8,
AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
at24_read_post_vaio);
AT24_CHIP_DATA(at24_data_24c04, 4096 / 8, 0);
AT24_CHIP_DATA(at24_data_24cs04, 16,
AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
/* 24rf08 quirk is handled at i2c-core */
AT24_CHIP_DATA(at24_data_24c08, 8192 / 8, 0);
AT24_CHIP_DATA(at24_data_24cs08, 16,
AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24c16, 16384 / 8, 0);
AT24_CHIP_DATA(at24_data_24cs16, 16,
AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24c32, 32768 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24cs32, 16,
AT24_FLAG_ADDR16 | AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24c64, 65536 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24cs64, 16,
AT24_FLAG_ADDR16 | AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
AT24_CHIP_DATA(at24_data_24c128, 131072 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24c256, 262144 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24c512, 524288 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24c1024, 1048576 / 8, AT24_FLAG_ADDR16);
AT24_CHIP_DATA(at24_data_24c2048, 2097152 / 8, AT24_FLAG_ADDR16);
/* identical to 24c08 ? */
AT24_CHIP_DATA(at24_data_INT3499, 8192 / 8, 0);
static const struct i2c_device_id at24_ids[] = {
{ "24c00", (kernel_ulong_t)&at24_data_24c00 },
{ "24c01", (kernel_ulong_t)&at24_data_24c01 },
{ "24cs01", (kernel_ulong_t)&at24_data_24cs01 },
{ "24c02", (kernel_ulong_t)&at24_data_24c02 },
{ "24cs02", (kernel_ulong_t)&at24_data_24cs02 },
{ "24mac402", (kernel_ulong_t)&at24_data_24mac402 },
{ "24mac602", (kernel_ulong_t)&at24_data_24mac602 },
{ "spd", (kernel_ulong_t)&at24_data_spd },
{ "24c02-vaio", (kernel_ulong_t)&at24_data_24c02_vaio },
{ "24c04", (kernel_ulong_t)&at24_data_24c04 },
{ "24cs04", (kernel_ulong_t)&at24_data_24cs04 },
{ "24c08", (kernel_ulong_t)&at24_data_24c08 },
{ "24cs08", (kernel_ulong_t)&at24_data_24cs08 },
{ "24c16", (kernel_ulong_t)&at24_data_24c16 },
{ "24cs16", (kernel_ulong_t)&at24_data_24cs16 },
{ "24c32", (kernel_ulong_t)&at24_data_24c32 },
{ "24cs32", (kernel_ulong_t)&at24_data_24cs32 },
{ "24c64", (kernel_ulong_t)&at24_data_24c64 },
{ "24cs64", (kernel_ulong_t)&at24_data_24cs64 },
{ "24c128", (kernel_ulong_t)&at24_data_24c128 },
{ "24c256", (kernel_ulong_t)&at24_data_24c256 },
{ "24c512", (kernel_ulong_t)&at24_data_24c512 },
{ "24c1024", (kernel_ulong_t)&at24_data_24c1024 },
{ "24c2048", (kernel_ulong_t)&at24_data_24c2048 },
{ "at24", 0 },
{ /* END OF LIST */ }
};
MODULE_DEVICE_TABLE(i2c, at24_ids);
static const struct of_device_id at24_of_match[] = {
{ .compatible = "atmel,24c00", .data = &at24_data_24c00 },
{ .compatible = "atmel,24c01", .data = &at24_data_24c01 },
{ .compatible = "atmel,24cs01", .data = &at24_data_24cs01 },
{ .compatible = "atmel,24c02", .data = &at24_data_24c02 },
{ .compatible = "atmel,24cs02", .data = &at24_data_24cs02 },
{ .compatible = "atmel,24mac402", .data = &at24_data_24mac402 },
{ .compatible = "atmel,24mac602", .data = &at24_data_24mac602 },
{ .compatible = "atmel,spd", .data = &at24_data_spd },
{ .compatible = "atmel,24c04", .data = &at24_data_24c04 },
{ .compatible = "atmel,24cs04", .data = &at24_data_24cs04 },
{ .compatible = "atmel,24c08", .data = &at24_data_24c08 },
{ .compatible = "atmel,24cs08", .data = &at24_data_24cs08 },
{ .compatible = "atmel,24c16", .data = &at24_data_24c16 },
{ .compatible = "atmel,24cs16", .data = &at24_data_24cs16 },
{ .compatible = "atmel,24c32", .data = &at24_data_24c32 },
{ .compatible = "atmel,24cs32", .data = &at24_data_24cs32 },
{ .compatible = "atmel,24c64", .data = &at24_data_24c64 },
{ .compatible = "atmel,24cs64", .data = &at24_data_24cs64 },
{ .compatible = "atmel,24c128", .data = &at24_data_24c128 },
{ .compatible = "atmel,24c256", .data = &at24_data_24c256 },
{ .compatible = "atmel,24c512", .data = &at24_data_24c512 },
{ .compatible = "atmel,24c1024", .data = &at24_data_24c1024 },
{ .compatible = "atmel,24c2048", .data = &at24_data_24c2048 },
{ /* END OF LIST */ },
};
MODULE_DEVICE_TABLE(of, at24_of_match);
static const struct acpi_device_id __maybe_unused at24_acpi_ids[] = {
{ "INT3499", (kernel_ulong_t)&at24_data_INT3499 },
{ "TPF0001", (kernel_ulong_t)&at24_data_24c1024 },
{ /* END OF LIST */ }
};
MODULE_DEVICE_TABLE(acpi, at24_acpi_ids);
/*
* This routine supports chips which consume multiple I2C addresses. It
* computes the addressing information to be used for a given r/w request.
* Assumes that sanity checks for offset happened at sysfs-layer.
*
* Slave address and byte offset derive from the offset. Always
* set the byte address; on a multi-master board, another master
* may have changed the chip's "current" address pointer.
*/
static struct at24_client *at24_translate_offset(struct at24_data *at24,
unsigned int *offset)
{
unsigned int i;
if (at24->flags & AT24_FLAG_ADDR16) {
i = *offset >> 16;
*offset &= 0xffff;
} else {
i = *offset >> 8;
*offset &= 0xff;
}
return &at24->client[i];
}
static struct device *at24_base_client_dev(struct at24_data *at24)
{
return &at24->client[0].client->dev;
}
static size_t at24_adjust_read_count(struct at24_data *at24,
unsigned int offset, size_t count)
{
unsigned int bits;
size_t remainder;
/*
* In case of multi-address chips that don't rollover reads to
* the next slave address: truncate the count to the slave boundary,
* so that the read never straddles slaves.
*/
if (at24->flags & AT24_FLAG_NO_RDROL) {
bits = (at24->flags & AT24_FLAG_ADDR16) ? 16 : 8;
remainder = BIT(bits) - offset;
if (count > remainder)
count = remainder;
}
if (count > at24_io_limit)
count = at24_io_limit;
return count;
}
static ssize_t at24_regmap_read(struct at24_data *at24, char *buf,
unsigned int offset, size_t count)
{
unsigned long timeout, read_time;
struct at24_client *at24_client;
struct i2c_client *client;
struct regmap *regmap;
int ret;
at24_client = at24_translate_offset(at24, &offset);
regmap = at24_client->regmap;
client = at24_client->client;
count = at24_adjust_read_count(at24, offset, count);
/* adjust offset for mac and serial read ops */
offset += at24->offset_adj;
timeout = jiffies + msecs_to_jiffies(at24_write_timeout);
do {
/*
* The timestamp shall be taken before the actual operation
* to avoid a premature timeout in case of high CPU load.
*/
read_time = jiffies;
ret = regmap_bulk_read(regmap, offset, buf, count);
dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n",
count, offset, ret, jiffies);
if (!ret)
return count;
usleep_range(1000, 1500);
} while (time_before(read_time, timeout));
return -ETIMEDOUT;
}
/*
* Note that if the hardware write-protect pin is pulled high, the whole
* chip is normally write protected. But there are plenty of product
* variants here, including OTP fuses and partial chip protect.
*
* We only use page mode writes; the alternative is sloooow. These routines
* write at most one page.
*/
static size_t at24_adjust_write_count(struct at24_data *at24,
unsigned int offset, size_t count)
{
unsigned int next_page;
/* write_max is at most a page */
if (count > at24->write_max)
count = at24->write_max;
/* Never roll over backwards, to the start of this page */
next_page = roundup(offset + 1, at24->page_size);
if (offset + count > next_page)
count = next_page - offset;
return count;
}
static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf,
unsigned int offset, size_t count)
{
unsigned long timeout, write_time;
struct at24_client *at24_client;
struct i2c_client *client;
struct regmap *regmap;
int ret;
at24_client = at24_translate_offset(at24, &offset);
regmap = at24_client->regmap;
client = at24_client->client;
count = at24_adjust_write_count(at24, offset, count);
timeout = jiffies + msecs_to_jiffies(at24_write_timeout);
do {
/*
* The timestamp shall be taken before the actual operation
* to avoid a premature timeout in case of high CPU load.
*/
write_time = jiffies;
ret = regmap_bulk_write(regmap, offset, buf, count);
dev_dbg(&client->dev, "write %zu@%d --> %d (%ld)\n",
count, offset, ret, jiffies);
if (!ret)
return count;
usleep_range(1000, 1500);
} while (time_before(write_time, timeout));
return -ETIMEDOUT;
}
static int at24_read(void *priv, unsigned int off, void *val, size_t count)
{
struct at24_data *at24;
struct device *dev;
char *buf = val;
int i, ret;
at24 = priv;
dev = at24_base_client_dev(at24);
if (unlikely(!count))
return count;
if (off + count > at24->byte_len)
return -EINVAL;
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
pm_runtime_put_noidle(dev);
return ret;
}
/*
* Read data from chip, protecting against concurrent updates
* from this host, but not from other I2C masters.
*/
mutex_lock(&at24->lock);
for (i = 0; count; i += ret, count -= ret) {
ret = at24_regmap_read(at24, buf + i, off + i, count);
if (ret < 0) {
mutex_unlock(&at24->lock);
pm_runtime_put(dev);
return ret;
}
}
mutex_unlock(&at24->lock);
pm_runtime_put(dev);
if (unlikely(at24->read_post))
at24->read_post(off, buf, i);
return 0;
}
static int at24_write(void *priv, unsigned int off, void *val, size_t count)
{
struct at24_data *at24;
struct device *dev;
char *buf = val;
int ret;
at24 = priv;
dev = at24_base_client_dev(at24);
if (unlikely(!count))
return -EINVAL;
if (off + count > at24->byte_len)
return -EINVAL;
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
pm_runtime_put_noidle(dev);
return ret;
}
/*
* Write data to chip, protecting against concurrent updates
* from this host, but not from other I2C masters.
*/
mutex_lock(&at24->lock);
while (count) {
ret = at24_regmap_write(at24, buf, off, count);
if (ret < 0) {
mutex_unlock(&at24->lock);
pm_runtime_put(dev);
return ret;
}
buf += ret;
off += ret;
count -= ret;
}
mutex_unlock(&at24->lock);
pm_runtime_put(dev);
return 0;
}
static const struct at24_chip_data *at24_get_chip_data(struct device *dev)
{
struct device_node *of_node = dev->of_node;
const struct at24_chip_data *cdata;
const struct i2c_device_id *id;
id = i2c_match_id(at24_ids, to_i2c_client(dev));
/*
* The I2C core allows OF nodes compatibles to match against the
* I2C device ID table as a fallback, so check not only if an OF
* node is present but also if it matches an OF device ID entry.
*/
if (of_node && of_match_device(at24_of_match, dev))
cdata = of_device_get_match_data(dev);
else if (id)
cdata = (void *)id->driver_data;
else
cdata = acpi_device_get_match_data(dev);
if (!cdata)
return ERR_PTR(-ENODEV);
return cdata;
}
static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
struct regmap_config *regmap_config)
{
struct i2c_client *base_client, *dummy_client;
struct regmap *regmap;
struct device *dev;
base_client = at24->client[0].client;
dev = &base_client->dev;
dummy_client = devm_i2c_new_dummy_device(dev, base_client->adapter,
base_client->addr + index);
if (IS_ERR(dummy_client))
return PTR_ERR(dummy_client);
regmap = devm_regmap_init_i2c(dummy_client, regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
at24->client[index].client = dummy_client;
at24->client[index].regmap = regmap;
return 0;
}
static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len)
{
if (flags & AT24_FLAG_MAC) {
/* EUI-48 starts from 0x9a, EUI-64 from 0x98 */
return 0xa0 - byte_len;
} else if (flags & AT24_FLAG_SERIAL && flags & AT24_FLAG_ADDR16) {
/*
* For 16 bit address pointers, the word address must contain
* a '10' sequence in bits 11 and 10 regardless of the
* intended position of the address pointer.
*/
return 0x0800;
} else if (flags & AT24_FLAG_SERIAL) {
/*
* Otherwise the word address must begin with a '10' sequence,
* regardless of the intended address.
*/
return 0x0080;
} else {
return 0;
}
}
static int at24_probe(struct i2c_client *client)
{
struct regmap_config regmap_config = { };
struct nvmem_config nvmem_config = { };
u32 byte_len, page_size, flags, addrw;
const struct at24_chip_data *cdata;
struct device *dev = &client->dev;
bool i2c_fn_i2c, i2c_fn_block;
unsigned int i, num_addresses;
struct at24_data *at24;
struct regmap *regmap;
bool writable;
u8 test_byte;
int err;
i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
i2c_fn_block = i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
cdata = at24_get_chip_data(dev);
if (IS_ERR(cdata))
return PTR_ERR(cdata);
err = device_property_read_u32(dev, "pagesize", &page_size);
if (err)
/*
* This is slow, but we can't know all eeproms, so we better
* play safe. Specifying custom eeprom-types via device tree
* or properties is recommended anyhow.
*/
page_size = 1;
flags = cdata->flags;
if (device_property_present(dev, "read-only"))
flags |= AT24_FLAG_READONLY;
if (device_property_present(dev, "no-read-rollover"))
flags |= AT24_FLAG_NO_RDROL;
err = device_property_read_u32(dev, "address-width", &addrw);
if (!err) {
switch (addrw) {
case 8:
if (flags & AT24_FLAG_ADDR16)
dev_warn(dev,
"Override address width to be 8, while default is 16\n");
flags &= ~AT24_FLAG_ADDR16;
break;
case 16:
flags |= AT24_FLAG_ADDR16;
break;
default:
dev_warn(dev, "Bad \"address-width\" property: %u\n",
addrw);
}
}
err = device_property_read_u32(dev, "size", &byte_len);
if (err)
byte_len = cdata->byte_len;
if (!i2c_fn_i2c && !i2c_fn_block)
page_size = 1;
if (!page_size) {
dev_err(dev, "page_size must not be 0!\n");
return -EINVAL;
}
if (!is_power_of_2(page_size))
dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
err = device_property_read_u32(dev, "num-addresses", &num_addresses);
if (err) {
if (flags & AT24_FLAG_TAKE8ADDR)
num_addresses = 8;
else
num_addresses = DIV_ROUND_UP(byte_len,
(flags & AT24_FLAG_ADDR16) ? 65536 : 256);
}
if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
dev_err(dev,
"invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
return -EINVAL;
}
regmap_config.val_bits = 8;
regmap_config.reg_bits = (flags & AT24_FLAG_ADDR16) ? 16 : 8;
regmap_config.disable_locking = true;
regmap = devm_regmap_init_i2c(client, ®map_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
at24 = devm_kzalloc(dev, struct_size(at24, client, num_addresses),
GFP_KERNEL);
if (!at24)
return -ENOMEM;
mutex_init(&at24->lock);
at24->byte_len = byte_len;
at24->page_size = page_size;
at24->flags = flags;
at24->read_post = cdata->read_post;
at24->num_addresses = num_addresses;
at24->offset_adj = at24_get_offset_adj(flags, byte_len);
at24->client[0].client = client;
at24->client[0].regmap = regmap;
at24->vcc_reg = devm_regulator_get(dev, "vcc");
if (IS_ERR(at24->vcc_reg))
return PTR_ERR(at24->vcc_reg);
writable = !(flags & AT24_FLAG_READONLY);
if (writable) {
at24->write_max = min_t(unsigned int,
page_size, at24_io_limit);
if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)
at24->write_max = I2C_SMBUS_BLOCK_MAX;
}
/* use dummy devices for multiple-address chips */
for (i = 1; i < num_addresses; i++) {
err = at24_make_dummy_client(at24, i, ®map_config);
if (err)
return err;
}
/*
* We initialize nvmem_config.id to NVMEM_DEVID_AUTO even if the
* label property is set as some platform can have multiple eeproms
* with same label and we can not register each of those with same
* label. Failing to register those eeproms trigger cascade failure
* on such platform.
*/
nvmem_config.id = NVMEM_DEVID_AUTO;
if (device_property_present(dev, "label")) {
err = device_property_read_string(dev, "label",
&nvmem_config.name);
if (err)
return err;
} else {
nvmem_config.name = dev_name(dev);
}
nvmem_config.type = NVMEM_TYPE_EEPROM;
nvmem_config.dev = dev;
nvmem_config.read_only = !writable;
nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO);
nvmem_config.owner = THIS_MODULE;
nvmem_config.compat = true;
nvmem_config.base_dev = dev;
nvmem_config.reg_read = at24_read;
nvmem_config.reg_write = at24_write;
nvmem_config.priv = at24;
nvmem_config.stride = 1;
nvmem_config.word_size = 1;
nvmem_config.size = byte_len;
i2c_set_clientdata(client, at24);
err = regulator_enable(at24->vcc_reg);
if (err) {
dev_err(dev, "Failed to enable vcc regulator\n");
return err;
}
/* enable runtime pm */
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
if (IS_ERR(at24->nvmem)) {
pm_runtime_disable(dev);
if (!pm_runtime_status_suspended(dev))
regulator_disable(at24->vcc_reg);
return PTR_ERR(at24->nvmem);
}
/*
* Perform a one-byte test read to verify that the
* chip is functional.
*/
err = at24_read(at24, 0, &test_byte, 1);
if (err) {
pm_runtime_disable(dev);
if (!pm_runtime_status_suspended(dev))
regulator_disable(at24->vcc_reg);
return -ENODEV;
}
pm_runtime_idle(dev);
if (writable)
dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/write\n",
byte_len, client->name, at24->write_max);
else
dev_info(dev, "%u byte %s EEPROM, read-only\n",
byte_len, client->name);
return 0;
}
static int at24_remove(struct i2c_client *client)
{
struct at24_data *at24 = i2c_get_clientdata(client);
pm_runtime_disable(&client->dev);
if (!pm_runtime_status_suspended(&client->dev))
regulator_disable(at24->vcc_reg);
pm_runtime_set_suspended(&client->dev);
return 0;
}
static int __maybe_unused at24_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct at24_data *at24 = i2c_get_clientdata(client);
return regulator_disable(at24->vcc_reg);
}
static int __maybe_unused at24_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct at24_data *at24 = i2c_get_clientdata(client);
return regulator_enable(at24->vcc_reg);
}
static const struct dev_pm_ops at24_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
pm_runtime_force_resume)
SET_RUNTIME_PM_OPS(at24_suspend, at24_resume, NULL)
};
static struct i2c_driver at24_driver = {
.driver = {
.name = "at24",
.pm = &at24_pm_ops,
.of_match_table = at24_of_match,
.acpi_match_table = ACPI_PTR(at24_acpi_ids),
},
.probe_new = at24_probe,
.remove = at24_remove,
.id_table = at24_ids,
};
static int __init at24_init(void)
{
if (!at24_io_limit) {
pr_err("at24: at24_io_limit must not be 0!\n");
return -EINVAL;
}
at24_io_limit = rounddown_pow_of_two(at24_io_limit);
return i2c_add_driver(&at24_driver);
}
module_init(at24_init);
static void __exit at24_exit(void)
{
i2c_del_driver(&at24_driver);
}
module_exit(at24_exit);
MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
MODULE_AUTHOR("David Brownell and Wolfram Sang");
MODULE_LICENSE("GPL");
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/EEPROM/install.sh | #!/usr/bin/env sh
# Install EEPROM driver
#
set -x
sudo cp i2c3.dtbo /boot/firmware/overlays/
make
make install
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Adafruit_GPIO/__init__.py | from __future__ import absolute_import
from Mangdang.Adafruit_GPIO.GPIO import *
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Adafruit_GPIO/Platform.py | # Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import platform
import re
# Platform identification constants.
UNKNOWN = 0
RASPBERRY_PI = 1
BEAGLEBONE_BLACK = 2
MINNOWBOARD = 3
JETSON_NANO = 4
def platform_detect():
"""Detect if running on the Raspberry Pi or Beaglebone Black and return the
platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN."""
# Handle Raspberry Pi
pi = pi_version()
if pi is not None:
return RASPBERRY_PI
# Handle Beaglebone Black
# TODO: Check the Beaglebone Black /proc/cpuinfo value instead of reading
# the platform.
plat = platform.platform()
if plat.lower().find('armv7l-with-debian') > -1:
return BEAGLEBONE_BLACK
elif plat.lower().find('armv7l-with-ubuntu') > -1:
return BEAGLEBONE_BLACK
elif plat.lower().find('armv7l-with-glibc2.4') > -1:
return BEAGLEBONE_BLACK
elif plat.lower().find('tegra-aarch64-with-ubuntu') > -1:
return JETSON_NANO
# Handle Minnowboard
# Assumption is that mraa is installed
try:
import mraa
if mraa.getPlatformName()=='MinnowBoard MAX':
return MINNOWBOARD
except ImportError:
pass
# Couldn't figure out the platform, just return unknown.
return UNKNOWN
def pi_revision():
"""Detect the revision number of a Raspberry Pi, useful for changing
functionality like default I2C bus based on revision."""
# Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History
with open('/proc/cpuinfo', 'r') as infile:
for line in infile:
# Match a line of the form "Revision : 0002" while ignoring extra
# info in front of the revsion (like 1000 when the Pi was over-volted).
match = re.match('Revision\s+:\s+.*(\w{4})$', line, flags=re.IGNORECASE)
if match and match.group(1) in ['0000', '0002', '0003']:
# Return revision 1 if revision ends with 0000, 0002 or 0003.
return 1
elif match:
# Assume revision 2 if revision ends with any other 4 chars.
return 2
# Couldn't find the revision, throw an exception.
raise RuntimeError('Could not determine Raspberry Pi revision.')
def pi_version():
"""Detect the version of the Raspberry Pi. Returns either 1, 2 or
None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+),
Raspberry Pi 2 (model B+), or not a Raspberry Pi.
"""
# Check /proc/cpuinfo for the Hardware field value.
# 2708 is pi 1
# 2709 is pi 2
# 2835 is pi 3 on 4.9.x kernel
# Anything else is not a pi.
with open('/proc/cpuinfo', 'r') as infile:
cpuinfo = infile.read()
# Match a line like 'Hardware : BCM2709'
match = re.search('^Hardware\s+:\s+(\w+)$', cpuinfo,
flags=re.MULTILINE | re.IGNORECASE)
if not match:
# Couldn't find the hardware, assume it isn't a pi.
return None
if match.group(1) == 'BCM2708':
# Pi 1
return 1
elif match.group(1) == 'BCM2709':
# Pi 2
return 2
elif match.group(1) == 'BCM2835':
# Pi 3 / Pi on 4.9.x kernel
return 3
else:
# Something else, not a pi.
return None
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Adafruit_GPIO/GPIO.py | # Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import Adafruit_GPIO.Platform as Platform
OUT = 0
IN = 1
HIGH = True
LOW = False
RISING = 1
FALLING = 2
BOTH = 3
PUD_OFF = 0
PUD_DOWN = 1
PUD_UP = 2
class BaseGPIO(object):
"""Base class for implementing simple digital IO for a platform.
Implementors are expected to subclass from this and provide an implementation
of the setup, output, and input functions."""
def setup(self, pin, mode, pull_up_down=PUD_OFF):
"""Set the input or output mode for a specified pin. Mode should be
either OUT or IN."""
raise NotImplementedError
def output(self, pin, value):
"""Set the specified pin the provided high/low value. Value should be
either HIGH/LOW or a boolean (true = high)."""
raise NotImplementedError
def input(self, pin):
"""Read the specified pin and return HIGH/true if the pin is pulled high,
or LOW/false if pulled low."""
raise NotImplementedError
def set_high(self, pin):
"""Set the specified pin HIGH."""
self.output(pin, HIGH)
def set_low(self, pin):
"""Set the specified pin LOW."""
self.output(pin, LOW)
def is_high(self, pin):
"""Return true if the specified pin is pulled high."""
return self.input(pin) == HIGH
def is_low(self, pin):
"""Return true if the specified pin is pulled low."""
return self.input(pin) == LOW
# Basic implementation of multiple pin methods just loops through pins and
# processes each one individually. This is not optimal, but derived classes can
# provide a more optimal implementation that deals with groups of pins
# simultaneously.
# See MCP230xx or PCF8574 classes for examples of optimized implementations.
def output_pins(self, pins):
"""Set multiple pins high or low at once. Pins should be a dict of pin
name to pin value (HIGH/True for 1, LOW/False for 0). All provided pins
will be set to the given values.
"""
# General implementation just loops through pins and writes them out
# manually. This is not optimized, but subclasses can choose to implement
# a more optimal batch output implementation. See the MCP230xx class for
# example of optimized implementation.
for pin, value in iter(pins.items()):
self.output(pin, value)
def setup_pins(self, pins):
"""Setup multiple pins as inputs or outputs at once. Pins should be a
dict of pin name to pin type (IN or OUT).
"""
# General implementation that can be optimized by derived classes.
for pin, value in iter(pins.items()):
self.setup(pin, value)
def input_pins(self, pins):
"""Read multiple pins specified in the given list and return list of pin values
GPIO.HIGH/True if the pin is pulled high, or GPIO.LOW/False if pulled low.
"""
# General implementation that can be optimized by derived classes.
return [self.input(pin) for pin in pins]
def add_event_detect(self, pin, edge):
"""Enable edge detection events for a particular GPIO channel. Pin
should be type IN. Edge must be RISING, FALLING or BOTH.
"""
raise NotImplementedError
def remove_event_detect(self, pin):
"""Remove edge detection for a particular GPIO channel. Pin should be
type IN.
"""
raise NotImplementedError
def add_event_callback(self, pin, callback):
"""Add a callback for an event already defined using add_event_detect().
Pin should be type IN.
"""
raise NotImplementedError
def event_detected(self, pin):
"""Returns True if an edge has occured on a given GPIO. You need to
enable edge detection using add_event_detect() first. Pin should be
type IN.
"""
raise NotImplementedError
def wait_for_edge(self, pin, edge):
"""Wait for an edge. Pin should be type IN. Edge must be RISING,
FALLING or BOTH."""
raise NotImplementedError
def cleanup(self, pin=None):
"""Clean up GPIO event detection for specific pin, or all pins if none
is specified.
"""
raise NotImplementedError
# helper functions useful to derived classes
def _validate_pin(self, pin):
# Raise an exception if pin is outside the range of allowed values.
if pin < 0 or pin >= self.NUM_GPIO:
raise ValueError('Invalid GPIO value, must be between 0 and {0}.'.format(self.NUM_GPIO))
def _bit2(self, src, bit, val):
bit = 1 << bit
return (src | bit) if val else (src & ~bit)
class RPiGPIOAdapter(BaseGPIO):
"""GPIO implementation for the Raspberry Pi using the RPi.GPIO library."""
def __init__(self, rpi_gpio, mode=None):
self.rpi_gpio = rpi_gpio
# Suppress warnings about GPIO in use.
rpi_gpio.setwarnings(False)
# Setup board pin mode.
if mode == rpi_gpio.BOARD or mode == rpi_gpio.BCM:
rpi_gpio.setmode(mode)
elif mode is not None:
raise ValueError('Unexpected value for mode. Must be BOARD or BCM.')
else:
# Default to BCM numbering if not told otherwise.
rpi_gpio.setmode(rpi_gpio.BCM)
# Define mapping of Adafruit GPIO library constants to RPi.GPIO constants.
self._dir_mapping = { OUT: rpi_gpio.OUT,
IN: rpi_gpio.IN }
self._pud_mapping = { PUD_OFF: rpi_gpio.PUD_OFF,
PUD_DOWN: rpi_gpio.PUD_DOWN,
PUD_UP: rpi_gpio.PUD_UP }
self._edge_mapping = { RISING: rpi_gpio.RISING,
FALLING: rpi_gpio.FALLING,
BOTH: rpi_gpio.BOTH }
def setup(self, pin, mode, pull_up_down=PUD_OFF):
"""Set the input or output mode for a specified pin. Mode should be
either OUTPUT or INPUT.
"""
self.rpi_gpio.setup(pin, self._dir_mapping[mode],
pull_up_down=self._pud_mapping[pull_up_down])
def output(self, pin, value):
"""Set the specified pin the provided high/low value. Value should be
either HIGH/LOW or a boolean (true = high).
"""
self.rpi_gpio.output(pin, value)
def input(self, pin):
"""Read the specified pin and return HIGH/true if the pin is pulled high,
or LOW/false if pulled low.
"""
return self.rpi_gpio.input(pin)
def input_pins(self, pins):
"""Read multiple pins specified in the given list and return list of pin values
GPIO.HIGH/True if the pin is pulled high, or GPIO.LOW/False if pulled low.
"""
# maybe rpi has a mass read... it would be more efficient to use it if it exists
return [self.rpi_gpio.input(pin) for pin in pins]
def add_event_detect(self, pin, edge, callback=None, bouncetime=-1):
"""Enable edge detection events for a particular GPIO channel. Pin
should be type IN. Edge must be RISING, FALLING or BOTH. Callback is a
function for the event. Bouncetime is switch bounce timeout in ms for
callback
"""
kwargs = {}
if callback:
kwargs['callback']=callback
if bouncetime > 0:
kwargs['bouncetime']=bouncetime
self.rpi_gpio.add_event_detect(pin, self._edge_mapping[edge], **kwargs)
def remove_event_detect(self, pin):
"""Remove edge detection for a particular GPIO channel. Pin should be
type IN.
"""
self.rpi_gpio.remove_event_detect(pin)
def add_event_callback(self, pin, callback):
"""Add a callback for an event already defined using add_event_detect().
Pin should be type IN.
"""
self.rpi_gpio.add_event_callback(pin, callback)
def event_detected(self, pin):
"""Returns True if an edge has occured on a given GPIO. You need to
enable edge detection using add_event_detect() first. Pin should be
type IN.
"""
return self.rpi_gpio.event_detected(pin)
def wait_for_edge(self, pin, edge):
"""Wait for an edge. Pin should be type IN. Edge must be RISING,
FALLING or BOTH.
"""
self.rpi_gpio.wait_for_edge(pin, self._edge_mapping[edge])
def cleanup(self, pin=None):
"""Clean up GPIO event detection for specific pin, or all pins if none
is specified.
"""
if pin is None:
self.rpi_gpio.cleanup()
else:
self.rpi_gpio.cleanup(pin)
class AdafruitBBIOAdapter(BaseGPIO):
"""GPIO implementation for the Beaglebone Black using the Adafruit_BBIO
library.
"""
def __init__(self, bbio_gpio):
self.bbio_gpio = bbio_gpio
# Define mapping of Adafruit GPIO library constants to RPi.GPIO constants.
self._dir_mapping = { OUT: bbio_gpio.OUT,
IN: bbio_gpio.IN }
self._pud_mapping = { PUD_OFF: bbio_gpio.PUD_OFF,
PUD_DOWN: bbio_gpio.PUD_DOWN,
PUD_UP: bbio_gpio.PUD_UP }
self._edge_mapping = { RISING: bbio_gpio.RISING,
FALLING: bbio_gpio.FALLING,
BOTH: bbio_gpio.BOTH }
def setup(self, pin, mode, pull_up_down=PUD_OFF):
"""Set the input or output mode for a specified pin. Mode should be
either OUTPUT or INPUT.
"""
self.bbio_gpio.setup(pin, self._dir_mapping[mode],
pull_up_down=self._pud_mapping[pull_up_down])
def output(self, pin, value):
"""Set the specified pin the provided high/low value. Value should be
either HIGH/LOW or a boolean (true = high).
"""
self.bbio_gpio.output(pin, value)
def input(self, pin):
"""Read the specified pin and return HIGH/true if the pin is pulled high,
or LOW/false if pulled low.
"""
return self.bbio_gpio.input(pin)
def input_pins(self, pins):
"""Read multiple pins specified in the given list and return list of pin values
GPIO.HIGH/True if the pin is pulled high, or GPIO.LOW/False if pulled low.
"""
# maybe bbb has a mass read... it would be more efficient to use it if it exists
return [self.bbio_gpio.input(pin) for pin in pins]
def add_event_detect(self, pin, edge, callback=None, bouncetime=-1):
"""Enable edge detection events for a particular GPIO channel. Pin
should be type IN. Edge must be RISING, FALLING or BOTH. Callback is a
function for the event. Bouncetime is switch bounce timeout in ms for
callback
"""
kwargs = {}
if callback:
kwargs['callback']=callback
if bouncetime > 0:
kwargs['bouncetime']=bouncetime
self.bbio_gpio.add_event_detect(pin, self._edge_mapping[edge], **kwargs)
def remove_event_detect(self, pin):
"""Remove edge detection for a particular GPIO channel. Pin should be
type IN.
"""
self.bbio_gpio.remove_event_detect(pin)
def add_event_callback(self, pin, callback, bouncetime=-1):
"""Add a callback for an event already defined using add_event_detect().
Pin should be type IN. Bouncetime is switch bounce timeout in ms for
callback
"""
kwargs = {}
if bouncetime > 0:
kwargs['bouncetime']=bouncetime
self.bbio_gpio.add_event_callback(pin, callback, **kwargs)
def event_detected(self, pin):
"""Returns True if an edge has occured on a given GPIO. You need to
enable edge detection using add_event_detect() first. Pin should be
type IN.
"""
return self.bbio_gpio.event_detected(pin)
def wait_for_edge(self, pin, edge):
"""Wait for an edge. Pin should be type IN. Edge must be RISING,
FALLING or BOTH.
"""
self.bbio_gpio.wait_for_edge(pin, self._edge_mapping[edge])
def cleanup(self, pin=None):
"""Clean up GPIO event detection for specific pin, or all pins if none
is specified.
"""
if pin is None:
self.bbio_gpio.cleanup()
else:
self.bbio_gpio.cleanup(pin)
class AdafruitMinnowAdapter(BaseGPIO):
"""GPIO implementation for the Minnowboard + MAX using the mraa library"""
def __init__(self,mraa_gpio):
self.mraa_gpio = mraa_gpio
# Define mapping of Adafruit GPIO library constants to mraa constants
self._dir_mapping = { OUT: self.mraa_gpio.DIR_OUT,
IN: self.mraa_gpio.DIR_IN }
self._pud_mapping = { PUD_OFF: self.mraa_gpio.MODE_STRONG,
PUD_UP: self.mraa_gpio.MODE_HIZ,
PUD_DOWN: self.mraa_gpio.MODE_PULLDOWN }
self._edge_mapping = { RISING: self.mraa_gpio.EDGE_RISING,
FALLING: self.mraa_gpio.EDGE_FALLING,
BOTH: self.mraa_gpio.EDGE_BOTH }
def setup(self,pin,mode):
"""Set the input or output mode for a specified pin. Mode should be
either DIR_IN or DIR_OUT.
"""
self.mraa_gpio.Gpio.dir(self.mraa_gpio.Gpio(pin),self._dir_mapping[mode])
def output(self,pin,value):
"""Set the specified pin the provided high/low value. Value should be
either 1 (ON or HIGH), or 0 (OFF or LOW) or a boolean.
"""
self.mraa_gpio.Gpio.write(self.mraa_gpio.Gpio(pin), value)
def input(self,pin):
"""Read the specified pin and return HIGH/true if the pin is pulled high,
or LOW/false if pulled low.
"""
return self.mraa_gpio.Gpio.read(self.mraa_gpio.Gpio(pin))
def add_event_detect(self, pin, edge, callback=None, bouncetime=-1):
"""Enable edge detection events for a particular GPIO channel. Pin
should be type IN. Edge must be RISING, FALLING or BOTH. Callback is a
function for the event. Bouncetime is switch bounce timeout in ms for
callback
"""
kwargs = {}
if callback:
kwargs['callback']=callback
if bouncetime > 0:
kwargs['bouncetime']=bouncetime
self.mraa_gpio.Gpio.isr(self.mraa_gpio.Gpio(pin), self._edge_mapping[edge], **kwargs)
def remove_event_detect(self, pin):
"""Remove edge detection for a particular GPIO channel. Pin should be
type IN.
"""
self.mraa_gpio.Gpio.isrExit(self.mraa_gpio.Gpio(pin))
def wait_for_edge(self, pin, edge):
"""Wait for an edge. Pin should be type IN. Edge must be RISING,
FALLING or BOTH.
"""
self.bbio_gpio.wait_for_edge(self.mraa_gpio.Gpio(pin), self._edge_mapping[edge])
def get_platform_gpio(**keywords):
"""Attempt to return a GPIO instance for the platform which the code is being
executed on. Currently supports only the Raspberry Pi using the RPi.GPIO
library and Beaglebone Black using the Adafruit_BBIO library. Will throw an
exception if a GPIO instance can't be created for the current platform. The
returned GPIO object is an instance of BaseGPIO.
"""
plat = Platform.platform_detect()
if plat == Platform.RASPBERRY_PI:
import RPi.GPIO
return RPiGPIOAdapter(RPi.GPIO, **keywords)
elif plat == Platform.BEAGLEBONE_BLACK:
import Adafruit_BBIO.GPIO
return AdafruitBBIOAdapter(Adafruit_BBIO.GPIO, **keywords)
elif plat == Platform.MINNOWBOARD:
import mraa
return AdafruitMinnowAdapter(mraa, **keywords)
elif plat == Platform.JETSON_NANO:
import Jetson.GPIO
return RPiGPIOAdapter(Jetson.GPIO, **keywords)
elif plat == Platform.UNKNOWN:
raise RuntimeError('Could not determine platform.')
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/Adafruit_GPIO/SPI.py | # Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import operator
import time
import Mangdang.Adafruit_GPIO as GPIO
MSBFIRST = 0
LSBFIRST = 1
class SpiDev(object):
"""Hardware-based SPI implementation using the spidev interface."""
def __init__(self, port, device, max_speed_hz=500000):
"""Initialize an SPI device using the SPIdev interface. Port and device
identify the device, for example the device /dev/spidev1.0 would be port
1 and device 0.
"""
import spidev
self._device = spidev.SpiDev()
self._device.open(port, device)
self._device.max_speed_hz=max_speed_hz
# Default to mode 0, and make sure CS is active low.
self._device.mode = 0
#self._device.cshigh = False
def set_clock_hz(self, hz):
"""Set the speed of the SPI clock in hertz. Note that not all speeds
are supported and a lower speed might be chosen by the hardware.
"""
self._device.max_speed_hz=hz
def set_mode(self, mode):
"""Set SPI mode which controls clock polarity and phase. Should be a
numeric value 0, 1, 2, or 3. See wikipedia page for details on meaning:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
"""
if mode < 0 or mode > 3:
raise ValueError('Mode must be a value 0, 1, 2, or 3.')
self._device.mode = mode
def set_bit_order(self, order):
"""Set order of bits to be read/written over serial lines. Should be
either MSBFIRST for most-significant first, or LSBFIRST for
least-signifcant first.
"""
if order == MSBFIRST:
self._device.lsbfirst = False
elif order == LSBFIRST:
self._device.lsbfirst = True
else:
raise ValueError('Order must be MSBFIRST or LSBFIRST.')
def close(self):
"""Close communication with the SPI device."""
self._device.close()
def write(self, data):
"""Half-duplex SPI write. The specified array of bytes will be clocked
out the MOSI line.
"""
self._device.writebytes(data)
def read(self, length):
"""Half-duplex SPI read. The specified length of bytes will be clocked
in the MISO line and returned as a bytearray object.
"""
return bytearray(self._device.readbytes(length))
def transfer(self, data):
"""Full-duplex SPI read and write. The specified array of bytes will be
clocked out the MOSI line, while simultaneously bytes will be read from
the MISO line. Read bytes will be returned as a bytearray object.
"""
return bytearray(self._device.xfer2(data))
class SpiDevMraa(object):
"""Hardware SPI implementation with the mraa library on Minnowboard"""
def __init__(self, port, device, max_speed_hz=500000):
import mraa
self._device = mraa.Spi(0)
self._device.mode(0)
def set_clock_hz(self, hz):
"""Set the speed of the SPI clock in hertz. Note that not all speeds
are supported and a lower speed might be chosen by the hardware.
"""
self._device.frequency(hz)
def set_mode(self,mode):
"""Set SPI mode which controls clock polarity and phase. Should be a
numeric value 0, 1, 2, or 3. See wikipedia page for details on meaning:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
"""
if mode < 0 or mode > 3:
raise ValueError('Mode must be a value 0, 1, 2, or 3.')
self._device.mode(mode)
def set_bit_order(self, order):
"""Set order of bits to be read/written over serial lines. Should be
either MSBFIRST for most-significant first, or LSBFIRST for
least-signifcant first.
"""
if order == MSBFIRST:
self._device.lsbmode(False)
elif order == LSBFIRST:
self._device.lsbmode(True)
else:
raise ValueError('Order must be MSBFIRST or LSBFIRST.')
def close(self):
"""Close communication with the SPI device."""
self._device.Spi()
def write(self, data):
"""Half-duplex SPI write. The specified array of bytes will be clocked
out the MOSI line.
"""
self._device.write(bytearray(data))
class BitBang(object):
"""Software-based implementation of the SPI protocol over GPIO pins."""
def __init__(self, gpio, sclk, mosi=None, miso=None, ss=None):
"""Initialize bit bang (or software) based SPI. Must provide a BaseGPIO
class, the SPI clock, and optionally MOSI, MISO, and SS (slave select)
pin numbers. If MOSI is set to None then writes will be disabled and fail
with an error, likewise for MISO reads will be disabled. If SS is set to
None then SS will not be asserted high/low by the library when
transfering data.
"""
self._gpio = gpio
self._sclk = sclk
self._mosi = mosi
self._miso = miso
self._ss = ss
# Set pins as outputs/inputs.
gpio.setup(sclk, GPIO.OUT)
if mosi is not None:
gpio.setup(mosi, GPIO.OUT)
if miso is not None:
gpio.setup(miso, GPIO.IN)
if ss is not None:
gpio.setup(ss, GPIO.OUT)
# Assert SS high to start with device communication off.
gpio.set_high(ss)
# Assume mode 0.
self.set_mode(0)
# Assume most significant bit first order.
self.set_bit_order(MSBFIRST)
def set_clock_hz(self, hz):
"""Set the speed of the SPI clock. This is unsupported with the bit
bang SPI class and will be ignored.
"""
pass
def set_mode(self, mode):
"""Set SPI mode which controls clock polarity and phase. Should be a
numeric value 0, 1, 2, or 3. See wikipedia page for details on meaning:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
"""
if mode < 0 or mode > 3:
raise ValueError('Mode must be a value 0, 1, 2, or 3.')
if mode & 0x02:
# Clock is normally high in mode 2 and 3.
self._clock_base = GPIO.HIGH
else:
# Clock is normally low in mode 0 and 1.
self._clock_base = GPIO.LOW
if mode & 0x01:
# Read on trailing edge in mode 1 and 3.
self._read_leading = False
else:
# Read on leading edge in mode 0 and 2.
self._read_leading = True
# Put clock into its base state.
self._gpio.output(self._sclk, self._clock_base)
def set_bit_order(self, order):
"""Set order of bits to be read/written over serial lines. Should be
either MSBFIRST for most-significant first, or LSBFIRST for
least-signifcant first.
"""
# Set self._mask to the bitmask which points at the appropriate bit to
# read or write, and appropriate left/right shift operator function for
# reading/writing.
if order == MSBFIRST:
self._mask = 0x80
self._write_shift = operator.lshift
self._read_shift = operator.rshift
elif order == LSBFIRST:
self._mask = 0x01
self._write_shift = operator.rshift
self._read_shift = operator.lshift
else:
raise ValueError('Order must be MSBFIRST or LSBFIRST.')
def close(self):
"""Close the SPI connection. Unused in the bit bang implementation."""
pass
def write(self, data, assert_ss=True, deassert_ss=True):
"""Half-duplex SPI write. If assert_ss is True, the SS line will be
asserted low, the specified bytes will be clocked out the MOSI line, and
if deassert_ss is True the SS line be put back high.
"""
# Fail MOSI is not specified.
if self._mosi is None:
raise RuntimeError('Write attempted with no MOSI pin specified.')
if assert_ss and self._ss is not None:
self._gpio.set_low(self._ss)
for byte in data:
for i in range(8):
# Write bit to MOSI.
if self._write_shift(byte, i) & self._mask:
self._gpio.set_high(self._mosi)
else:
self._gpio.set_low(self._mosi)
# Flip clock off base.
self._gpio.output(self._sclk, not self._clock_base)
# Return clock to base.
self._gpio.output(self._sclk, self._clock_base)
if deassert_ss and self._ss is not None:
self._gpio.set_high(self._ss)
def read(self, length, assert_ss=True, deassert_ss=True):
"""Half-duplex SPI read. If assert_ss is true, the SS line will be
asserted low, the specified length of bytes will be clocked in the MISO
line, and if deassert_ss is true the SS line will be put back high.
Bytes which are read will be returned as a bytearray object.
"""
if self._miso is None:
raise RuntimeError('Read attempted with no MISO pin specified.')
if assert_ss and self._ss is not None:
self._gpio.set_low(self._ss)
result = bytearray(length)
for i in range(length):
for j in range(8):
# Flip clock off base.
self._gpio.output(self._sclk, not self._clock_base)
# Handle read on leading edge of clock.
if self._read_leading:
if self._gpio.is_high(self._miso):
# Set bit to 1 at appropriate location.
result[i] |= self._read_shift(self._mask, j)
else:
# Set bit to 0 at appropriate location.
result[i] &= ~self._read_shift(self._mask, j)
# Return clock to base.
self._gpio.output(self._sclk, self._clock_base)
# Handle read on trailing edge of clock.
if not self._read_leading:
if self._gpio.is_high(self._miso):
# Set bit to 1 at appropriate location.
result[i] |= self._read_shift(self._mask, j)
else:
# Set bit to 0 at appropriate location.
result[i] &= ~self._read_shift(self._mask, j)
if deassert_ss and self._ss is not None:
self._gpio.set_high(self._ss)
return result
def transfer(self, data, assert_ss=True, deassert_ss=True):
"""Full-duplex SPI read and write. If assert_ss is true, the SS line
will be asserted low, the specified bytes will be clocked out the MOSI
line while bytes will also be read from the MISO line, and if
deassert_ss is true the SS line will be put back high. Bytes which are
read will be returned as a bytearray object.
"""
if self._mosi is None:
raise RuntimeError('Write attempted with no MOSI pin specified.')
if self._miso is None:
raise RuntimeError('Read attempted with no MISO pin specified.')
if assert_ss and self._ss is not None:
self._gpio.set_low(self._ss)
result = bytearray(len(data))
for i in range(len(data)):
for j in range(8):
# Write bit to MOSI.
if self._write_shift(data[i], j) & self._mask:
self._gpio.set_high(self._mosi)
else:
self._gpio.set_low(self._mosi)
# Flip clock off base.
self._gpio.output(self._sclk, not self._clock_base)
# Handle read on leading edge of clock.
if self._read_leading:
if self._gpio.is_high(self._miso):
# Set bit to 1 at appropriate location.
result[i] |= self._read_shift(self._mask, j)
else:
# Set bit to 0 at appropriate location.
result[i] &= ~self._read_shift(self._mask, j)
# Return clock to base.
self._gpio.output(self._sclk, self._clock_base)
# Handle read on trailing edge of clock.
if not self._read_leading:
if self._gpio.is_high(self._miso):
# Set bit to 1 at appropriate location.
result[i] |= self._read_shift(self._mask, j)
else:
# Set bit to 0 at appropriate location.
result[i] &= ~self._read_shift(self._mask, j)
if deassert_ss and self._ss is not None:
self._gpio.set_high(self._ss)
return result
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/FuelGauge/install.sh | #!/usr/bin/env sh
# Install FuelGauge driver and battery monitor daemon
#
set -x
sudo cp i2c4.dtbo /boot/firmware/overlays/
make clean
make
make install
sudo cp battery_monitor /usr/bin/
sudo cp battery_monitor.service /lib/systemd/system/
sudo systemctl enable battery_monitor.service
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/FuelGauge/max1720x_battery.c | /*
* Maxim MAX17201/MAX17205 fuel gauge driver
*
* Author: Mahir Ozturk <[email protected]>
* Copyright (C) 2019 Maxim Integrated
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This driver is based on max17042/40_battery.c
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/power_supply.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#define DRV_NAME "max1720x"
/* CONFIG register bits */
#define MAX1720X_CONFIG_ALRT_EN (1 << 2)
/* STATUS register bits */
#define MAX1720X_STATUS_BST (1 << 3)
#define MAX1720X_STATUS_POR (1 << 1)
/* STATUS interrupt status bits */
#define MAX1720X_STATUS_ALRT_CLR_MASK (0x88BB)
#define MAX1720X_STATUS_SOC_MAX_ALRT (1 << 14)
#define MAX1720X_STATUS_TEMP_MAX_ALRT (1 << 13)
#define MAX1720X_STATUS_VOLT_MAX_ALRT (1 << 12)
#define MAX1720X_STATUS_SOC_MIN_ALRT (1 << 10)
#define MAX1720X_STATUS_TEMP_MIN_ALRT (1 << 9)
#define MAX1720X_STATUS_VOLT_MIN_ALRT (1 << 8)
#define MAX1720X_STATUS_CURR_MAX_ALRT (1 << 6)
#define MAX1720X_STATUS_CURR_MIN_ALRT (1 << 2)
/* ProtStatus register bits */
#define MAX1730X_PROTSTATUS_CHGWDT (1 << 15)
#define MAX1730X_PROTSTATUS_TOOHOTC (1 << 14)
#define MAX1730X_PROTSTATUS_FULL (1 << 13)
#define MAX1730X_PROTSTATUS_TOOCOLDC (1 << 12)
#define MAX1730X_PROTSTATUS_OVP (1 << 11)
#define MAX1730X_PROTSTATUS_OCCP (1 << 10)
#define MAX1730X_PROTSTATUS_QOVFLW (1 << 9)
#define MAX1730X_PROTSTATUS_RESCFAULT (1 << 7)
#define MAX1730X_PROTSTATUS_PERMFAIL (1 << 6)
#define MAX1730X_PROTSTATUS_DIEHOT (1 << 5)
#define MAX1730X_PROTSTATUS_TOOHOTD (1 << 4)
#define MAX1730X_PROTSTATUS_UVP (1 << 3)
#define MAX1730X_PROTSTATUS_ODCP (1 << 2)
#define MAX1730X_PROTSTATUS_RESDFAULT (1 << 1)
#define MAX1730X_PROTSTATUS_SHDN (1 << 0)
#define MAX1720X_VMAX_TOLERANCE 50 /* 50 mV */
#define MODELGAUGE_DATA_I2C_ADDR 0x36
#define NONVOLATILE_DATA_I2C_ADDR 0x0B
struct max1720x_platform_data {
/*
* rsense in miliOhms.
* default 10 (if rsense = 0) as it is the recommended value by
* the datasheet although it can be changed by board designers.
*/
unsigned int rsense;
int volt_min; /* in mV */
int volt_max; /* in mV */
int temp_min; /* in DegreC */
int temp_max; /* in DegreeC */
int soc_max; /* in percent */
int soc_min; /* in percent */
int curr_max; /* in mA */
int curr_min; /* in mA */
};
struct max1720x_priv {
struct i2c_client *client;
struct device *dev;
struct regmap *regmap;
struct power_supply *battery;
struct max1720x_platform_data *pdata;
struct work_struct init_worker;
struct attribute_group *attr_grp;
const u8 *regs;
u8 nvmem_high_addr;
int cycles_reg_lsb_percent;
int (*get_charging_status)(void);
int (*get_battery_health)(struct max1720x_priv *priv, int *health);
};
enum chip_id {
ID_MAX1720X,
ID_MAX1730X,
};
enum register_ids {
STATUS_REG = 0,
VALRTTH_REG,
TALRTTH_REG,
SALRTTH_REG,
ATRATE_REG,
REPCAP_REG,
REPSOC_REG,
TEMP_REG,
VCELL_REG,
CURRENT_REG,
AVGCURRENT_REG,
TTE_REG ,
CYCLES_REG,
DESIGNCAP_REG,
AVGVCELL_REG,
MAXMINVOLT_REG,
CONFIG_REG,
TTF_REG ,
VERSION_REG,
FULLCAPREP_REG,
VEMPTY_REG,
QH_REG ,
IALRTTH_REG,
PROTSTATUS_REG,
ATTTE_REG,
VFOCV_REG,
};
static int max1720x_get_battery_health(struct max1720x_priv *priv, int *health);
static int max1730x_get_battery_health(struct max1720x_priv *priv, int *health);
static int (*get_battery_health_handlers[])
(struct max1720x_priv *priv, int *health) = {
[ID_MAX1720X] = max1720x_get_battery_health,
[ID_MAX1730X] = max1730x_get_battery_health,
};
/* Register addresses */
static const u8 max1720x_regs[] = {
[STATUS_REG] = 0x00,
[VALRTTH_REG] = 0x01,
[TALRTTH_REG] = 0x02,
[SALRTTH_REG] = 0x03,
[ATRATE_REG] = 0x04,
[REPCAP_REG] = 0x05,
[REPSOC_REG] = 0x06,
[TEMP_REG] = 0x08,
[VCELL_REG] = 0x09,
[CURRENT_REG] = 0x0A,
[AVGCURRENT_REG] = 0x0B,
[TTE_REG] = 0x11,
[CYCLES_REG] = 0x17,
[DESIGNCAP_REG] = 0x18,
[AVGVCELL_REG] = 0x19,
[MAXMINVOLT_REG] = 0x1B,
[CONFIG_REG] = 0x1D,
[TTF_REG] = 0x20,
[VERSION_REG] = 0x21,
[FULLCAPREP_REG] = 0x35,
[VEMPTY_REG] = 0x3A,
[QH_REG] = 0x4D,
[IALRTTH_REG] = 0xB4,
[ATTTE_REG] = 0xDD,
[VFOCV_REG] = 0xFB,
};
static const u8 max1730x_regs[] = {
[STATUS_REG] = 0x00,
[VALRTTH_REG] = 0x01,
[TALRTTH_REG] = 0x02,
[SALRTTH_REG] = 0x03,
[ATRATE_REG] = 0x04,
[REPCAP_REG] = 0x05,
[REPSOC_REG] = 0x06,
[TEMP_REG] = 0x1B,
[VCELL_REG] = 0x1A,
[CURRENT_REG] = 0x1C,
[AVGCURRENT_REG] = 0x1D,
[TTE_REG] = 0x11,
[CYCLES_REG] = 0x17,
[DESIGNCAP_REG] = 0x18,
[AVGVCELL_REG] = 0x19,
[MAXMINVOLT_REG] = 0x08,
[CONFIG_REG] = 0x1D,
[TTF_REG] = 0x20,
[VERSION_REG] = 0x21,
[FULLCAPREP_REG] = 0x10,
[VEMPTY_REG] = 0x3A,
[QH_REG] = 0x4D,
[IALRTTH_REG] = 0xAC,
[PROTSTATUS_REG] = 0xD9,
[ATTTE_REG] = 0xDD,
[VFOCV_REG] = 0xFB,
};
static const u8* chip_regs[] = {
[ID_MAX1720X] = max1720x_regs,
[ID_MAX1730X] = max1730x_regs,
};
static const u8 nvmem_high_addrs[] = {
[ID_MAX1720X] = 0xDF,
[ID_MAX1730X] = 0xEF,
};
static const int cycles_reg_lsb_percents[] = {
[ID_MAX1720X] = 25,
[ID_MAX1730X] = 16,
};
static enum power_supply_property max1720x_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_VOLTAGE_MAX,
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_VOLTAGE_AVG,
POWER_SUPPLY_PROP_VOLTAGE_OCV,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN,
POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CURRENT_AVG,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
};
static inline int max1720x_raw_voltage_to_uvolts(struct max1720x_priv *priv,
int lsb)
{
return lsb * 10000 / 65536; /* 78.125uV per bit */
}
static inline int max1720x_raw_current_to_uamps(struct max1720x_priv *priv,
int curr)
{
return curr * 15625 / ((int)priv->pdata->rsense * 10);
}
static inline int max1720x_raw_capacity_to_uamph(struct max1720x_priv *priv,
int cap)
{
return cap * 5000 / (int)priv->pdata->rsense;
}
static ssize_t max1720x_log_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct max1720x_priv *priv = dev_get_drvdata(dev);
int rc = 0, reg = 0;
u32 val = 0;
for (reg = 0; reg < 0xE0; reg++) {
regmap_read(priv->regmap, reg, &val);
rc += (int)snprintf(buf+rc, PAGE_SIZE-rc, "0x%04X,", val);
if (reg == 0x4F)
reg += 0x60;
if (reg == 0xBF)
reg += 0x10;
}
rc += (int)snprintf(buf+rc, PAGE_SIZE-rc, "\n");
return rc;
}
static ssize_t max1720x_nvmem_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct max1720x_priv *priv = dev_get_drvdata(dev);
int rc = 0, reg = 0;
u32 val = 0;
int ret;
int i;
/*
* Device has a separate slave address for accessing non-volatile memory
* region, so we are temporarily changing i2c client address.
*/
priv->client->addr = NONVOLATILE_DATA_I2C_ADDR;
for (reg = 0x80; reg < priv->nvmem_high_addr; reg += 16) {
rc += snprintf(buf+rc, PAGE_SIZE-rc, "Page %02Xh: ",
(reg + 0x100) >> 4);
for (i = 0; i < 16; i++) {
ret = regmap_read(priv->regmap, reg + i, &val);
if (ret) {
dev_err(dev, "NV memory reading failed (%d)\n",
ret);
return 0;
}
rc += snprintf(buf+rc, PAGE_SIZE-rc, "0x%04X ", val);
}
rc += snprintf(buf+rc, PAGE_SIZE-rc, "\n");
}
priv->client->addr = MODELGAUGE_DATA_I2C_ADDR;
return rc;
}
static ssize_t max1720x_atrate_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct max1720x_priv *priv = dev_get_drvdata(dev);
u32 val = 0;
int ret;
ret = regmap_read(priv->regmap, priv->regs[ATRATE_REG], &val);
if (ret) {
return 0;
}
return sprintf(buf, "%d", (short)val);
}
static ssize_t max1720x_atrate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct max1720x_priv *priv = dev_get_drvdata(dev);
s32 val = 0;
int ret;
if (kstrtos32(buf, 0, &val))
return -EINVAL;
ret = regmap_write(priv->regmap, priv->regs[ATRATE_REG], val);
if (ret < 0)
return ret;
return count;
}
static ssize_t max1720x_attte_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct max1720x_priv *priv = dev_get_drvdata(dev);
u32 val = 0;
int ret;
ret = regmap_read(priv->regmap, priv->regs[ATTTE_REG], &val);
if (ret) {
return 0;
}
return sprintf(buf, "%d", (short)val);
}
static DEVICE_ATTR(log, S_IRUGO, max1720x_log_show, NULL);
static DEVICE_ATTR(nvmem, S_IRUGO, max1720x_nvmem_show, NULL);
static DEVICE_ATTR(atrate, S_IRUGO | S_IWUSR, max1720x_atrate_show,
max1720x_atrate_store);
static DEVICE_ATTR(attte, S_IRUGO, max1720x_attte_show, NULL);
static struct attribute *max1720x_attr[] = {
&dev_attr_log.attr,
&dev_attr_nvmem.attr,
&dev_attr_atrate.attr,
&dev_attr_attte.attr,
NULL
};
static struct attribute_group max1720x_attr_group = {
.attrs = max1720x_attr,
};
static int max1720x_get_temperature(struct max1720x_priv *priv, int *temp)
{
int ret;
u32 data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[TEMP_REG], &data);
if (ret < 0)
return ret;
*temp = sign_extend32(data, 15);
/* The value is converted into centigrade scale */
/* Units of LSB = 1 / 256 degree Celsius */
*temp = (*temp * 10) >> 8;
return 0;
}
static int max1720x_set_temp_lower_limit(struct max1720x_priv *priv,
int temp)
{
int ret;
u32 data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[TALRTTH_REG], &data);
if (ret < 0)
return ret;
/* Input in deci-centigrade, convert to centigrade */
temp /= 10;
data &= 0xFF00;
data |= (temp & 0xFF);
ret = regmap_write(map, priv->regs[TALRTTH_REG], data);
if (ret < 0)
return ret;
return 0;
}
static int max1720x_get_temperature_alert_min(struct max1720x_priv *priv,
int *temp)
{
int ret;
u32 data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[TALRTTH_REG], &data);
if (ret < 0)
return ret;
/* Convert 1DegreeC LSB to 0.1DegreeC LSB */
*temp = sign_extend32(data & 0xff, 7) * 10;
return 0;
}
static int max1720x_set_temp_upper_limit(struct max1720x_priv *priv,
int temp)
{
int ret;
u32 data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[TALRTTH_REG], &data);
if (ret < 0)
return ret;
/* Input in deci-centigrade, convert to centigrade */
temp /= 10;
data &= 0xFF;
data |= ((temp << 8) & 0xFF00);
ret = regmap_write(map, priv->regs[TALRTTH_REG], data);
if (ret < 0)
return ret;
return 0;
}
static int max1720x_get_temperature_alert_max(struct max1720x_priv *priv,
int *temp)
{
int ret;
u32 data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[TALRTTH_REG], &data);
if (ret < 0)
return ret;
/* Convert 1DegreeC LSB to 0.1DegreeC LSB */
*temp = sign_extend32(data >> 8, 7) * 10;
return 0;
}
static int max1720x_get_battery_health(struct max1720x_priv *priv, int *health)
{
int temp, vavg, vbatt, ret;
u32 val;
ret = regmap_read(priv->regmap, priv->regs[AVGVCELL_REG], &val);
if (ret < 0)
goto health_error;
/* bits [0-3] unused */
vavg = max1720x_raw_voltage_to_uvolts(priv, val);
/* Convert to millivolts */
vavg /= 1000;
ret = regmap_read(priv->regmap, priv->regs[VCELL_REG], &val);
if (ret < 0)
goto health_error;
/* bits [0-3] unused */
vbatt = max1720x_raw_voltage_to_uvolts(priv, val);
/* Convert to millivolts */
vbatt /= 1000;
if (vavg < priv->pdata->volt_min) {
*health = POWER_SUPPLY_HEALTH_DEAD;
goto out;
}
if (vbatt > priv->pdata->volt_max + MAX1720X_VMAX_TOLERANCE) {
*health = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
goto out;
}
ret = max1720x_get_temperature(priv, &temp);
if (ret < 0)
goto health_error;
if (temp <= priv->pdata->temp_min) {
*health = POWER_SUPPLY_HEALTH_COLD;
goto out;
}
if (temp >= priv->pdata->temp_max) {
*health = POWER_SUPPLY_HEALTH_OVERHEAT;
goto out;
}
*health = POWER_SUPPLY_HEALTH_GOOD;
out:
return 0;
health_error:
return ret;
}
static int max1730x_get_battery_health(struct max1720x_priv *priv, int *health)
{
int ret;
u32 val;
ret = regmap_read(priv->regmap, priv->regs[PROTSTATUS_REG], &val);
if (ret < 0)
return ret;
if ((val & MAX1730X_PROTSTATUS_RESCFAULT) ||
(val & MAX1730X_PROTSTATUS_RESDFAULT)) {
*health = POWER_SUPPLY_HEALTH_UNKNOWN;
} else if ((val & MAX1730X_PROTSTATUS_TOOHOTC) ||
(val & MAX1730X_PROTSTATUS_TOOHOTD) ||
(val & MAX1730X_PROTSTATUS_DIEHOT)) {
*health = POWER_SUPPLY_HEALTH_OVERHEAT;
} else if ((val & MAX1730X_PROTSTATUS_UVP) ||
(val & MAX1730X_PROTSTATUS_PERMFAIL) ||
(val & MAX1730X_PROTSTATUS_SHDN)) {
*health = POWER_SUPPLY_HEALTH_DEAD;
} else if (val & MAX1730X_PROTSTATUS_TOOCOLDC) {
*health = POWER_SUPPLY_HEALTH_COLD;
} else if (val & MAX1730X_PROTSTATUS_OVP) {
*health = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
} else if ((val & MAX1730X_PROTSTATUS_QOVFLW) ||
(val & MAX1730X_PROTSTATUS_OCCP) ||
(val & MAX1730X_PROTSTATUS_ODCP)) {
*health = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
} else if (val & MAX1730X_PROTSTATUS_CHGWDT) {
*health = POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE;
} else {
*health = POWER_SUPPLY_HEALTH_GOOD;
}
return 0;
}
static int max1720x_get_min_capacity_alert_th(struct max1720x_priv *priv,
unsigned int *th)
{
int ret;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[SALRTTH_REG], th);
if (ret < 0)
return ret;
*th &= 0xFF;
return 0;
}
static int max1720x_set_min_capacity_alert_th(struct max1720x_priv *priv,
unsigned int th)
{
int ret;
unsigned int data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[SALRTTH_REG], &data);
if (ret < 0)
return ret;
data &= 0xFF00;
data |= (th & 0xFF);
ret = regmap_write(map, priv->regs[SALRTTH_REG], data);
if (ret < 0)
return ret;
return 0;
}
static int max1720x_get_max_capacity_alert_th(struct max1720x_priv *priv,
unsigned int *th)
{
int ret;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[SALRTTH_REG], th);
if (ret < 0)
return ret;
*th >>= 8;
return 0;
}
static int max1720x_set_max_capacity_alert_th(struct max1720x_priv *priv,
unsigned int th)
{
int ret;
unsigned int data;
struct regmap *map = priv->regmap;
ret = regmap_read(map, priv->regs[SALRTTH_REG], &data);
if (ret < 0)
return ret;
data &= 0xFF;
data |= ((th & 0xFF) << 8);
ret = regmap_write(map, priv->regs[SALRTTH_REG], data);
if (ret < 0)
return ret;
return 0;
}
static int max1720x_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct max1720x_priv *priv = power_supply_get_drvdata(psy);
struct regmap *regmap = priv->regmap;
struct max1720x_platform_data *pdata = priv->pdata;
unsigned int reg;
int ret;
switch (psp) {
case POWER_SUPPLY_PROP_PRESENT:
ret = regmap_read(regmap, priv->regs[STATUS_REG], ®);
if (ret < 0)
return ret;
if (reg & MAX1720X_STATUS_BST)
val->intval = 0;
else
val->intval = 1;
break;
case POWER_SUPPLY_PROP_CYCLE_COUNT:
ret = regmap_read(regmap, priv->regs[CYCLES_REG], ®);
if (ret < 0)
return ret;
val->intval = reg * 100 / priv->cycles_reg_lsb_percent;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
ret = regmap_read(regmap, priv->regs[MAXMINVOLT_REG], ®);
if (ret < 0)
return ret;
val->intval = reg >> 8;
val->intval *= 20000; /* Units of LSB = 20mV */
break;
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
ret = regmap_read(regmap, priv->regs[VEMPTY_REG], ®);
if (ret < 0)
return ret;
val->intval = reg >> 7;
val->intval *= 10000; /* Units of LSB = 10mV */
break;
case POWER_SUPPLY_PROP_STATUS:
if (pdata && priv->get_charging_status)
val->intval = priv->get_charging_status();
else
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
ret = regmap_read(regmap, priv->regs[VCELL_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_voltage_to_uvolts(priv, reg);
break;
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
ret = regmap_read(regmap, priv->regs[AVGVCELL_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_voltage_to_uvolts(priv, reg);
break;
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
ret = regmap_read(regmap, priv->regs[VFOCV_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_voltage_to_uvolts(priv, reg);
break;
case POWER_SUPPLY_PROP_CAPACITY:
ret = regmap_read(regmap, priv->regs[REPSOC_REG], ®);
if (ret < 0)
return ret;
val->intval = reg >> 8; /* RepSOC LSB: 1/256 % */
break;
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
ret = max1720x_get_min_capacity_alert_th(priv, &val->intval);
if (ret < 0)
return ret;
break;
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX:
ret = max1720x_get_max_capacity_alert_th(priv, &val->intval);
if (ret < 0)
return ret;
break;
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
ret = regmap_read(regmap, priv->regs[DESIGNCAP_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_capacity_to_uamph(priv, reg);
break;
case POWER_SUPPLY_PROP_CHARGE_FULL:
ret = regmap_read(regmap, priv->regs[FULLCAPREP_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_capacity_to_uamph(priv, reg);
break;
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
ret = regmap_read(regmap, priv->regs[QH_REG], ®);
if (ret < 0)
return ret;
/* This register is signed as oppose to other capacity type
* registers.
*/
val->intval = max1720x_raw_capacity_to_uamph(priv,
sign_extend32(reg, 15));
break;
case POWER_SUPPLY_PROP_CHARGE_NOW:
ret = regmap_read(regmap, priv->regs[REPCAP_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_capacity_to_uamph(priv, reg);
break;
case POWER_SUPPLY_PROP_TEMP:
ret = max1720x_get_temperature(priv, &val->intval);
if (ret < 0)
return ret;
break;
case POWER_SUPPLY_PROP_TEMP_ALERT_MIN:
ret = max1720x_get_temperature_alert_min(priv, &val->intval);
if (ret < 0)
return ret;
break;
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
ret = max1720x_get_temperature_alert_max(priv, &val->intval);
if (ret < 0)
return ret;
break;
case POWER_SUPPLY_PROP_HEALTH:
if (priv->get_battery_health != 0) {
ret = priv->get_battery_health(priv, &val->intval);
if (ret < 0)
return ret;
} else {
val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
}
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
ret = regmap_read(regmap, priv->regs[CURRENT_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_current_to_uamps(priv, sign_extend32(reg, 15));
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
ret = regmap_read(regmap, priv->regs[AVGCURRENT_REG], ®);
if (ret < 0)
return ret;
val->intval = max1720x_raw_current_to_uamps(priv, sign_extend32(reg, 15));
break;
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
ret = regmap_read(regmap, priv->regs[TTE_REG], ®);
if (ret < 0)
return ret;
val->intval = (reg * 45) >> 3; /* TTE LSB: 5.625 sec */
break;
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
ret = regmap_read(regmap, priv->regs[TTF_REG], ®);
if (ret < 0)
return ret;
val->intval = (reg * 45) >> 3; /* TTF LSB: 5.625 sec */
break;
default:
return -EINVAL;
}
return 0;
}
static int max1720x_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{
struct max1720x_priv *priv = power_supply_get_drvdata(psy);
int ret = 0;
switch (psp) {
case POWER_SUPPLY_PROP_TEMP_ALERT_MIN:
ret = max1720x_set_temp_lower_limit(priv, val->intval);
if (ret < 0)
dev_err(priv->dev, "temp alert min set fail:%d\n",
ret);
break;
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
ret = max1720x_set_temp_upper_limit(priv, val->intval);
if (ret < 0)
dev_err(priv->dev, "temp alert max set fail:%d\n",
ret);
break;
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
ret = max1720x_set_min_capacity_alert_th(priv, val->intval);
if (ret < 0)
dev_err(priv->dev, "capacity alert min set fail:%d\n",
ret);
break;
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX:
ret = max1720x_set_max_capacity_alert_th(priv, val->intval);
if (ret < 0)
dev_err(priv->dev, "capacity alert max set fail:%d\n",
ret);
break;
default:
return -EINVAL;
}
return ret;
}
static int max1720x_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{
int ret;
switch (psp) {
case POWER_SUPPLY_PROP_TEMP_ALERT_MIN:
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
case POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
static irqreturn_t max1720x_irq_handler(int id, void *dev)
{
struct max1720x_priv *priv = dev;
u32 val;
/* Check alert type */
regmap_read(priv->regmap, priv->regs[STATUS_REG], &val);
if (val & MAX1720X_STATUS_SOC_MAX_ALRT)
dev_info(priv->dev, "Alert: SOC MAX!\n");
if (val & MAX1720X_STATUS_SOC_MIN_ALRT)
dev_info(priv->dev, "Alert: SOC MIN!\n");
if (val & MAX1720X_STATUS_TEMP_MAX_ALRT)
dev_info(priv->dev, "Alert: TEMP MAX!\n");
if (val & MAX1720X_STATUS_TEMP_MIN_ALRT)
dev_info(priv->dev, "Alert: TEMP MIN!\n");
if (val & MAX1720X_STATUS_VOLT_MAX_ALRT)
dev_info(priv->dev, "Alert: VOLT MAX!\n");
if (val & MAX1720X_STATUS_VOLT_MIN_ALRT)
dev_info(priv->dev, "Alert: VOLT MIN!\n");
if (val & MAX1720X_STATUS_CURR_MAX_ALRT)
dev_info(priv->dev, "Alert: CURR MAX!\n");
if (val & MAX1720X_STATUS_CURR_MIN_ALRT)
dev_info(priv->dev, "Alert: CURR MIN!\n");
/* Clear alerts */
regmap_write(priv->regmap, priv->regs[STATUS_REG],
val & MAX1720X_STATUS_ALRT_CLR_MASK);
power_supply_changed(priv->battery);
return IRQ_HANDLED;
}
static void max1720x_set_alert_thresholds(struct max1720x_priv *priv)
{
struct max1720x_platform_data *pdata = priv->pdata;
struct regmap *regmap = priv->regmap;
u32 val;
/* Set VAlrtTh */
val = (pdata->volt_min / 20);
val |= ((pdata->volt_max / 20) << 8);
regmap_write(regmap, priv->regs[VALRTTH_REG], val);
/* Set TAlrtTh */
val = pdata->temp_min & 0xFF;
val |= ((pdata->temp_max & 0xFF) << 8);
regmap_write(regmap, priv->regs[TALRTTH_REG], val);
/* Set SAlrtTh */
val = pdata->soc_min;
val |= (pdata->soc_max << 8);
regmap_write(regmap, priv->regs[SALRTTH_REG], val);
/* Set IAlrtTh */
val = (pdata->curr_min * pdata->rsense / 400) & 0xFF;
val |= (((pdata->curr_max * pdata->rsense / 400) & 0xFF) << 8);
regmap_write(regmap, priv->regs[IALRTTH_REG], val);
}
static int max1720x_init(struct max1720x_priv *priv)
{
struct regmap *regmap = priv->regmap;
int ret;
unsigned int reg;
u32 fgrev;
ret = regmap_read(regmap, priv->regs[VERSION_REG], &fgrev);
if (ret < 0)
return ret;
dev_info(priv->dev, "IC Version: 0x%04x\n", fgrev);
/* Optional step - alert threshold initialization */
max1720x_set_alert_thresholds(priv);
/* Clear Status.POR */
ret = regmap_read(regmap, priv->regs[STATUS_REG], ®);
if (ret < 0)
return ret;
ret = regmap_write(regmap, priv->regs[STATUS_REG],
reg & ~MAX1720X_STATUS_POR);
if (ret < 0)
return ret;
return 0;
}
static void max1720x_init_worker(struct work_struct *work)
{
struct max1720x_priv *priv = container_of(work,
struct max1720x_priv,
init_worker);
max1720x_init(priv);
}
static struct max1720x_platform_data *max1720x_parse_dt(struct device *dev)
{
struct device_node *np = dev->of_node;
struct max1720x_platform_data *pdata;
int ret;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
ret = of_property_read_u32(np, "talrt-min", &pdata->temp_min);
if (ret)
pdata->temp_min = -128; /* DegreeC */ /* Disable alert */
ret = of_property_read_u32(np, "talrt-max", &pdata->temp_max);
if (ret)
pdata->temp_max = 127; /* DegreeC */ /* Disable alert */
ret = of_property_read_u32(np, "valrt-min", &pdata->volt_min);
if (ret)
pdata->volt_min = 0; /* mV */ /* Disable alert */
ret = of_property_read_u32(np, "valrt-max", &pdata->volt_max);
if (ret)
pdata->volt_max = 5100; /* mV */ /* Disable alert */
ret = of_property_read_u32(np, "ialrt-min", &pdata->curr_min);
if (ret)
pdata->curr_min = -5120; /* mA */ /* Disable alert */
ret = of_property_read_u32(np, "ialrt-max", &pdata->curr_max);
if (ret)
pdata->curr_max = 5080; /* mA */ /* Disable alert */
ret = of_property_read_u32(np, "salrt-min", &pdata->soc_min);
if (ret)
pdata->soc_min = 0; /* Percent */ /* Disable alert */
ret = of_property_read_u32(np, "salrt-max", &pdata->soc_max);
if (ret)
pdata->soc_max = 255; /* Percent */ /* Disable alert */
ret = of_property_read_u32(np, "rsense", &pdata->rsense);
if (ret)
pdata->rsense = 10;
return pdata;
}
static const struct regmap_config max1720x_regmap = {
.reg_bits = 8,
.val_bits = 16,
.val_format_endian = REGMAP_ENDIAN_NATIVE,
};
static const struct power_supply_desc max1720x_fg_desc = {
.name = "max1720x_battery",
.type = POWER_SUPPLY_TYPE_BATTERY,
.properties = max1720x_battery_props,
.num_properties = ARRAY_SIZE(max1720x_battery_props),
.get_property = max1720x_get_property,
.set_property = max1720x_set_property,
.property_is_writeable = max1720x_property_is_writeable,
};
static int max1720x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct max1720x_priv *priv;
struct power_supply_config psy_cfg = {};
int ret;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
return -EIO;
priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->regs = chip_regs[id->driver_data];
priv->nvmem_high_addr = nvmem_high_addrs[id->driver_data];
priv->cycles_reg_lsb_percent = cycles_reg_lsb_percents[id->driver_data];
priv->get_battery_health = get_battery_health_handlers[id->driver_data];
if (client->dev.of_node)
priv->pdata = max1720x_parse_dt(&client->dev);
else
priv->pdata = client->dev.platform_data;
priv->dev = &client->dev;
i2c_set_clientdata(client, priv);
priv->client = client;
priv->regmap = devm_regmap_init_i2c(client, &max1720x_regmap);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
INIT_WORK(&priv->init_worker, max1720x_init_worker);
schedule_work(&priv->init_worker);
psy_cfg.drv_data = priv;
priv->battery = power_supply_register(&client->dev,
&max1720x_fg_desc, &psy_cfg);
if (IS_ERR(priv->battery)) {
ret = PTR_ERR(priv->battery);
dev_err(&client->dev, "failed to register battery: %d\n", ret);
goto err_supply;
}
if (client->irq) {
ret = devm_request_threaded_irq(priv->dev, client->irq,
NULL,
max1720x_irq_handler,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
priv->battery->desc->name,
priv);
if (ret) {
dev_err(priv->dev, "Failed to request irq %d\n",
client->irq);
goto err_irq;
} else {
regmap_update_bits(priv->regmap, priv->regs[CONFIG_REG],
MAX1720X_CONFIG_ALRT_EN,
MAX1720X_CONFIG_ALRT_EN);
}
}
/* Create max1720x sysfs attributes */
priv->attr_grp = &max1720x_attr_group;
ret = sysfs_create_group(&priv->dev->kobj, priv->attr_grp);
if (ret) {
dev_err(priv->dev, "Failed to create attribute group [%d]\n",
ret);
priv->attr_grp = NULL;
goto err_attr;
}
return 0;
err_irq:
power_supply_unregister(priv->battery);
err_supply:
cancel_work_sync(&priv->init_worker);
err_attr:
sysfs_remove_group(&priv->dev->kobj, priv->attr_grp);
return ret;
}
static int max1720x_remove(struct i2c_client *client)
{
struct max1720x_priv *priv = i2c_get_clientdata(client);
cancel_work_sync(&priv->init_worker);
sysfs_remove_group(&priv->dev->kobj, priv->attr_grp);
power_supply_unregister(priv->battery);
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int max1720x_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
if (client->irq) {
disable_irq(client->irq);
enable_irq_wake(client->irq);
}
return 0;
}
static int max1720x_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
if (client->irq) {
disable_irq_wake(client->irq);
enable_irq(client->irq);
}
return 0;
}
static SIMPLE_DEV_PM_OPS(max1720x_pm_ops, max1720x_suspend, max1720x_resume);
#define MAX1720X_PM_OPS (&max1720x_pm_ops)
#else
#define MAX1720X_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_OF
static const struct of_device_id max1720x_match[] = {
{ .compatible = "maxim,max17201", },
{ .compatible = "maxim,max17205", },
{ .compatible = "maxim,max17301", },
{ .compatible = "maxim,max17302", },
{ .compatible = "maxim,max17303", },
{ },
};
MODULE_DEVICE_TABLE(of, max1720x_match);
#endif
static const struct i2c_device_id max1720x_id[] = {
{ "max17201", ID_MAX1720X },
{ "max17205", ID_MAX1720X },
{ "max17301", ID_MAX1730X },
{ "max17302", ID_MAX1730X },
{ "max17303", ID_MAX1730X },
{ },
};
MODULE_DEVICE_TABLE(i2c, max1720x_id);
static struct i2c_driver max1720x_i2c_driver = {
.driver = {
.name = DRV_NAME,
.of_match_table = of_match_ptr(max1720x_match),
.pm = MAX1720X_PM_OPS,
},
.probe = max1720x_probe,
.remove = max1720x_remove,
.id_table = max1720x_id,
};
module_i2c_driver(max1720x_i2c_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mahir Ozturk <[email protected]>");
MODULE_DESCRIPTION("Maxim MAX17201/5 and MAX17301/2/3 Fuel Gauge driver");
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/LCD/ST7789.py | # ST7789 IPS LCD (320x240) driver
import numbers
import time
import numpy as np
import sys
import os
from PIL import Image
from PIL import ImageDraw
sys.path.append("/home/ubuntu/Robotics/QuadrupedRobot")
sys.path.extend([os.path.join(root, name) for root, dirs, _ in os.walk("/home/ubuntu/Robotics/QuadrupedRobot") for name in dirs])
import Mangdang.Adafruit_GPIO as GPIO
import Mangdang.Adafruit_GPIO.SPI as SPI
from Mangdang.LCD.gif import AnimatedGif
SPI_CLOCK_HZ = 31200000 # 31.2 MHz
# Constants for interacting with display registers.
ST7789_TFTWIDTH = 320
ST7789_TFTHEIGHT = 240
ST7789_NOP = 0x00
ST7789_SWRESET = 0x01
ST7789_RDDID = 0x04
ST7789_RDDST = 0x09
ST7789_RDDPM = 0x0A
ST7789_RDDMADCTL = 0x0B
ST7789_RDDCOLMOD = 0x0C
ST7789_RDDIM = 0x0D
ST7789_RDDSM = 0x0E
ST7789_RDDSDR = 0x0F
ST7789_SLPIN = 0x10
ST7789_SLPOUT = 0x11
ST7789_PTLON = 0x12
ST7789_NORON = 0x13
ST7789_INVOFF = 0x20
ST7789_INVON = 0x21
ST7789_GAMSET = 0x26
ST7789_DISPOFF = 0x28
ST7789_DISPON = 0x29
ST7789_CASET = 0x2A
ST7789_RASET = 0x2B
ST7789_RAMWR = 0x2C
ST7789_RAMRD = 0x2E
ST7789_PTLAR = 0x30
ST7789_VSCRDEF = 0x33
ST7789_TEOFF = 0x34
ST7789_TEON = 0x35
ST7789_MADCTL = 0x36
ST7789_VSCRSADD = 0x37
ST7789_IDMOFF = 0x38
ST7789_IDMON = 0x39
ST7789_COLMOD = 0x3A
ST7789_RAMWRC = 0x3C
ST7789_RAMRDC = 0x3E
ST7789_TESCAN = 0x44
ST7789_RDTESCAN = 0x45
ST7789_WRDISBV = 0x51
ST7789_RDDISBV = 0x52
ST7789_WRCTRLD = 0x53
ST7789_RDCTRLD = 0x54
ST7789_WRCACE = 0x55
ST7789_RDCABC = 0x56
ST7789_WRCABCMB = 0x5E
ST7789_RDCABCMB = 0x5F
ST7789_RDABCSDR = 0x68
ST7789_RDID1 = 0xDA
ST7789_RDID2 = 0xDB
ST7789_RDID3 = 0xDC
ST7789_RAMCTRL = 0xB0
ST7789_RGBCTRL = 0xB1
ST7789_PORCTRL = 0xB2
ST7789_FRCTRL1 = 0xB3
ST7789_GCTRL = 0xB7
ST7789_DGMEN = 0xBA
ST7789_VCOMS = 0xBB
ST7789_LCMCTRL = 0xC0
ST7789_IDSET = 0xC1
ST7789_VDVVRHEN = 0xC2
ST7789_VRHS = 0xC3
ST7789_VDVSET = 0xC4
ST7789_VCMOFSET = 0xC5
ST7789_FRCTR2 = 0xC6
ST7789_CABCCTRL = 0xC7
ST7789_REGSEL1 = 0xC8
ST7789_REGSEL2 = 0xCA
ST7789_PWMFRSEL = 0xCC
ST7789_PWCTRL1 = 0xD0
ST7789_VAPVANEN = 0xD2
ST7789_CMD2EN = 0xDF5A6902
ST7789_PVGAMCTRL = 0xE0
ST7789_NVGAMCTRL = 0xE1
ST7789_DGMLUTR = 0xE2
ST7789_DGMLUTB = 0xE3
ST7789_GATECTRL = 0xE4
ST7789_PWCTRL2 = 0xE8
ST7789_EQCTRL = 0xE9
ST7789_PROMCTRL = 0xEC
ST7789_PROMEN = 0xFA
ST7789_NVMSET = 0xFC
ST7789_PROMACT = 0xFE
# Colours for convenience
ST7789_BLACK = 0x0000 # 0b 00000 000000 00000
ST7789_BLUE = 0x001F # 0b 00000 000000 11111
ST7789_GREEN = 0x07E0 # 0b 00000 111111 00000
ST7789_RED = 0xF800 # 0b 11111 000000 00000
ST7789_CYAN = 0x07FF # 0b 00000 111111 11111
ST7789_MAGENTA = 0xF81F # 0b 11111 000000 11111
ST7789_YELLOW = 0xFFE0 # 0b 11111 111111 00000
ST7789_WHITE = 0xFFFF # 0b 11111 111111 11111
def color565(r, g, b):
"""Convert red, green, blue components to a 16-bit 565 RGB value. Components
should be values 0 to 255.
"""
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
def image_to_data(image):
"""Generator function to convert a PIL image to 16-bit 565 RGB bytes."""
# NumPy is much faster at doing this. NumPy code provided by:
# Keith (https://www.blogger.com/profile/02555547344016007163)
pb = np.array(image.convert('RGB')).astype('uint16')
color = ((pb[:,:,0] & 0xF8) << 8) | ((pb[:,:,1] & 0xFC) << 3) | (pb[:,:,2] >> 3)
return np.dstack(((color >> 8) & 0xFF, color & 0xFF)).flatten().tolist()
class ST7789(object):
"""Representation of an ST7789 IPS LCD."""
def __init__(self, rst, dc, led):
"""Create an instance of the display using SPI communication. Must
provide the GPIO pin number for the D/C pin and the SPI driver. Can
optionally provide the GPIO pin number for the reset pin as the rst
parameter.
"""
SPI_PORT = 0
SPI_DEVICE = 0
SPI_MODE = 0b11
SPI_SPEED_HZ = 40000000
self._spi = SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=SPI_SPEED_HZ)
self._rst = rst
self._dc = dc
self._led = led
self._gpio = None
self.width = ST7789_TFTWIDTH
self.height = ST7789_TFTHEIGHT
if self._gpio is None:
self._gpio = GPIO.get_platform_gpio()
# Set DC as output.
self._gpio.setup(self._dc, GPIO.OUT)
# Setup reset as output (if provided).
if self._rst is not None:
self._gpio.setup(self._rst, GPIO.OUT)
# Turn on the backlight LED
self._gpio.setup(self._led, GPIO.OUT)
# Set SPI to mode 0, MSB first.
self._spi.set_mode(SPI_MODE)
self._spi.set_bit_order(SPI.MSBFIRST)
self._spi.set_clock_hz(SPI_CLOCK_HZ)
# Create an image buffer.
self.buffer = Image.new('RGB', (self.width, self.height))
def send(self, data, is_data=True, chunk_size=4096):
"""Write a byte or array of bytes to the display. Is_data parameter
controls if byte should be interpreted as display data (True) or command
data (False). Chunk_size is an optional size of bytes to write in a
single SPI transaction, with a default of 4096.
"""
# Set DC low for command, high for data.
self._gpio.output(self._dc, is_data)
# Convert scalar argument to list so either can be passed as parameter.
if isinstance(data, numbers.Number):
data = [data & 0xFF]
# Write data a chunk at a time.
for start in range(0, len(data), chunk_size):
end = min(start+chunk_size, len(data))
self._spi.write(data[start:end])
def command(self, data):
"""Write a byte or array of bytes to the display as command data."""
self.send(data, False)
def data(self, data):
"""Write a byte or array of bytes to the display as display data."""
self.send(data, True)
def reset(self):
"""Reset the display, if reset pin is connected."""
if self._rst is not None:
self._gpio.set_high(self._rst)
time.sleep(0.100)
self._gpio.set_low(self._rst)
time.sleep(0.100)
self._gpio.set_high(self._rst)
time.sleep(0.100)
def _init(self):
# Initialize the display. Broken out as a separate function so it can
# be overridden by other displays in the future.
time.sleep(0.012)
self.command(0x11)
time.sleep(0.150)
self.command(0x36)
self.data(0xA0)
self.data(0x00)
self.command(0x3A)
self.data(0x05)
self.command(0xB2)
self.data(0x0C)
self.data(0x0C)
self.data(0x00)
self.data(0x33)
self.data(0x33)
self.command(0xB7)
self.data(0x35)
## ---------------------------------ST7789S Power setting - ----------------------------
self.command(0xBB)
self.data(0x29)
# self.command(0xC0)
# self.data(0x2C)
self.command(0xC2)
self.data(0x01)
self.command(0xC3)
self.data(0x19)
self.command(0xC4)
self.data(0x20)
self.command(0xC5)
self.data(0x1A)
self.command(0xC6)
self.data(0x1F) ## 0x0F:60Hz
# self.command(0xCA)
# self.data(0x0F)
#
# self.command(0xC8)
# self.data(0x08)
#
# self.command(0x55)
# self.data(0x90)
self.command(0xD0)
self.data(0xA4)
self.data(0xA1)
## --------------------------------ST7789S gamma setting - -----------------------------
self.command(0xE0)
self.data(0xD0)
self.data(0x08)
self.data(0x0E)
self.data(0x09)
self.data(0x09)
self.data(0x05)
self.data(0x31)
self.data(0x33)
self.data(0x48)
self.data(0x17)
self.data(0x14)
self.data(0x15)
self.data(0x31)
self.data(0x34)
self.command(0xE1)
self.data(0xD0)
self.data(0x08)
self.data(0x0E)
self.data(0x09)
self.data(0x09)
self.data(0x15)
self.data(0x31)
self.data(0x33)
self.data(0x48)
self.data(0x17)
self.data(0x14)
self.data(0x15)
self.data(0x31)
self.data(0x34)
self.command(0x21)
self.command(0x29)
time.sleep(0.100) # 100 ms
self._gpio.set_high(self._led)
def begin(self):
"""Initialize the display. Should be called once before other calls that
interact with the display are called.
"""
self.reset()
self._init()
def set_window(self, x0=0, y0=0, x1=None, y1=None):
"""Set the pixel address window for proceeding drawing commands. x0 and
x1 should define the minimum and maximum x pixel bounds. y0 and y1
should define the minimum and maximum y pixel bound. If no parameters
are specified the default will be to update the entire display from 0,0
to width-1,height-1.
"""
if x1 is None:
x1 = self.width-1
if y1 is None:
y1 = self.height-1
self.command(ST7789_CASET) # Column addr set
self.data(x0 >> 8)
self.data(x0) # XSTART
self.data(x1 >> 8)
self.data(x1) # XEND
self.command(ST7789_RASET) # Row addr set
self.data(y0 >> 8)
self.data(y0) # YSTART
self.data(y1 >> 8)
self.data(y1) # YEND
self.command(ST7789_RAMWR) # write to RAM
#def display(self, image=None):
def display(self, image=None, x0=0, y0=0, x1=None, y1=None):
"""Write the display buffer or provided image to the hardware. If no
image parameter is provided the display buffer will be written to the
hardware. If an image is provided, it should be RGB format and the
same dimensions as the display hardware.
"""
# By default write the internal buffer to the display.
if image is None:
image = self.buffer
# Set address bounds to entire display.
#self.set_window()
if x1 is None:
x1 = self.width-1
if y1 is None:
y1 = self.height-1
self.set_window(x0, y0, x1, y1)
#image.thumbnail((x1-x0+1, y1-y0+1), Image.ANTIALIAS)
# Convert image to array of 16bit 565 RGB data bytes.
# Unfortunate that this copy has to occur, but the SPI byte writing
# function needs to take an array of bytes and PIL doesn't natively
# store images in 16-bit 565 RGB format.
pixelbytes = list(image_to_data(image))
# Write data to hardware.
self.data(pixelbytes)
def clear(self, color=(0,0,0)):
"""Clear the image buffer to the specified RGB color (default black)."""
width, height = self.buffer.size
self.buffer.putdata([color]*(width*height))
def draw(self):
"""Return a PIL ImageDraw instance for 2D drawing on the image buffer."""
return ImageDraw.Draw(self.buffer)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Mangdang/LCD/gif.py | import os
import time
from PIL import Image
from PIL import ImageOps
class Frame:
def __init__(self, duration=0):
self.duration = duration
self.image = None
class AnimatedGif:
def __init__(self, display, width=None, height=None, folder=None):
self._frame_count = 0
self._loop = 0
self._index = 0
self._duration = 0
self._gif_files = []
self._frames = []
self._gif_folder = folder
if width is not None:
self._width = width
else:
self._width = display.width
if height is not None:
self._height = height
else:
self._height = display.height
self.display = display
if folder is not None:
self.load_files(folder)
self.preload()
def advance(self):
self._index = (self._index + 1) % len(self._gif_files)
def back(self):
self._index = (self._index - 1 + len(self._gif_files)) % len(self._gif_files)
def load_files(self, folder):
gif_files = [f for f in os.listdir(folder) if f.endswith(".gif")]
for gif_file in gif_files:
image = Image.open(folder + gif_file)
# Only add animated Gifs
if image.is_animated:
self._gif_files.append(gif_file)
#print("Found", self._gif_files)
if not self._gif_files:
print("No Gif files found in current folder")
exit() # pylint: disable=consider-using-sys-exit
def preload(self):
image = Image.open(self._gif_folder + self._gif_files[self._index])
#print("Loading {}...".format(self._gif_files[self._index]))
if "duration" in image.info:
self._duration = image.info["duration"]
else:
self._duration = 0
if "loop" in image.info:
self._loop = image.info["loop"]
else:
self._loop = 1
self._frame_count = image.n_frames
del self._frames[:]
for frame in range(self._frame_count):
image.seek(frame)
# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
frame_object = Frame(duration=self._duration)
if "duration" in image.info:
frame_object.duration = image.info["duration"]
frame_object.image = ImageOps.pad( # pylint: disable=no-member
image.convert("RGB"),
(self._width, self._height),
method=Image.NEAREST,
color=(0, 0, 0),
centering=(0.5, 0.5),
)
self._frames.append(frame_object)
def play(self):
# Check if we have loaded any files first
if not self._gif_files:
print("There are no Gif Images loaded to Play")
return False
#while True:
for frame_object in self._frames:
start_time = time.time()
self.display.display(frame_object.image)
while time.time() < (start_time + frame_object.duration / 1000):
pass
if self._loop == 1:
return True
if self._loop > 0:
self._loop -= 1
def run(self):
while True:
auto_advance = self.play()
if auto_advance:
self.advance()
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/PupperCommand/install.sh | #!/usr/bin/env sh
FOLDER=$(dirname $(realpath "$0"))
cd $FOLDER
for file in *.service; do
[ -f "$file" ] || break
sudo ln -s $FOLDER/$file /lib/systemd/system/
done
sudo systemctl daemon-reload
sudo systemctl enable joystick
sudo systemctl start joystick
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/PupperCommand/joystick.py | from UDPComms import Publisher, Subscriber, timeout
from PS4Joystick import Joystick
import time
## you need to git clone the PS4Joystick repo and run `sudo bash install.sh`
## Configurable ##
MESSAGE_RATE = 20
PUPPER_COLOR = {"red":0, "blue":0, "green":255}
joystick_pub = Publisher(8830,65530)
joystick_subcriber = Subscriber(8840, timeout=0.01)
joystick = Joystick()
joystick.led_color(**PUPPER_COLOR)
while True:
values = joystick.get_input()
left_y = -values["left_analog_y"]
right_y = -values["right_analog_y"]
right_x = values["right_analog_x"]
left_x = values["left_analog_x"]
L2 = values["l2_analog"]
R2 = values["r2_analog"]
R1 = values["button_r1"]
L1 = values["button_l1"]
square = values["button_square"]
x = values["button_cross"]
circle = values["button_circle"]
triangle = values["button_triangle"]
dpadx = values["dpad_right"] - values["dpad_left"]
dpady = values["dpad_up"] - values["dpad_down"]
msg = {
"ly": left_y,
"lx": left_x,
"rx": right_x,
"ry": right_y,
"L2": L2,
"R2": R2,
"R1": R1,
"L1": L1,
"dpady": dpady,
"dpadx": dpadx,
"x": x,
"square": square,
"circle": circle,
"triangle": triangle,
"message_rate": MESSAGE_RATE,
}
joystick_pub.send(msg)
try:
msg = joystick_subcriber.get()
joystick.led_color(**msg["ps4_color"])
except timeout:
pass
time.sleep(1 / MESSAGE_RATE)
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/PupperCommand/README.md | # PupperCommand
## Installation
```shell
git clone https://github.com/stanfordroboticsclub/PupperCommand.git
cd PupperCommand
sudo bash install.sh
```
Then clone https://github.com/stanfordroboticsclub/PS4Joystick/ and follow the installation instructions in the README.
## Starting the joystick publisher
1. The ```install.sh``` script makes the Raspberry Pi automatically look to pair and connect to PS4 joysticks on boot.
2. So once the Raspberry Pi turns on, put the PS4 controller into pairing mode by holding the share and PS button at the same time. The light should start blinking in bursts of two.
3. By around 10 seconds, the joystick should have paired with the Raspberry Pi and the front light on the joystick will change to whatever color you specify in the ```joystick.py``` script.
## Debugging
To see if the controller is publishing to the Rover topic use:
```shell
rover peek 8830
```
You can also check the status of the system daemon (systemd) running the ```joystick.py``` script by doing
```shell
sudo systemctl status joystick
```
If it shows that the service failed, you can try
```shell
sudo systemctl stop joystick
sudo systemctl start joystick
```
## Notes
If a packet is lost over the joystick connection, the PS4Joystick code will raise an exception and cause the program to exit. Systemd will then restart the ```joystick.py``` script, which means you will have to re-pair the joystick (hold share + ps4 button until double blinking).
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Legacy/ImageOps.py | #
# The Python Imaging Library.
# $Id$
#
# standard image operations
#
# History:
# 2001-10-20 fl Created
# 2001-10-23 fl Added autocontrast operator
# 2001-12-18 fl Added Kevin's fit operator
# 2004-03-14 fl Fixed potential division by zero in equalize
# 2005-05-05 fl Fixed equalize for low number of values
#
# Copyright (c) 2001-2004 by Secret Labs AB
# Copyright (c) 2001-2004 by Fredrik Lundh
#
# See the README file for information on usage and redistribution.
#
from . import Image
import operator
import functools
import warnings
#
# helpers
def _border(border):
if isinstance(border, tuple):
if len(border) == 2:
left, top = right, bottom = border
elif len(border) == 4:
left, top, right, bottom = border
else:
left = top = right = bottom = border
return left, top, right, bottom
def _color(color, mode):
if isStringType(color):
from . import ImageColor
color = ImageColor.getcolor(color, mode)
return color
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, not image data
raise NotImplementedError("mode P support coming soon")
elif image.mode in ("L", "RGB"):
if image.mode == "RGB" and len(lut) == 256:
lut = lut + lut + lut
return image.point(lut)
else:
raise IOError("not supported for this image mode")
#
# actions
def autocontrast(image, cutoff=0, ignore=None):
"""
Maximize (normalize) image contrast. This function calculates a
histogram of the input image, removes **cutoff** percent of the
lightest and darkest pixels from the histogram, and remaps the image
so that the darkest pixel becomes black (0), and the lightest
becomes white (255).
:param image: The image to process.
:param cutoff: How many percent to cut off from the histogram.
:param ignore: The background pixel value (use None for no background).
:return: An image.
"""
histogram = image.histogram()
lut = []
for layer in range(0, len(histogram), 256):
h = histogram[layer:layer+256]
if ignore is not None:
# get rid of outliers
try:
h[ignore] = 0
except TypeError:
# assume sequence
for ix in ignore:
h[ix] = 0
if cutoff:
# cut off pixels from both ends of the histogram
# get number of pixels
n = 0
for ix in range(256):
n = n + h[ix]
# remove cutoff% pixels from the low end
cut = n * cutoff // 100
for lo in range(256):
if cut > h[lo]:
cut = cut - h[lo]
h[lo] = 0
else:
h[lo] -= cut
cut = 0
if cut <= 0:
break
# remove cutoff% samples from the hi end
cut = n * cutoff // 100
for hi in range(255, -1, -1):
if cut > h[hi]:
cut = cut - h[hi]
h[hi] = 0
else:
h[hi] -= cut
cut = 0
if cut <= 0:
break
# find lowest/highest samples after preprocessing
for lo in range(256):
if h[lo]:
break
for hi in range(255, -1, -1):
if h[hi]:
break
if hi <= lo:
# don't bother
lut.extend(list(range(256)))
else:
scale = 255.0 / (hi - lo)
offset = -lo * scale
for ix in range(256):
ix = int(ix * scale + offset)
if ix < 0:
ix = 0
elif ix > 255:
ix = 255
lut.append(ix)
return _lut(image, lut)
def colorize(image, black, white, mid=None, blackpoint=0,
whitepoint=255, midpoint=127):
"""
Colorize grayscale image.
This function calculates a color wedge which maps all black pixels in
the source image to the first color and all white pixels to the
second color. If **mid** is specified, it uses three-color mapping.
The **black** and **white** arguments should be RGB tuples or color names;
optionally you can use three-color mapping by also specifying **mid**.
Mapping positions for any of the colors can be specified
(e.g. **blackpoint**), where these parameters are the integer
value corresponding to where the corresponding color should be mapped.
These parameters must have logical order, such that
**blackpoint** <= **midpoint** <= **whitepoint** (if **mid** is specified).
:param image: The image to colorize.
:param black: The color to use for black input pixels.
:param white: The color to use for white input pixels.
:param mid: The color to use for midtone input pixels.
:param blackpoint: an int value [0, 255] for the black mapping.
:param whitepoint: an int value [0, 255] for the white mapping.
:param midpoint: an int value [0, 255] for the midtone mapping.
:return: An image.
"""
# Initial asserts
assert image.mode == "L"
if mid is None:
assert 0 <= blackpoint <= whitepoint <= 255
else:
assert 0 <= blackpoint <= midpoint <= whitepoint <= 255
# Define colors from arguments
black = _color(black, "RGB")
white = _color(white, "RGB")
if mid is not None:
mid = _color(mid, "RGB")
# Empty lists for the mapping
red = []
green = []
blue = []
# Create the low-end values
for i in range(0, blackpoint):
red.append(black[0])
green.append(black[1])
blue.append(black[2])
# Create the mapping (2-color)
if mid is None:
range_map = range(0, whitepoint - blackpoint)
for i in range_map:
red.append(black[0] + i * (white[0] - black[0]) // len(range_map))
green.append(black[1] + i * (white[1] - black[1]) // len(range_map))
blue.append(black[2] + i * (white[2] - black[2]) // len(range_map))
# Create the mapping (3-color)
else:
range_map1 = range(0, midpoint - blackpoint)
range_map2 = range(0, whitepoint - midpoint)
for i in range_map1:
red.append(black[0] + i * (mid[0] - black[0]) // len(range_map1))
green.append(black[1] + i * (mid[1] - black[1]) // len(range_map1))
blue.append(black[2] + i * (mid[2] - black[2]) // len(range_map1))
for i in range_map2:
red.append(mid[0] + i * (white[0] - mid[0]) // len(range_map2))
green.append(mid[1] + i * (white[1] - mid[1]) // len(range_map2))
blue.append(mid[2] + i * (white[2] - mid[2]) // len(range_map2))
# Create the high-end values
for i in range(0, 256 - whitepoint):
red.append(white[0])
green.append(white[1])
blue.append(white[2])
# Return converted image
image = image.convert("RGB")
return _lut(image, red + green + blue)
def pad(image, size, method=Image.NEAREST, color=None, centering=(0.5, 0.5)):
"""
Returns a sized and padded version of the image, expanded to fill the
requested aspect ratio and size.
:param image: The image to size and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: What resampling method to use. Default is
:py:attr:`PIL.Image.NEAREST`.
:param color: The background color of the padded image.
:param centering: Control the position of the original image within the
padded version.
(0.5, 0.5) will keep the image centered
(0, 0) will keep the image aligned to the top left
(1, 1) will keep the image aligned to the bottom
right
:return: An image.
"""
im_ratio = image.width / image.height
dest_ratio = float(size[0]) / size[1]
if im_ratio == dest_ratio:
out = image.resize(size, resample=method)
else:
out = Image.new(image.mode, size, color)
if im_ratio > dest_ratio:
new_height = int(image.height / image.width * size[0])
if new_height != size[1]:
image = image.resize((size[0], new_height), resample=method)
y = int((size[1] - new_height) * max(0, min(centering[1], 1)))
out.paste(image, (0, y))
else:
new_width = int(image.width / image.height * size[1])
if new_width != size[0]:
image = image.resize((new_width, size[1]), resample=method)
x = int((size[0] - new_width) * max(0, min(centering[0], 1)))
out.paste(image, (x, 0))
return out
def crop(image, border=0):
"""
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes.
.. seealso:: :py:meth:`~PIL.Image.Image.crop`
:param image: The image to crop.
:param border: The number of pixels to remove.
:return: An image.
"""
left, top, right, bottom = _border(border)
return image.crop(
(left, top, image.size[0]-right, image.size[1]-bottom)
)
def scale(image, factor, resample=Image.NEAREST):
"""
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image.
:param image: The image to rescale.
:param factor: The expansion factor, as a float.
:param resample: An optional resampling filter. Same values possible as
in the PIL.Image.resize function.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
if factor == 1:
return image.copy()
elif factor <= 0:
raise ValueError("the factor must be greater than 0")
else:
size = (int(round(factor * image.width)),
int(round(factor * image.height)))
return image.resize(size, resample)
def deform(image, deformer, resample=Image.BILINEAR):
"""
Deform the image.
:param image: The image to deform.
:param deformer: A deformer object. Any object that implements a
**getmesh** method can be used.
:param resample: An optional resampling filter. Same values possible as
in the PIL.Image.transform function.
:return: An image.
"""
return image.transform(
image.size, Image.MESH, deformer.getmesh(image), resample
)
def equalize(image, mask=None):
"""
Equalize the image histogram. This function applies a non-linear
mapping to the input image, in order to create a uniform
distribution of grayscale values in the output image.
:param image: The image to equalize.
:param mask: An optional mask. If given, only the pixels selected by
the mask are included in the analysis.
:return: An image.
"""
if image.mode == "P":
image = image.convert("RGB")
h = image.histogram(mask)
lut = []
for b in range(0, len(h), 256):
histo = [_f for _f in h[b:b+256] if _f]
if len(histo) <= 1:
lut.extend(list(range(256)))
else:
step = (functools.reduce(operator.add, histo) - histo[-1]) // 255
if not step:
lut.extend(list(range(256)))
else:
n = step // 2
for i in range(256):
lut.append(n // step)
n = n + h[i+b]
return _lut(image, lut)
def expand(image, border=0, fill=0):
"""
Add border to the image
:param image: The image to expand.
:param border: Border width, in pixels.
:param fill: Pixel fill value (a color value). Default is 0 (black).
:return: An image.
"""
left, top, right, bottom = _border(border)
width = left + image.size[0] + right
height = top + image.size[1] + bottom
out = Image.new(image.mode, (width, height), _color(fill, image.mode))
out.paste(image, (left, top))
return out
def fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)):
"""
Returns a sized and cropped version of the image, cropped to the
requested aspect ratio and size.
This function was contributed by Kevin Cazabon.
:param image: The image to size and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: What resampling method to use. Default is
:py:attr:`PIL.Image.NEAREST`.
:param bleed: Remove a border around the outside of the image from all
four edges. The value is a decimal percentage (use 0.01 for
one percent). The default value is 0 (no border).
Cannot be greater than or equal to 0.5.
:param centering: Control the cropping position. Use (0.5, 0.5) for
center cropping (e.g. if cropping the width, take 50% off
of the left side, and therefore 50% off the right side).
(0.0, 0.0) will crop from the top left corner (i.e. if
cropping the width, take all of the crop off of the right
side, and if cropping the height, take all of it off the
bottom). (1.0, 0.0) will crop from the bottom left
corner, etc. (i.e. if cropping the width, take all of the
crop off the left side, and if cropping the height take
none from the top, and therefore all off the bottom).
:return: An image.
"""
# by Kevin Cazabon, Feb 17/2000
# [email protected]
# http://www.cazabon.com
# ensure centering is mutable
centering = list(centering)
if not 0.0 <= centering[0] <= 1.0:
centering[0] = 0.5
if not 0.0 <= centering[1] <= 1.0:
centering[1] = 0.5
if not 0.0 <= bleed < 0.5:
bleed = 0.0
# calculate the area to use for resizing and cropping, subtracting
# the 'bleed' around the edges
# number of pixels to trim off on Top and Bottom, Left and Right
bleed_pixels = (bleed * image.size[0], bleed * image.size[1])
live_size = (image.size[0] - bleed_pixels[0] * 2,
image.size[1] - bleed_pixels[1] * 2)
# calculate the aspect ratio of the live_size
live_size_ratio = float(live_size[0]) / live_size[1]
# calculate the aspect ratio of the output image
output_ratio = float(size[0]) / size[1]
# figure out if the sides or top/bottom will be cropped off
if live_size_ratio >= output_ratio:
# live_size is wider than what's needed, crop the sides
crop_width = output_ratio * live_size[1]
crop_height = live_size[1]
else:
# live_size is taller than what's needed, crop the top and bottom
crop_width = live_size[0]
crop_height = live_size[0] / output_ratio
# make the crop
crop_left = bleed_pixels[0] + (live_size[0]-crop_width) * centering[0]
crop_top = bleed_pixels[1] + (live_size[1]-crop_height) * centering[1]
crop = (
crop_left, crop_top,
crop_left + crop_width, crop_top + crop_height
)
# resize the image and return it
return image.resize(size, method, box=crop)
def flip(image):
"""
Flip the image vertically (top to bottom).
:param image: The image to flip.
:return: An image.
"""
return image.transpose(Image.FLIP_TOP_BOTTOM)
def grayscale(image):
"""
Convert the image to grayscale.
:param image: The image to convert.
:return: An image.
"""
return image.convert("L")
def invert(image):
"""
Invert (negate) the image.
:param image: The image to invert.
:return: An image.
"""
lut = []
for i in range(256):
lut.append(255-i)
return _lut(image, lut)
def mirror(image):
"""
Flip image horizontally (left to right).
:param image: The image to mirror.
:return: An image.
"""
return image.transpose(Image.FLIP_LEFT_RIGHT)
def posterize(image, bits):
"""
Reduce the number of bits for each color channel.
:param image: The image to posterize.
:param bits: The number of bits to keep for each channel (1-8).
:return: An image.
"""
lut = []
mask = ~(2**(8-bits)-1)
for i in range(256):
lut.append(i & mask)
return _lut(image, lut)
def solarize(image, threshold=128):
"""
Invert all pixel values above a threshold.
:param image: The image to solarize.
:param threshold: All pixels above this greyscale level are inverted.
:return: An image.
"""
lut = []
for i in range(256):
if i < threshold:
lut.append(i)
else:
lut.append(255-i)
return _lut(image, lut)
# --------------------------------------------------------------------
# PIL USM components, from Kevin Cazabon.
def gaussian_blur(im, radius=None):
""" PIL_usm.gblur(im, [radius])"""
warnings.warn(
'PIL.ImageOps.gaussian_blur is deprecated. '
'Use PIL.ImageFilter.GaussianBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
if radius is None:
radius = 5.0
im.load()
return im.im.gaussian_blur(radius)
def gblur(im, radius=None):
""" PIL_usm.gblur(im, [radius])"""
warnings.warn(
'PIL.ImageOps.gblur is deprecated. '
'Use PIL.ImageFilter.GaussianBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
return gaussian_blur(im, radius)
def unsharp_mask(im, radius=None, percent=None, threshold=None):
""" PIL_usm.usm(im, [radius, percent, threshold])"""
warnings.warn(
'PIL.ImageOps.unsharp_mask is deprecated. '
'Use PIL.ImageFilter.UnsharpMask instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
if radius is None:
radius = 5.0
if percent is None:
percent = 150
if threshold is None:
threshold = 3
im.load()
return im.im.unsharp_mask(radius, percent, threshold)
def usm(im, radius=None, percent=None, threshold=None):
""" PIL_usm.usm(im, [radius, percent, threshold])"""
warnings.warn(
'PIL.ImageOps.usm is deprecated. '
'Use PIL.ImageFilter.UnsharpMask instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
return unsharp_mask(im, radius, percent, threshold)
def box_blur(image, radius):
"""
Blur the image by setting each pixel to the average value of the pixels
in a square box extending radius pixels in each direction.
Supports float radius of arbitrary size. Uses an optimized implementation
which runs in linear time relative to the size of the image
for any radius value.
:param image: The image to blur.
:param radius: Size of the box in one direction. Radius 0 does not blur,
returns an identical image. Radius 1 takes 1 pixel
in each direction, i.e. 9 pixels in total.
:return: An image.
"""
warnings.warn(
'PIL.ImageOps.box_blur is deprecated. '
'Use PIL.ImageFilter.BoxBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
image.load()
return image._new(image.im.box_blur(radius))
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/Legacy/pre_install.sh | #!/usr/bin/env sh
###Install all software dependence for Mini Pupper
#Install system tools
sudo apt install -y net-tools
sudo apt install -y openssh-server
sudo apt install -y curl
sudo apt install -y git
#Update time and source
sudo date -s "$(curl -s --head http://www.baidu.com | grep ^Date: | sed 's/Date: //g')"
sudo apt-get update
#dependencies
sudo apt-get install -y libsdl-ttf2.0-0
sudo apt-get install -y libatlas-base-dev
sudo apt-get install -y libhdf5-dev
sudo apt-get install -y python3-pip
sudo apt-get install -y i2c-tools
sudo apt-get install -y python
sudo apt-get install -y python3-tk
#sudo apt-get install -y mpg123
sudo apt-get install -y python3-rpi.gpio
#Libraries of Python3
yes | sudo pip3 install Cython
yes | sudo pip3 install numpy
yes | sudo pip3 install msgpack
yes | sudo pip3 install pexpect
yes | sudo pip3 install transforms3d
yes | sudo pip3 install matplotlib
yes | sudo pip3 install ds4drv
yes | sudo pip3 install pyserial
yes | sudo pip3 install adafruit-blinka==5.13.1
yes | sudo pip3 install adafruit-CircuitPython-BusDevice==5.0.4
yes | sudo pip3 install spidev
#The WA for Pillow lib in raspberry ubuntu 20.04+
sudo rm /usr/lib/python3/dist-packages/PIL/ImageOps.py -f
sudo cp ImageOps.py /usr/lib/python3/dist-packages/PIL/ImageOps.py -f
#remove upgrader core
sudo apt-get remove -y ubuntu-release-upgrader-core
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/calibrate_tool.py | import re
import tkinter as tk
import tkinter.messagebox
from tkinter import *
import _thread
import time
import os
import sys
import numpy as np
from pupper.HardwareInterface import HardwareInterface
###################################################################
OverLoadCurrentMax = 1500000
OverLoadHoldCounterMax = 100 # almost 3s
ServoCalibrationFilePath = '/sys/bus/i2c/devices/3-0050/eeprom'
servo1_en = 25
servo2_en = 21
hw_version=""
###################################################################
class LegPositionScale:
def __init__(self,root,location_x,location_y,leg_name):
self.LocationX = location_x
self.LocationY = location_y
delt_x = 40
delt_y = 45
self.Value1 = DoubleVar()
self.Value2 = DoubleVar()
self.Value3 = DoubleVar()
self.title = Label(root,text = leg_name,font = ('bold',16))
self.label1 = Label(root,text = 'Hip')
self.slider1 = Scale(root,from_=-100,to=100,variable = self.Value1,length = 120,orient = HORIZONTAL)
self.label2 = Label(root,text = 'Thigh')
self.slider2 = Scale(root,from_=-55,to=145,variable = self.Value2,length = 120,orient = HORIZONTAL)
self.label3 = Label(root,text = 'Calf')
self.slider3 = Scale(root,from_=-145,to=55,variable = self.Value3,length = 120,orient = HORIZONTAL)
self.label1.place(x=location_x, y=location_y + 20)
self.label2.place(x=location_x, y=location_y + delt_y*1+ 20)
self.label3.place(x=location_x, y=location_y + delt_y*2+ 20)
self.slider1.place(x=location_x + delt_x, y=location_y )
self.slider2.place(x=location_x + delt_x, y=location_y + delt_y*1)
self.slider3.place(x=location_x + delt_x, y=location_y + delt_y*2)
self.title.place(x=location_x + 70, y=location_y + delt_y*3)
def setValue(self,value):
self.slider1.set(value[0])
self.slider2.set(value[1])
self.slider3.set(value[2])
return True
def getValue(self):
value = []
value.append(self.Value1.get())
value.append(self.Value2.get())
value.append(self.Value3.get())
return value
class CalibrationTool:
def __init__(self,title, width, height):
self.Run = True
self.FileAllLines = []
#leg slider value
self.Leg1SlidersValue = [0,0,0]
self.Leg2SlidersValue = [0,0,0]
self.Leg3SlidersValue = [0,0,0]
self.Leg4SlidersValue = [0,0,0]
# calibration data
self.Matrix_EEPROM = np.array([[0, 0, 0, 0], [45, 45, 45, 45], [-45, -45, -45, -45]])
self.ServoStandardLAngle = [[0,0,0,0],[45,45,45,45],[-45,-45,-45,-45]]
self.ServoNeutralLAngle = [[0,0,0,0],[45,45,45,45],[-45,-45,-45,-45]]
self.NocalibrationServoAngle = [[0,0,0,0],[45,45,45,45],[-45,-45,-45,-45]]
self.CalibrationServoAngle = [[0,0,0,0],[45,45,45,45],[-45,-45,-45,-45]]
#build main window
self.MainWindow = tk.Tk()
screenwidth = self.MainWindow.winfo_screenwidth()
screenheight = self.MainWindow.winfo_screenheight()
size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
self.MainWindow.geometry(size)
self.MainWindow.title('MiniPupper') #Mini Pupper Calibration Tool
self.MainWindow.update()
#init title
self.Title = Label(self.MainWindow,text = title,font = ('bold',30))
self.Title.place(x=140,y=15)
#init robot image
self.photo = tk.PhotoImage(file= '/home/ubuntu/Robotics/QuadrupedRobot/Doc/imgs/MiniPupper.Calibration.png')
self.MainImg = Label(self.MainWindow,image = self.photo)
self.MainImg.place(x=230,y=60)
#init read update button
self.ResetButton = Button(self.MainWindow,text = ' Reset ',font = ('bold',20),command=self.ResetButtonEvent)
self.UpdateButton = Button(self.MainWindow,text = 'Update',font = ('bold',20),command=self.updateButtonEvent)
self.RestoreButton = Button(self.MainWindow,text = 'Restore',font = ('bold',7),command=self.RestoreButtonEvent)
self.ResetButton.place(x=600,y=100)
self.UpdateButton.place(x=600,y=200)
self.RestoreButton.place(x=160,y=80)
#build 4 legs sliders
self.Leg1Calibration = LegPositionScale(self.MainWindow,20,300, 'Leg 1')
self.Leg2Calibration = LegPositionScale(self.MainWindow,220,300,'Leg 2')
self.Leg3Calibration = LegPositionScale(self.MainWindow,420,300,'Leg 3')
self.Leg4Calibration = LegPositionScale(self.MainWindow,620,300,'Leg 4')
self.Leg1Calibration.setValue([self.ServoNeutralLAngle[0][0],self.ServoNeutralLAngle[1][0],self.ServoNeutralLAngle[2][0]])
self.Leg2Calibration.setValue([self.ServoNeutralLAngle[0][1],self.ServoNeutralLAngle[1][1],self.ServoNeutralLAngle[2][1]])
self.Leg3Calibration.setValue([self.ServoNeutralLAngle[0][2],self.ServoNeutralLAngle[1][2],self.ServoNeutralLAngle[2][2]])
self.Leg4Calibration.setValue([self.ServoNeutralLAngle[0][3],self.ServoNeutralLAngle[1][3],self.ServoNeutralLAngle[2][3]])
def setLegSlidersValue(self,value):
self.Leg1Calibration.setValue(value[0])
self.Leg2Calibration.setValue(value[1])
self.Leg3Calibration.setValue(value[2])
self.Leg4Calibration.setValue(value[3])
return value
def readCalibrationFile(self):
#read all lines text from EEPROM
try:
with open(ServoCalibrationFilePath, "rb") as nv_f:
arr1 = np.array(eval(nv_f.readline()))
arr2 = np.array(eval(nv_f.readline()))
matrix = np.append(arr1, arr2)
arr3 = np.array(eval(nv_f.readline()))
matrix = np.append(matrix, arr3)
matrix.resize(3,4)
self.Matrix_EEPROM = matrix
print("Get nv calibration params: \n" , self.Matrix_EEPROM)
except:
matrix = np.array([[0, 0, 0, 0], [45, 45, 45, 45], [-45, -45, -45, -45]])
self.Matrix_EEPROM = matrix
#update
for i in range(3):
for j in range(4):
self.NocalibrationServoAngle[i][j] = self.Matrix_EEPROM[i,j]
self.CalibrationServoAngle[i][j] = self.Matrix_EEPROM[i,j]
return True
def updateCalibrationMatrix(self,angle):
for i in range(3):
for j in range(4):
self.Matrix_EEPROM[i,j] = angle[i][j]
return True
def writeCalibrationFile(self):
#write matrix to EEPROM
buf_matrix = np.zeros((3, 4))
for i in range(3):
for j in range(4):
buf_matrix[i,j]= self.Matrix_EEPROM[i,j]
# Format array object string for np.array
p1 = re.compile("([0-9]\.) ( *)") # pattern to replace the space that follows each number with a comma
partially_formatted_matrix = p1.sub(r"\1,\2", str(buf_matrix))
p2 = re.compile("(\]\n)") # pattern to add a comma at the end of the first two lines
formatted_matrix_with_required_commas = p2.sub("],\n", partially_formatted_matrix)
with open(ServoCalibrationFilePath, "w") as nv_f:
_tmp = str(buf_matrix)
_tmp = _tmp.replace('.' , ',')
_tmp = _tmp.replace('[' , '')
_tmp = _tmp.replace(']' , '')
print(_tmp, file = nv_f)
nv_f.close()
return True
def getLegSlidersValue(self):
value = [[0,0,0,0],[0,0,0,0],[0,0,0,0]]
self.Leg1SlidersValue = self.Leg1Calibration.getValue()
self.Leg2SlidersValue = self.Leg2Calibration.getValue()
self.Leg3SlidersValue = self.Leg3Calibration.getValue()
self.Leg4SlidersValue = self.Leg4Calibration.getValue()
value[0] = [self.Leg1SlidersValue[0],self.Leg2SlidersValue[0],self.Leg3SlidersValue[0],self.Leg4SlidersValue[0]]
value[1] = [self.Leg1SlidersValue[1],self.Leg2SlidersValue[1],self.Leg3SlidersValue[1],self.Leg4SlidersValue[1]]
value[2] = [self.Leg1SlidersValue[2],self.Leg2SlidersValue[2],self.Leg3SlidersValue[2],self.Leg4SlidersValue[2]]
self.ServoNeutralLAngle = value
return value
def ResetButtonEvent(self):
value = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
for j in range(4):
value[j][i] = self.ServoStandardLAngle[i][j]
self.setLegSlidersValue(value)
return True
def updateButtonEvent(self):
# update angle matrix
value = self.getLegSlidersValue()
angle = [[0,0,0,0],[0,0,0,0],[0,0,0,0]]
for i in range(3):
for j in range(4):
angle[i][j] = self.ServoStandardLAngle[i][j] - value[i][j] +MainWindow.NocalibrationServoAngle[i][j]
# limit angle
for i in range(3):
for j in range(4):
if angle[i][j] > 90:
angle[i][j] = 90
elif angle[i][j] < -90:
angle[i][j] = -90
# popup message box
result = tk.messagebox.askquestion('Info:','****** Angle Matrix ******\n'
+str(angle[0])+'\n'
+str(angle[1])+'\n'
+str(angle[2])+'\n'
+'****************************\n'
+' Update Matrix?')
# update matrix
if result == 'yes':
self.updateCalibrationMatrix(angle)
self.writeCalibrationFile()
print('******** Angle Matrix ********')
print(angle[0])
print(angle[1])
print(angle[2])
print('******************************')
return True
def RestoreButtonEvent(self):
# update angle matrix
value = self.getLegSlidersValue()
angle = [[0,0,0,0],[45,45,45,45],[-45,-45,-45,-45]]
# popup message box
result = tk.messagebox.askquestion('Warning','Are you sure you want to Restore Factory Setting!?')
# update matrix
if result == 'yes':
self.updateCalibrationMatrix(angle)
self.writeCalibrationFile()
print('******** Angle Matrix ********')
print(angle[0])
print(angle[1])
print(angle[2])
print('******************************')
sys.exit()
for i in range(3):
for j in range(4):
self.NocalibrationServoAngle[i][j] = angle[i][j]
#self.CalibrationServoAngle[i][j] = angle[i][j]
value = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
for j in range(4):
value[j][i] = self.ServoStandardLAngle[i][j]
self.setLegSlidersValue(value)
return True
def runMainWindow(self):
self.MainWindow.mainloop()
return True
def stopMainWindow(self):
self.Run = False
return True
OverLoadHoldCounter = 0
def OverLoadDetection():
overload = False
global OverLoadHoldCounter
r = os.popen("cat /sys/class/power_supply/max1720x_battery/current_now")
feedback = str(r.readlines())
current_now = int(feedback[3:len(feedback)-4])
if (current_now > OverLoadCurrentMax):
OverLoadHoldCounter = OverLoadHoldCounter + 1
if (OverLoadHoldCounter > OverLoadHoldCounterMax):
OverLoadHoldCounter = OverLoadHoldCounterMax
os.popen("echo 0 > /sys/class/gpio/gpio"+ str(servo1_en) + "/value")
os.popen("echo 0 > /sys/class/gpio/gpio"+ str(servo2_en) + "/value")
overload = True
else:
overload = False
else:
OverLoadHoldCounter = OverLoadHoldCounter - 10
if (OverLoadHoldCounter < 0):
OverLoadHoldCounter = 0
os.popen("echo 1 > /sys/class/gpio/gpio" + str(servo1_en) + "/value")
os.popen("echo 1 > /sys/class/gpio/gpio" + str(servo2_en) + "/value")
overload = False
return overload
def updateServoValue(MainWindow,servo):
while MainWindow.Run:
#update leg slider value
value = MainWindow.getLegSlidersValue()
# overload detection
overload = OverLoadDetection()
if overload == True:
tk.messagebox.showwarning('Warning','Servos overload, please check !!!')
else:
#control servo
joint_angles = np.zeros((3, 4))
joint_angles2 = np.zeros((3, 4))
for i in range(3):
for j in range(4):
joint_angles[i,j] = (value[i][j] - (MainWindow.NocalibrationServoAngle[i][j] - MainWindow.CalibrationServoAngle[i][j]))*0.01745
servo.set_actuator_postions(joint_angles)
time.sleep(0.01)
##############################################
with open("/home/ubuntu/.hw_version", "r") as hw_f:
hw_version = hw_f.readline()
if hw_version == 'P1\n':
ServoCalibrationFilePath = "/home/ubuntu/.nv_fle"
servo1_en = 19
servo2_en = 26
else:
servo1_en = 25
servo2_en = 21
os.system("sudo systemctl stop robot")
os.system("echo 1 > /sys/class/gpio/gpio" + str(servo1_en) + "/value")
os.system("echo 1 > /sys/class/gpio/gpio" + str(servo2_en) + "/value")
MainWindow = CalibrationTool('MiniPupper Calibration Tool',800,500)
MainWindow.readCalibrationFile()
hardware_interface = HardwareInterface()
try:
_thread.start_new_thread( updateServoValue, ( MainWindow, hardware_interface,) )
except:
print ('Thread Error')
MainWindow.runMainWindow()
MainWindow.stopMainWindow()
os.system("sudo systemctl start robot")
os.system("echo 1 > /sys/class/gpio/gpio"+ str(servo1_en) + "/value")
os.system("echo 1 > /sys/class/gpio/gpio"+ str(servo2_en) + "/value")
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/install.sh | #!/usr/bin/env sh
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/PupperCommand/install.sh
sudo bash /home/ubuntu/Robotics/QuadrupedRobot/PS4Joystick/install.sh
cd /home/ubuntu/Robotics/QuadrupedRobot/StanfordQuadruped
sudo ln -s $(realpath .)/robot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable robot
sudo systemctl start robot
sudo mv CalibrationTool.desktop /home/ubuntu/Desktop
sudo chmod a+x /home/ubuntu/Desktop/CalibrationTool.desktop
sudo chmod a+r /home/ubuntu/Robotics/QuadrupedRobot/StanfordQuadruped/imgs/icon.png
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/run_robot.py | import os
import sys
import threading
import time
import numpy as np
from PIL import Image
from multiprocessing import Process
import multiprocessing
sys.path.append("/home/ubuntu/Robotics/QuadrupedRobot")
sys.path.extend([os.path.join(root, name) for root, dirs, _ in os.walk("/home/ubuntu/Robotics/QuadrupedRobot") for name in dirs])
from Mangdang.LCD.ST7789 import ST7789
from Mangdang.LCD.gif import AnimatedGif
from src.Controller import Controller
from src.JoystickInterface import JoystickInterface
from src.State import State
from pupper.MovementGroup import MovementLib
from src.MovementScheme import MovementScheme
from pupper.HardwareInterface import HardwareInterface
from pupper.Config import Configuration
from pupper.Kinematics import four_legs_inverse_kinematics
quat_orientation = np.array([1, 0, 0, 0])
cartoons_folder = "/home/ubuntu/Robotics/QuadrupedRobot/Mangdang/LCD/cartoons/"
current_show = ""
with open("/home/ubuntu/.hw_version", "r") as hw_f:
hw_version = hw_f.readline()
if hw_version == 'P1\n':
disp = ST7789(14, 15, 47)
else :
disp = ST7789(27, 24, 26)
def pic_show(disp, pic_name, _lock):
""" Show the specify picture
Parameter:
disp : display instance
pic_name : picture name to show
Return : None
"""
if pic_name == "":
return
global current_show
if pic_name == current_show:
return
image=Image.open(cartoons_folder + pic_name)
image.resize((320,240))
_lock.acquire()
disp.display(image)
_lock.release()
current_show = pic_name
def animated_thr_fun(_disp, duration, is_connect, current_leg, _lock):
"""
The thread funcation to show sleep animated gif
Parameter: None
Returen: None
"""
try:
gif_player = AnimatedGif(_disp, width=320, height=240, folder=cartoons_folder)
last_time = time.time()
last_joint_angles = np.zeros(3)
while True:
if is_connect.value == 1 :
#if ((current_leg[0]==last_joint_angles[0]) and (current_leg[1]==last_joint_angles[1]) and (current_leg[2]==last_joint_angles[2])) == False :
if ((current_leg[0]==last_joint_angles[0]) and (current_leg[1]==last_joint_angles[1])) == False :
last_time = time.time()
last_joint_angles[0] = current_leg[0]
last_joint_angles[1] = current_leg[1]
#last_joint_angles[2] = current_leg[2]
if (time.time() - last_time) > duration :
_lock.acquire()
gif_player.play()
_lock.release()
time.sleep(0.5)
else :
last_time = time.time()
time.sleep(1.5)
except KeyboardInterrupt:
_lock.release()
pass
def cmd_dump(cmd):
"""
debug interface to show all info about PS4 command
Parameter: None
return : None
"""
print("\nGet PS4 command :")
print("horizontal_velocity: ", cmd.horizontal_velocity)
print("yaw_rate ", cmd.yaw_rate)
print("height", cmd.height)
print("pitch ", cmd.pitch)
print("roll ", cmd.roll)
print("activation ", cmd.activation)
print("hop_event ", cmd.hop_event)
print("trot_event ", cmd.trot_event)
print("activate_event ", cmd.activate_event)
def main():
"""Main program
"""
# Create config
config = Configuration()
hardware_interface = HardwareInterface()
# show logo
global disp
disp.begin()
disp.clear()
image=Image.open(cartoons_folder + "logo.png")
image.resize((320,240))
disp.display(image)
shutdown_counter = 0 # counter for shuudown cmd
# Start animated process
duration = 10
is_connect = multiprocessing.Value('l', 0)
current_leg = multiprocessing.Array('d', [0, 0, 0])
lock = multiprocessing.Lock()
animated_process = Process(target=animated_thr_fun, args=(disp, duration, is_connect, current_leg, lock))
#animated_process.start()
#Create movement group scheme
movement_ctl = MovementScheme(MovementLib)
# Create controller and user input handles
controller = Controller(
config,
four_legs_inverse_kinematics,
)
state = State()
print("Creating joystick listener...")
joystick_interface = JoystickInterface(config)
print("Done.")
last_loop = time.time()
print("Summary of gait parameters:")
print("overlap time: ", config.overlap_time)
print("swing time: ", config.swing_time)
print("z clearance: ", config.z_clearance)
print("x shift: ", config.x_shift)
# Wait until the activate button has been pressed
while True:
print("Waiting for L1 to activate robot.")
while True:
command = joystick_interface.get_command(state)
joystick_interface.set_color(config.ps4_deactivated_color)
if command.activate_event == 1:
break
time.sleep(0.1)
print("Robot activated.")
is_connect.value = 1
joystick_interface.set_color(config.ps4_color)
pic_show(disp, "walk.png", lock)
while True:
now = time.time()
if now - last_loop < config.dt:
continue
last_loop = time.time()
# Parse the udp joystick commands and then update the robot controller's parameters
command = joystick_interface.get_command(state)
#cmd_dump(command)
_pic = "walk.png" if command.yaw_rate ==0 else "turnaround.png"
if command.trot_event == True:
_pic = "walk_r1.png"
pic_show(disp, _pic, lock)
if command.activate_event == 1:
is_connect.value = 0
pic_show(disp, "notconnect.png", lock)
print("Deactivating Robot")
break
state.quat_orientation = quat_orientation
# movement scheme
movement_switch = command.dance_switch_event
gait_state = command.trot_event
dance_state = command.dance_activate_event
shutdown_signal = command.shutdown_signal
#shutdown counter
if shutdown_signal == True:
shutdown_counter = shutdown_counter + 1
# press shut dow button more 3s(0.015*200), shut down system
if shutdown_counter >= 200:
print('shutdown system now')
os.system('systemctl stop robot')
os.system('shutdown -h now')
# gait and movement control
if gait_state == True or dance_state == True: # if triger tort event, reset the movement number to 0
movement_ctl.resetMovementNumber()
movement_ctl.runMovementScheme(movement_switch)
food_location = movement_ctl.getMovemenLegsLocation()
attitude_location = movement_ctl.getMovemenAttitude()
robot_speed = movement_ctl.getMovemenSpeed()
controller.run(state,command,food_location,attitude_location,robot_speed)
# Update the pwm widths going to the servos
hardware_interface.set_actuator_postions(state.joint_angles)
current_leg[0]= state.joint_angles[0][0]
current_leg[1]= state.joint_angles[1][0]
#current_leg[2]= state.joint_angles[2][0]
try:
main()
except KeyboardInterrupt:
pass
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/src/Gaits.py | class GaitController:
def __init__(self, config):
self.config = config
def phase_index(self, ticks):
"""Calculates which part of the gait cycle the robot should be in given the time in ticks.
Parameters
----------
ticks : int
Number of timesteps since the program started
gaitparams : GaitParams
GaitParams object
Returns
-------
Int
The index of the gait phase that the robot should be in.
"""
phase_time = ticks % self.config.phase_length
phase_sum = 0
for i in range(self.config.num_phases):
phase_sum += self.config.phase_ticks[i]
if phase_time < phase_sum:
return i
assert False
def subphase_ticks(self, ticks):
"""Calculates the number of ticks (timesteps) since the start of the current phase.
Parameters
----------
ticks : Int
Number of timesteps since the program started
gaitparams : GaitParams
GaitParams object
Returns
-------
Int
Number of ticks since the start of the current phase.
"""
phase_time = ticks % self.config.phase_length
phase_sum = 0
subphase_ticks = 0
for i in range(self.config.num_phases):
phase_sum += self.config.phase_ticks[i]
if phase_time < phase_sum:
subphase_ticks = phase_time - phase_sum + self.config.phase_ticks[i]
return subphase_ticks
assert False
def contacts(self, ticks):
"""Calculates which feet should be in contact at the given number of ticks
Parameters
----------
ticks : Int
Number of timesteps since the program started.
gaitparams : GaitParams
GaitParams object
Returns
-------
numpy array (4,)
Numpy vector with 0 indicating flight and 1 indicating stance.
"""
return self.config.contact_phases[:, self.phase_index(ticks)]
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/src/Command.py | import numpy as np
class Command:
"""Stores movement command
"""
def __init__(self):
self.horizontal_velocity = np.array([0, 0])
self.yaw_rate = 0.0
self.height = -0.07
self.pitch = 0.0
self.roll = 0.0
self.activation = 0
self.hop_event = False
self.trot_event = False
self.activate_event = False
self.dance_activate_event = False
self.dance_switch_event = False
self.gait_switch_event = False
self.shutdown_signal = False
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/src/SwingLegController.py | import numpy as np
from transforms3d.euler import euler2mat
class SwingController:
def __init__(self, config):
self.config = config
def raibert_touchdown_location(
self, leg_index, command
):
delta_p_2d = (
self.config.alpha
* self.config.stance_ticks
* self.config.dt
* command.horizontal_velocity
)
delta_p = np.array([delta_p_2d[0], delta_p_2d[1], 0])
theta = (
self.config.beta
* self.config.stance_ticks
* self.config.dt
* command.yaw_rate
)
R = euler2mat(0, 0, theta)
return R @ self.config.default_stance[:, leg_index] + delta_p
def swing_height(self, swing_phase, triangular=True):
if triangular:
if swing_phase < 0.5:
swing_height_ = swing_phase / 0.5 * self.config.z_clearance
else:
swing_height_ = self.config.z_clearance * (1 - (swing_phase - 0.5) / 0.5)
return swing_height_
def next_foot_location(
self,
swing_prop,
leg_index,
state,
command,
):
assert swing_prop >= 0 and swing_prop <= 1
foot_location = state.foot_locations[:, leg_index]
swing_height_ = self.swing_height(swing_prop)
touchdown_location = self.raibert_touchdown_location(leg_index, command)
time_left = self.config.dt * self.config.swing_ticks * (1.0 - swing_prop)
v = (touchdown_location - foot_location) / time_left * np.array([1, 1, 0])
delta_foot_location = v * self.config.dt
z_vector = np.array([0, 0, swing_height_ + command.height])
return foot_location * np.array([1, 1, 0]) + z_vector + delta_foot_location
|
renanmb/Omniverse_legged_robotics/URDF-Descriptions/Mini_pupper/QuadrupedRobot-mini_pupper/StanfordQuadruped/src/MovementScheme.py | from ActuatorControl import ActuatorControl
LocationStanding = [[ 0.06,0.06,-0.06,-0.06],[-0.05, 0.05,-0.05,0.05],[ -0.07,-0.07,-0.07,-0.07]]
DeltLocationMax = 0.001
AttitudeMinMax = [[-20,20],[-20,20],[-100,100]]
class SequenceInterpolation:
def __init__(self,name,dimension):
self.Name = name
self.Dimension = dimension
self.InterpolationNumber = 1
self.ExecuteTick = 0
self.SequenceExecuteCounter = 0
self.PhaseNumberMax = 1
self.SequencePoint = [[0,0,0]]
# interpolation point data
self.PointPhaseStart = 0
self.PointPhaseStop = 1
self.TnterpolationDelt = [0,0,0]
self.PointNow = [0,0,0]
self.PointPrevious = [0,0,0]
def setCycleType(self,cycle_type,cycle_index):
if cycle_type == 'Forever':
self.SequenceExecuteCounter = 9999
elif cycle_type == 'Multiple':
self.SequenceExecuteCounter = cycle_index
else:
self.SequenceExecuteCounter = 1
return True
def setInterpolationNumber(self,interpolation_number):
self.InterpolationNumber = interpolation_number
return True
def setSequencePoint(self,sequence):
self.SequencePoint = sequence
self.PhaseNumberMax = len(sequence)
# init now and pre point phase
for xyz in range(self.Dimension):
self.PointNow[xyz] = sequence[0][xyz]
self.PointPrevious[xyz] = sequence[0][xyz]
# init start point phase
self.PointPhaseStart = 0
# init stop point phase
self.PointPhaseStop = self.PointPhaseStart + 1
if self.PointPhaseStop >= len(sequence):
self.PointPhaseStop = self.PointPhaseStart
return True
def updatePointPhase(self):
# update start point phase
self.PointPhaseStart = self.PointPhaseStart + 1
if self.PointPhaseStart >= self.PhaseNumberMax:
if self.SequenceExecuteCounter >0:
self.PointPhaseStart = 0
else:
self.SequenceExecuteCounter = 0
self.PointPhaseStart = self.PointPhaseStart - 1
# update stop point phase
self.PointPhaseStop = self.PointPhaseStart + 1
if self.PointPhaseStop >= self.PhaseNumberMax:
self.SequenceExecuteCounter = self.SequenceExecuteCounter - 1
if self.SequenceExecuteCounter >0:
self.PointPhaseStop = 0
else:
self.SequenceExecuteCounter = 0
self.PointPhaseStop = self.PointPhaseStop - 1
self.PointPhaseStop = 0
return True
def updateInterpolationDelt(self):
#get start and stop point
point_start = self.SequencePoint[self.PointPhaseStart]
point_stop = self.SequencePoint[self.PointPhaseStop]
for xyz in range(self.Dimension):
diff = point_stop[xyz] - point_start[xyz]
self.TnterpolationDelt[xyz] = - diff/self.InterpolationNumber
return True
def getNewPoint(self):
#update movement tick
self.ExecuteTick = self.ExecuteTick + 1
if self.ExecuteTick >= self.InterpolationNumber:
self.ExecuteTick = 0
self.updatePointPhase()
self.updateInterpolationDelt()
self.PointNow[0] = self.PointPrevious[0] + self.TnterpolationDelt[0]
self.PointNow[1] = self.PointPrevious[1] + self.TnterpolationDelt[1]
self.PointNow[2] = self.PointPrevious[2] + self.TnterpolationDelt[2]
self.PointPrevious = self.PointNow
return self.PointNow
class Movements:
def __init__(self,name,speed_enable,attitude_enable,legs_enable,actuator_enable):
self.MovementName = name
self.SpeedEnable = speed_enable
self.AttitudeEnable = attitude_enable
self.LegsEnable = legs_enable
self.ActuatorEnable = actuator_enable
self.ExitToStand = True
self.SpeedMovements = SequenceInterpolation('speed',2)
self.AttitudeMovements = SequenceInterpolation('attitude',3)
self.LegsMovements = []
self.LegsMovements.append(SequenceInterpolation('leg1',3))
self.LegsMovements.append(SequenceInterpolation('leg2',3))
self.LegsMovements.append(SequenceInterpolation('leg3',3))
self.LegsMovements.append(SequenceInterpolation('leg4',3))
self.ActuatorsMovements = SequenceInterpolation('actuators',1)
# init state value
self.SpeedInit = [0,0,0] # x, y speed
self.AttitudeInit = [0,0,0] # roll pitch yaw rate
self.LegsLocationInit = [[0,0,0,0],[0,0,0,0],[0,0,0,0]] # x,y,z for 4 legs
self.ActuatorsAngleInit = [0,0,0] # angle for 3 actuators
# output
self.SpeedOutput = [0,0,0] # x, y speed
self.AttitudeOutput = [0,0,0] # roll pitch yaw rate
self.LegsLocationOutput = [[0,0,0,0],[0,0,0,0],[0,0,0,0]] # x,y,z for 4 legs
self.ActuatorsAngleOutput = [0,0,0] # angle for 3 actuators
def setInterpolationNumber(self,number):
self.ActuatorsMovements.setInterpolationNumber(number)
for leg in range(4):
self.LegsMovements[leg].setInterpolationNumber(number)
self.AttitudeMovements.setInterpolationNumber(number)
self.SpeedMovements.setInterpolationNumber(number)
return True
def setExitstate(self,state):
if state != 'Stand':
self.ExitToStand = False
return True
def setSpeedSequence(self,sequence,cycle_type,cycle_index):
self.SpeedMovements.setSequencePoint(sequence)
self.SpeedMovements.setCycleType(cycle_type,cycle_index)
self.SpeedInit = sequence[0]
def setAttitudeSequence(self,sequence,cycle_type,cycle_index):
self.AttitudeMovements.setSequencePoint(sequence)
self.AttitudeMovements.setCycleType(cycle_type,cycle_index)
self.AttitudeInit = sequence[0]
def setLegsSequence(self,sequence,cycle_type,cycle_index):
for leg in range(4):
self.LegsMovements[leg].setSequencePoint(sequence[leg])
self.LegsMovements[leg].setCycleType(cycle_type,cycle_index)
# init location
self.LegsLocationInit[0][leg] = sequence[leg][0][0]
self.LegsLocationInit[1][leg] = sequence[leg][0][1]
self.LegsLocationInit[2][leg] = sequence[leg][0][2]
def setActuatorsSequence(self,sequence,cycle_type,cycle_index):
self.ActuatorsMovements.setSequencePoint(sequence)
self.ActuatorsMovements.setCycleType(cycle_type,cycle_index)
self.ActuatorsAngleInit = sequence[0]
def runMovementSequence(self):
if self.SpeedEnable == 'SpeedEnable':
self.SpeedOutput = self.SpeedMovements.getNewPoint()
if self.AttitudeEnable == 'AttitudeEnable':
self.AttitudeOutput = self.AttitudeMovements.getNewPoint()
if self.LegsEnable == 'LegsEnable':
for leg in range(4):
leg_loaction = self.LegsMovements[leg].getNewPoint()
for xyz in range(3):
self.LegsLocationOutput[xyz][leg] = leg_loaction[xyz]
if self.ActuatorEnable == 'ActuatorEnable':
self.ActuatorsAngleOutput = self.ActuatorsMovements.getNewPoint()
def getSpeedOutput(self, state = 'Normal'):
if state == 'Init':
return self.SpeedInit
else:
return self.SpeedOutput
def getAttitudeOutput(self, state = 'Normal'):
if state == 'Init':
return self.AttitudeInit
else:
return self.AttitudeOutput
def getLegsLocationOutput(self, state = 'Normal'):
if state == 'Init':
return self.LegsLocationInit
else:
return self.LegsLocationOutput
def getActuatorsAngleOutput(self, state = 'Normal'):
if state == 'Init':
return self.ActuatorsAngleInit
else:
return self.ActuatorsAngleOutput
def getMovementName(self):
return self.MovementName
class MovementScheme:
def __init__(self,movements_lib):
self.movements_lib = movements_lib
self.movements_now = movements_lib[0]
self.movements_pre = movements_lib[0]
self.movement_now_name = movements_lib[0].getMovementName()
self.movement_now_number = 0
self.ststus = 'Movement' # 'Entry' 'Movement' 'Exit'
self.entry_down = False
self.exit_down = False
self.tick = 0
self.legs_location_pre = LocationStanding
self.legs_location_now = LocationStanding
self.attitude_pre = [0,0,0]
self.attitude_now = [0,0,0]
self.speed_pre = [0,0,0]
self.speed_now = [0,0,0]
self.actuators_pre = [0,0,0]
self.actuators_now = [0,0,0]
self.actuator = []
self.actuator.append(ActuatorControl(1))
self.actuator.append(ActuatorControl(2))
self.actuator.append(ActuatorControl(3))
def updateMovementType(self):
self.movements_pre = self.movements_lib[self.movement_now_number]
self.movement_now_number = self.movement_now_number + 1
if self.movement_now_number>= len(self.movements_lib):
self.movement_now_number = 0
self.entry_down = False
self.exit_down = False
self.movements_now = self.movements_lib[self.movement_now_number]
return self.movements_now.getMovementName()
def resetMovementNumber(self):
self.movements_pre = self.movements_lib[self.movement_now_number]
self.movement_now_number = 0
self.entry_down = False
self.exit_down = False
self.movements_now = self.movements_lib[0]
return True
def updateMovement(self,movement_type):
# movement state transition
if movement_type != self.movement_now_name:
self.ststus = 'Exit'
elif(self.entry_down):
self.ststus = 'Movement'
elif(self.exit_down):
self.ststus = 'Entry'
self.movement_now_name = movement_type
# update system tick
self.tick = self.tick+ 1
# movement execute
if self.ststus == 'Entry':
location_ready = self.movements_now.getLegsLocationOutput('Init')
self.legs_location_now,self.entry_down = self.updateMovementGradient(self.legs_location_pre,location_ready)
self.legs_location_pre = self.legs_location_now
if self.ststus == 'Exit':
if self.movements_pre.ExitToStand == False:
self.legs_location_now,self.exit_down = self.updateMovementGradient(self.location_pre,LocationStanding)
self.legs_location_pre = self.legs_location_now
else:
self.legs_location_now = self.legs_location_pre
self.exit_down = True
elif self.ststus == 'Movement':
self.updateMovemenScheme(self.tick)
self.legs_location_pre = self.legs_location_now
self.attitude_pre = self.attitude_now
return self.legs_location_now
def updateMovementGradient(self,location_now,location_target):
loaction_gradient = location_now
gradient_done = False
gradient_done_counter = 0
#legs gradient
for xyz_index in range(3):
for leg_index in range(4):
diff = location_now[xyz_index][leg_index] - location_target[xyz_index][leg_index]
if diff > DeltLocationMax:
loaction_gradient[xyz_index][leg_index] = location_now[xyz_index][leg_index] - DeltLocationMax
elif diff < -DeltLocationMax:
loaction_gradient[xyz_index][leg_index] = location_now[xyz_index][leg_index] + DeltLocationMax
else :
loaction_gradient[xyz_index][leg_index] = location_target[xyz_index][leg_index]
gradient_done_counter = gradient_done_counter + 1
# movement gradient is down
if gradient_done_counter == 12:
gradient_done = True
return loaction_gradient, gradient_done
def updateMovemenScheme(self,tick):
# run movement
self.movements_now.runMovementSequence()
# legs movement
self.legs_location_now = self.movements_now.getLegsLocationOutput('normal')
# speed movement
self.speed_now = self.movements_now.getSpeedOutput('normal')
# attitude movement
self.attitude_now = self.movements_now.getAttitudeOutput('normal')
# attitude movement
self.actuators_now = self.movements_now.getActuatorsAngleOutput('normal')
# attitude process
'''
for rpy in range(3):
#limite attitude angle
if attitude_now[rpy] < AttitudeMinMax[rpy][0]:
attitude_now[rpy] = AttitudeMinMax[rpy][0]
elif attitude_now[rpy] > AttitudeMinMax[rpy][1]:
attitude_now[rpy] = AttitudeMinMax[rpy][1]
'''
# speed process
return True
def runMovementScheme(self,transition):
# update movement
movement_name = ''
if transition == True:
movement_name = self.updateMovementType()
self.updateMovement(movement_name)
return True
def getMovemenSpeed(self):
speed_now = [0,0,0]
for xyz in range(3):
speed_now[xyz] = -self.speed_now[xyz]
return speed_now
def getMovemenLegsLocation(self):
return self.legs_location_now
def getMovemenAttitude(self):
attitude_now_rad = [0,0,0]
for rpy in range(3):
#angle to radin
attitude_now_rad[rpy] = -self.attitude_now[rpy] / 57.3
return attitude_now_rad
def getMovemenActuators(self):
return self.actuators_now
|
Subsets and Splits