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 |
For the examples, you can get the motor driver's Tx and Rx data as follows:
| tx3 = moby.get_motor_dirver_tx(3)
rx3 = moby.get_motor_dirver_rx(3)
print(tx3)
print(rx3)
|
Output:
| {'statusWord': 5175, 'modeOpDisp': 10, 'actualPosition': -23, 'actualVelocity': 0, 'actualTorque': 0}
{'controlWord': 15, 'modeOp': 10, 'targetPosition': 0, 'targetVelocity': 0, 'targetTorque': 0}
|
Get Moby status data
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 |
For the examples, you can get Moby's current state and error state as follows:
| state = moby.get_moby_state()
print(state)
error = moby.get_moby_error_state()
print(error)
|
Output:
| {'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
|
Here, Moby's error category is
- 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
Get Moby Odometry and Physical data
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 |
For the examples, you can get the MobyOdometry and Physical data as follows:
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:
| 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}
|
In this example, the MobyOdometry and Physical data are retrieved using the respective functions, and the pose is reset to its initial state using the reset_moby_pose()
function.
Get Sensor data
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 |
For the examples, you can get the sensor data as follows:
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:
| 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}
|
In this example, the gyro_data, imu_data, ir_data, and bms_data variables store the data from the gyroscope, IMU, IR sensors, and BMS, respectively. You can access specific values using the keys in the dictionary. For example, to access the x-axis angle value of the IMU data, you would use imu_data[0][0].
This example shows how to access specific values from the sensor data dictionaries and print them out.
Moby Motion Command
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 |
For the examples, you can control Moby's motion using the following commands:
| # 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)
|
These examples demonstrate how to use the Moby motion commands to control the robot's movement.