Skip to content

Moby gRPC Client Python API

Moby gRPC API List

Get EtherCAT Tx/Rx data

Command Description Parameters Return Type
get_motor_dirver_tx(slave_num: int) Get the EtherCAT Tx data of motor driver by index. slave_num: int dict
get_motor_dirver_rx(slave_num: int) Get the EtherCAT Rx data of motor driver by index. slave_num: int dict

예시로 모터 드라이버의 Tx 및 Rx 데이터를 다음과 같이 얻을 수 있습니다.

1
2
3
4
tx3 = moby.get_motor_dirver_tx(3)
rx3 = moby.get_motor_dirver_rx(3)
print(tx3)
print(rx3)

출력

1
2
{'statusWord': 5175, 'modeOpDisp': 10, 'actualPosition': -23, 'actualVelocity': 0, 'actualTorque': 0}
{'controlWord': 15, 'modeOp': 10, 'targetPosition': 0, 'targetVelocity': 0, 'targetTorque': 0}

Moby 상태 데이터 얻기

Command Description Parameters Return Type
get_moby_state() Get the current state of the Moby - dict
get_moby_error_state() Get the error state of the Moby - str

예시로 Moby의 상태와 에러상태를 다음과 같이 얻을 수 있습니다.

1
2
3
4
5
state = moby.get_moby_state()
print(state)

error = moby.get_moby_error_state()
print(error)

출력

1
2
3
{'is_ready': True, 'is_moving': False, 'is_move_finished': True, 'is_emg_pushed': False, 'is_error_state': False, 'is_home_pose': False, 'is_resetting': False, 'is_imu_avail': True, 'is_program_running': False, 'is_program_pause': False, 'is_rotation_zero': False}

NONE

에러 유형은 다음과 같습니다.

  • NONE
  • HW_EMG_PUSH
  • HW_CONNECTION_LOST
  • ECAT_MASTER_NOT_OP
  • ECAT_SLAVE_NOT_OP
  • ECAT_MOTOR_NOT_SERVO_ON
  • ECAT_MOTOR_ERROR
  • ECAT_SYSTEM_NOT_READY
  • ECAT_ENCODER1_ERROR
  • ECAT_ENCODER2_ERROR
  • ECAT_ENCODER3_ERROR
  • ECAT_ENCODER4_ERROR
  • SW_POSITION_LIMIT
  • SW_TORQUE_LIMIT

오도메트리와 로봇 역학 데이터

Command Description Parameters Return Type
get_moby_pose() Get the Moby pose including position and orientation. None list
get_moby_vel() Get the Moby velocity including linear and angular velocities. None list
reset_moby_pose() Reset the Moby pose to its initial state. None None
get_rotation_angle() Get the Moby's rotation angle. None dict
get_drive_speed() Get the drive speed of Moby. None list
get_target_vel() Get the target velocity of Moby. None list
get_zero() Get the zero point of Moby. None dict

사용 예시는 다음과 같습니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
pose_data = moby.get_moby_pose()
vel_data = moby.get_moby_vel()
rotation_angle = moby.get_rotation_angle()
drive_speed = moby.get_drive_speed()
target_vel = moby.get_target_vel()
zero_point = moby.get_zero()

print("Pose", pose_data)
print("Velocity", vel_data)
print("Rotation angle", rotation_angle)
print("Driving speed", drive_speed)
print("Target velocity", target_vel)
print("Zero position", zero_point)

moby.reset_moby_pose()

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Pose [0.0, 0.0, -0.0]

Velocity [0.0, 0.0, 0.0]

Rotation angle {'fl': -0.0, 'fr': -0.00, 'bl': 0.00, 'br': -0.00}

Driving speed {'fl': 0.0, 'fr': 0.0, 'bl': 0.0, 'br': 0.0}

Target velocity [0.0, 0.0, 0.0]

Zero position {'fl': 9410731, 'fr': -2143286890, 'bl': 266461587, 'br': -1685613215}

이 예시에서 Odometry 및 Physical 데이터는 얻는 것을 보여주며, Pose는 reset_moby_pose() 함수를 사용하여 초기 상태로 재설정 할 수 있습니다.

센서 값 획득

Command Description Parameters Return Type
get_gyro_data() Get the gyroscope data. Heading angle and angular velocity as [rad] and [rad/s] units None dict
reset_gyro() Reset the gyroscope data None None
get_imu_data() Get the Inertial Measurement Unit (IMU) data. Angle, angular velocity, linear acceleration None [list, list, list]
get_ir_data() Get the Infrared (IR) sensor data None dict
get_bms() Get the Battery Management System (BMS) data None dict

사용 예시는 다음과 같습니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
gyro_data = moby.get_gyro_data()
moby.reset_gyro()
imu_data = moby.get_imu_data()
ir_data = moby.get_ir_data()
bms_data = moby.get_bms()

print("Gyro data")
print(gyro_data)
print("IMU all")
print(imu_data)
print("IR data")
print(ir_data)
print("BMS")
print(bms_data)

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Gyro data
[-0.0, -0.0]

IMU all
([0.0, 0.0, -0.0], [0.0, 0.0, 0.0], [-0.0, 0.0, 9.56148375])

IR data
{'ir_front1': 65535, 'ir_front2': 65535, 'ir_left1': 65535, 'ir_left2': 65535, 'ir_left3': 65535, 'ir_rear': 65535, 'ir_right1': 65535, 'ir_right2': 65535, 'ir_right3': 65535}

BMS
{'BMS status-1': 98.0, 'BMS status-2': 98.0, 'Pack voltage-1': 55.59, 'Pack voltage-2': 55.87, 'Battery Voltage-1': 55.63, 'Battery Voltage-2': 55.64, 'Pack current1-1': 0.0, 'Pack current1-2': 0.0, 'Pack current2-1': -0.2, 'Pack current2-2': -0.4}

이 예제에서 gyro_data, imu_data, ir_data 및 bms_data 변수는 각각 자이로스코프, IMU, 적외선 센서 및 BMS에서 데이터를 저장합니다. 딕셔너리의 키를 사용하여 특정 값을 액세스할 수 있습니다. 예를 들어, IMU 데이터의 x축 각도 값을 액세스하려면 imu_data[0][0]을 사용하면 됩니다.

이 예제는 센서 데이터 딕셔너리에서 특정 값을 액세스하고 출력하는 방법을 보여줍니다.

Moby 모션 커맨드

Command Description Parameters
stop_motion() Stops all motion of Moby. None
set_target_velocity(vx: float, vy: float, vw: float) Sets the target linear and angular velocities for Moby. vx: float
vy: float
vw: float
move_rotation_deg(fl: float, fr: float, bl: float, br: float) Rotates each wheel of Moby by specified angles in degrees. fl: float
fr: float
bl: float
br: float
move_driving_mps(fl: float, fr: float, bl: float, br: float) Drives each wheel of Moby at specified speeds in meters per second. fl: float
fr: float
bl: float
br: float

사용 예시는 다음과 같습니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Stop Moby's motion
moby.stop_motion()

# Set target velocity (linear_x, linear_y, angular_z)
moby.set_target_velocity(0.5, 0.0, 0.1)

# Rotate each wheel by 90 degrees
moby.move_rotation_deg(fl=90, fr=90, bl=90, br=90)

# Drive each wheel forward for 0.5 m/s
moby.move_driving_mps(fl=0.5, fr=0.5, bl=0.5, br=0.5)

상기 예제는 Moby 모션 명령을 사용하여 로봇의 움직임을 제어하는 방법을 보여줍니다.