K-Bot KOS Quick Start

SERVERS

KOS-Sim

conda activate your_env_name

pip install kos-sim

kos-sim kbot-v1 --no-gravity --no-render

KOS-Sim is now listening

  • you can leave the render on, but there may be latency issues. Disable the rendering if you face this.

KOS-K-Bot

Set up CAN lines to communicate with actuators.

#!/bin/bash 
for i in {0..4} 	
	do echo "Setting up can$i..." 	
	sudo ip link set can$i down 	
	sudo ip link set can$i type can bitrate 1000000 	
	sudo ip link set can$i txqueuelen 1000 	
	sudo ip link set can$i up 
done
	

Running on Robot

mkdir local_crates
cd local_crates
git clone -b parse-faults https://github.com/kscalelabs/actuator.git

conda create -n kos-kbot_env_name python=3.11

conda activate kos-kbot_env_name

pip install numpy scipy pygame kinfer==0.0.5 pykos

cargo run --release

KOS is now listening

telemetry

on the same device, new terminal

mosquitto_sub -t '#' > today_date.txt

CLIENT

write python code to interact with it, like

https://github.com/kscalelabs/kbot-unit-tests

waveform test: https://github.com/kscalelabs/tests

from pykos import KOS
async with KOS(ip=args.host, port=args.port) as sim_kos, \
	         KOS(ip="100.89.14.31", port=args.port) as real_kos:
	  await sim_kos.sim.reset()
	  await configure_robot(sim_kos)
	  await configure_robot(real_kos)
	  print("Homing...")
	  homing_command = [{
	      "actuator_id": actuator.actuator_id,
	      "position": 0.0
	  } for actuator in ACTUATOR_LIST]
	  await asyncio.gather(
	      sim_kos.actuator.command_actuators(homing_command),
	      real_kos.actuator.command_actuators(homing_command),
	  )
	  await asyncio.sleep(2)