api

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIBaseURL = "/leubot/v1.2"

APIBaseURL is the path to the API

View Source
var APIHost = "api.interactions.ics.unisg.ch"

APIHost is the hostname

View Source
var APIProto = "https://"

APIProto for API access protocol

View Source
var HandlerChannel chan HandlerMessage

HandlerChannel is used to communicate between the router and other application logic

Functions

func AddUser

func AddUser(w http.ResponseWriter, r *http.Request)

func GenerateToken

func GenerateToken() string

GenerateToken creates a new token

func GetPosture added in v1.2.2

func GetPosture(w http.ResponseWriter, r *http.Request)

GetPosture gets the current posture

func GetState added in v1.2.2

func GetState(w http.ResponseWriter, r *http.Request)

GetState gets the current value for each joint

func GetUser

func GetUser(w http.ResponseWriter, r *http.Request)

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger handles the logging in the router

func NewRouter

func NewRouter(hmc chan HandlerMessage) *mux.Router

NewRouter creats a new instance of Router

func PutBase

func PutBase(w http.ResponseWriter, r *http.Request)

PutBase processes the request

func PutElbow

func PutElbow(w http.ResponseWriter, r *http.Request)

PutElbow processes the request for Elbow

func PutGripper

func PutGripper(w http.ResponseWriter, r *http.Request)

PutGripper processes the request for Gripper

func PutPosture added in v1.1.1

func PutPosture(w http.ResponseWriter, r *http.Request)

PutPosture sets all the joints at once

func PutReset

func PutReset(w http.ResponseWriter, r *http.Request)

PutReset processes the request to reset

func PutShoulder

func PutShoulder(w http.ResponseWriter, r *http.Request)

PutShoulder processes the request for Shoulder

func PutWristAngle

func PutWristAngle(w http.ResponseWriter, r *http.Request)

PutWristAngle processes the request for WristAngle

func PutWristRotation

func PutWristRotation(w http.ResponseWriter, r *http.Request)

PutWristRotation processes the request for WristRotation

func RemoveUser

func RemoveUser(w http.ResponseWriter, r *http.Request)

Types

type HandlerMessage

type HandlerMessage struct {
	Type  HandlerMessageType
	Value []interface{}
}

HandlerMessage contains the payload for the command messages

type HandlerMessageType

type HandlerMessageType int

HandlerMessageType is the type for HandlerMessage

const (
	// TypeAddUser is to add a user
	TypeAddUser HandlerMessageType = iota
	// TypeUserAdded says the user is added
	TypeUserAdded
	// TypeUserExisted says a user already exists
	TypeUserExisted
	// TypeInvalidUserInfo says something wrong about the user to be added
	TypeInvalidUserInfo
	// TypeDeleteUser is to delete a user
	TypeDeleteUser
	// TypeUserDeleted says the user is deleted
	TypeUserDeleted
	// TypeUserNotFound says no such user exists
	TypeUserNotFound
	// TypeGetUser is to get the current user
	TypeGetUser
	// TypeCurrentUser has the current user info
	TypeCurrentUser
	// TypeGetBase is to get Base
	TypeGetBase
	// TypeGetShoulder is to get Shoulder
	TypeGetShoulder
	// TypeGetElbow is to get Elbow
	TypeGetElbow
	// TypeGetWristAngle is to get WristAngle
	TypeGetWristAngle
	// TypeGetWristRotation is to get WristRotation
	TypeGetWristRotation
	// TypeGetGripper is to get Gripper
	TypeGetGripper
	// TypeGetPosture is to get a posture
	TypeGetPosture
	// TypeCurrentBase returns Base
	TypeCurrentBase
	// TypeCurrentShoulder returns Shoulder
	TypeCurrentShoulder
	// TypeCurrentElbow returns Elbow
	TypeCurrentElbow
	// TypeCurrentWristAngle returns WristAngle
	TypeCurrentWristAngle
	// TypeCurrentWristRotation returns WristRotation
	TypeCurrentWristRotation
	// TypeCurrentGripper returns Gripper
	TypeCurrentGripper
	// TypeCurrentPosture returns Posture
	TypeCurrentPosture
	// TypePutBase is to change Base
	TypePutBase
	// TypePutShoulder is to change Shoulder
	TypePutShoulder
	// TypePutElbow is to change Elbow
	TypePutElbow
	// TypePutWristAngle is to change WristAngle
	TypePutWristAngle
	// TypePutWristRotation is to change WristRotation
	TypePutWristRotation
	// TypePutGripper is to change Gripper
	TypePutGripper
	// TypePutPosture is to set a posture
	TypePutPosture
	// TypePutReset is to reset Leubot
	TypePutReset
	// TypeActionPerformed says the action was performed
	TypeActionPerformed
	// TypeInvalidToken says something is wrong with Token
	TypeInvalidToken
	// TypeInvalidCommand says no such command
	TypeInvalidCommand
	// TypeSomethingWentWrong says it didn't go well
	TypeSomethingWentWrong
)

type JointInfo added in v1.2.2

type JointInfo struct {
	Name  string `json:"name"`
	Value uint16 `json:"value"`
}

JointInfo is a struct for each joint

type PostureCommand added in v1.1.1

type PostureCommand struct {
	Token         string `json:"token"`
	Base          uint16 `json:"base"`
	Shoulder      uint16 `json:"shoulder"`
	Elbow         uint16 `json:"elbow"`
	WristAngle    uint16 `json:"wristAngle"`
	WristRotation uint16 `json:"wristRotation"`
	Gripper       uint16 `json:"gripper"`
	Delta         uint8  `json:"delta"`
}

PostureCommand is a struct for a posture

type RobotCommand

type RobotCommand struct {
	Token string `json:"token"`
	Value uint16 `json:"value"`
}

RobotCommand is a struct for each command

type RobotPose added in v1.2.2

type RobotPose struct {
	Base          uint16
	Shoulder      uint16
	Elbow         uint16
	WristAngle    uint16
	WristRotation uint16
	Gripper       uint16
}

RobotPose stores the rotations of each joint

func (*RobotPose) BuildArmLinkPacket added in v1.2.2

func (rp *RobotPose) BuildArmLinkPacket(delta uint8) *armlink.ArmLinkPacket

BuildArmLinkPacket creates a new ArmLinkPacket

func (*RobotPose) String added in v1.2.2

func (rp *RobotPose) String() string

String returns a string rep for the rp

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route is a basic pattern of the rounting

type Routes

type Routes []Route

Routes contain the Route

type Token

type Token struct {
	Token string `json:"token"`
}

Token for the user token

type User

type User struct {
	Name  string
	Email string
	Token string
}

func NewUser

func NewUser(userInfo *UserInfo) *User

func (*User) ToUserInfo

func (u *User) ToUserInfo() UserInfo

type UserInfo

type UserInfo struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL