6. Quick Start for Secondary Development
6. Quick Start for Secondary Development
This section demonstrates how to quickly run your first secondary development program through several simple example programs, to establish a basic understanding.
The quick start tutorial takes the example of deploying the secondary development program on the HDU and using a Python venv virtual environment.
6.1 Prerequisites
6.1.1 Connect to HDU
- Confirm IP and connect via WiFi
The development machine and the robot need to be connected to the same wireless network. Obtain the robot's IP from the WLAN interface in AimMaster's settings (this is the WiFi IP of the HDU). After connecting via SSH, you can jump to the MDU via 10.42.10.12.
6.1.2 Create Deployment Program Folder
The recommended program deployment directory is /agibot/. The onboard disk cleanup module will periodically clean up space, but this folder is whitelisted and will not be cleaned.
Placing programs or data in other paths may cause the partition to fill up or files to be accidentally deleted. Please strictly follow the convention of using the /agibot/ directory.
mkdir -p /agibot/data/home/agi/Desktop
If you encounter permission issues, you can use the following commands to create the folder:
sudo mkdir -p /agibot/data/home/agi/Desktop
sudo chown -R agi:agi /agibot/data/home/agi
6.1.3 Create Python Virtual Environment
cd /agibot/data/home/agi/Desktop
python -m venv mydev
source mydev/bin/activate
All subsequent examples assume that the virtual environment has been created and activated, and this step will not be repeated.
6.2 Example: Query Silent Mode Program
This example uses an HTTP request to query silent mode.
Run the following script directly in the ORIN command line:
curl --location --request POST 'http://10.42.10.10:59301/rpc/aimdk.protocol.AgentControlService/GetVoiceEnable' \
--header 'Content-Type: application/json' \
--data-raw '{}'
The returned result should be as follows (the meaning of each field is explained in detail in later interface sections):
{"header":{"code":"0","msg":"GetVoiceEnable successfully","trace_id":"","domin":""},"enable_voice":true}
6.3 Example: Get Robot Upper Limb Joint State
Save the following code as /agibot/data/home/agi/Desktop/joint_state.py on the HDU.
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from rclpy.qos import QoSHistoryPolicy, QoSProfile, QoSReliabilityPolicy
from sensor_msgs.msg import JointState
class JointStateSubscriber(Node):
def __init__(self, topic_name: str):
super().__init__("joint_state_subscriber")
self.topic_name = topic_name
qos_profile = QoSProfile(
history=QoSHistoryPolicy.KEEP_LAST, depth=10, reliability=QoSReliabilityPolicy.BEST_EFFORT
)
self.subscription = self.create_subscription(JointState, topic_name, self.listener_callback, qos_profile)
def listener_callback(self, msg: JointState):
self.get_logger().info(f"=== Received {self.topic_name} ===")
self.get_logger().info(f" header: {msg.header}")
self.get_logger().info(f" name: {msg.name}")
self.get_logger().info(f" position: {msg.position}")
self.get_logger().info(f" velocity: {msg.velocity}")
self.get_logger().info(f" effort: {msg.effort}")
def main(args=None):
rclpy.init(args=args)
joint_state_node = JointStateSubscriber("/motion/control/arm_joint_state")
try:
rclpy.spin(joint_state_node)
except KeyboardInterrupt:
pass
finally:
joint_state_node.destroy_node()
rclpy.shutdown()
if __name__ == "__main__":
main()
Then execute the following commands:
source /agibot/software/v0/entry/env/env.sh
python3 /agibot/data/home/agi/Desktop/joint_state.py