Communication protocol
Robot | Protocol V2 | CAN | Support Status |
---|---|---|---|
Scout 2.0 | Y | Y | Active |
Scout Mini | Y | Y | Active |
Hunter 2.0 | Y | Y | Active |
Bunker | Y | Y | Active |
Tracer | Y | Y | Active |
$ pip3 install pyagxrobots
$ pip3 -V
$ python3 -m pip install --upgrade pip
-
Enable gs_usb kernel module
$ sudo modprobe gs_usb
-
Bringup can device
$ sudo ip link set can0 up type can bitrate 500000
-
If no error occured during the previous steps, you should be able to see the can device now by using command
$ ifconfig -a
-
Install and use can-utils to test the hardware
$ sudo apt install can-utils
-
Testing command
# receiving data from can0 $ candump can0 # send data to can0 $ cansend can0 001#1122334455667788
You can run step 1-5 or "./setup_can2usb.bash" for the first-time setup and run step 2 or"./bringup_can2usb.bash" to bring up the device each time you unplug and re-plug the adapter.
#!/usr/bin/env python3
# coding=utf-8
import pyagxrobots
robots=pyagxrobots.pysdkugv.robotstype() # robotstype depend on your robot
EnableCAN()
SetMotionCommand()
SetLightCommand()
GetRobotStae:
MotionCommandMessage:
GetLinearVelocity()
GetAngularVelocity()
GetLateralVelocity()
GetSteeringAngle()
LightCommandMessage:
GetLightCmdCtrl()
GetFrontMode()
GetFrontCustom()
GetRearMode()
GetRearCustom()
SystemStateMessage:
GetVehicleState()
GetControlMode()
GetBatteryVoltage()
GetErrorCode()
RcStateMessage:
OdometryMessage:
GetLeftWheel()
GetRightWheel()
ActuatorStateMessageV2:
rpm()
current()
pulse_count()
driver_voltage()
driver_temp()
motor_temp()
driver_state()
- Prototype:
EnableCAN()
- Description: Enable command and control mode.
- Prototype:
SetMotionCommand()
- Description:Send Version Request to robots.
- Parameters
linear_vel
:(float)angular_vel
:(float)lateral_velocity
:(float)steering_angle
:(float)
- Prototype:
GetLinearVelocity()
- Description:Get the linear velocity from robot
- Return:linear velocity
- Prototype:
GetAngularVelocity()
- Description:Get the angular velocity from robot.
- Return:angular velocity
- Prototype:
GetSteeringAngle()
- Description:Get the steering angle from robot .
- Return:steering angle
- Prototype:
GetLateralVelocity()
- Description:Get the lateral velocity from robot .
- Return:lateral velocity
- Prototype:
GetControlMode()
- Description:Get the control mode from robot .
- Return:control mode
- Prototype:
GetLeftWheelOdeo()
- Description:get robots LeftWheelOdom .
- Return:LeftWheelOdom
- Prototype:
GetRightWheelOdom()
- Description:get robots RightWheelOdom .
- Return:RightWheelOdeom
- Prototype:
GetBatteryVoltage()
- Description:Get the battery voltage from robot
- Return:battery voltage
- Prototype:
GetErrorCode()
- Description:Get the error code from robot
- Return:error code
#!/usr/bin/env python3
# coding=UTF-8
import pyagxrobots
import time
scoutmini=pyagxrobots.pysdkugv.ScoutMiniBase()
scoutmini.EnableCAN()
num=5
while num>0:
scoutmini.SetMotionCommand(linear_vel=0.1)
print(scoutmini.GetLinearVelocity())
time.sleep(0.3)
num-=1
#!/usr/bin/env python3
# coding=UTF-8
import pyagxrobots
import time
bunker=pyagxrobots.pysdkugv.BunkerBase()
bunker.EnableCAN()
num=5
while num>0:
bunker.SetMotionCommand(linear_vel=0.1)
print(bunker.GetLinearVelocity())
time.sleep(0.3)
num-=1